# Minting restricted Sprite API tokens programmatically

**URL:** <https://community.fly.io/t/minting-restricted-sprite-api-tokens-programmatically/28958>\
**Category:** Questions / Help\
**Tags:** wishlist, security, sprites\
**Created:** [October 30, 2026, 7:57pm UTC](https://community.fly.io/t/minting-restricted-sprite-api-tokens-programmatically/28958 "2026-10-30T19:57:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adelessert](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/adelessert/32/44766_2.png) [@adelessert](https://community.fly.io/u/adelessert)\
**Post date:** [October 30, 2026, 7:57pm UTC](https://community.fly.io/t/minting-restricted-sprite-api-tokens-programmatically/28958/1 "2026-10-30T19:57:50Z")

</div>

I’m able to generate Sprites API tokens from the web admin that have useful restrictions: limiting access by Sprite name prefix, the number of Sprites it can launch, an expiry date. I’m also able to exchange a [Fly.io](http://Fly.io) token for a sprites token via the SDK `SpritesClient.create_token()`method, but as best I can tell there’s no way to apply those same restrictions.

Are there any plans (or existing ways that I’m not finding) to be able to generate tokens like this? We’ve got a variety of Sprites being orchestrated by a central system and it’d be super valuable to be able to spin out temporary/restricted credentials.

---

<div class="post-metadata">

**Author:** ![flyio-support](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/flyio-support/32/46245_2.png) [@flyio-support](https://community.fly.io/u/flyio-support)\
**Post date:** [November 9, 2026, 3:24pm UTC](https://community.fly.io/t/minting-restricted-sprite-api-tokens-programmatically/28958/5 "2026-11-09T15:24:10Z")

</div>

There is a way to do this today, though create\_token() doesn’t expose it. Use that method to exchange your [Fly.io](http://Fly.io) token for an unrestricted Sprites token, then use that token to call the API directly, or use a Sprites token from the dashboard directly. Here’s how to mint restricted tokens :

```auto
curl -X POST https://api.sprites.dev/v1/tokens \
  -H "Authorization: Bearer $SPRITES_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "CI pipeline",
    "policy": {
      "name_prefix": "ci-",
      "max_sprites_total": 10,
      "expires_at": "2026-12-31T23:59:59Z"
    }
  }'

```

The response includes the restricted token in token, and it’s only shown once. All policy fields are optional, and policy also accepts label. Only an unrestricted token can create new tokens, so treat the exchanged token as an admin credential.

---

<div class="post-metadata">

**Author:** ![adelessert](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/adelessert/32/44766_2.png) [@adelessert](https://community.fly.io/u/adelessert)\
**Post date:** [November 9, 2026, 3:44pm UTC](https://community.fly.io/t/minting-restricted-sprite-api-tokens-programmatically/28958/6 "2026-11-09T15:44:29Z")

</div>

Awesome, thanks so much!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [November 11, 2026, 3:44pm UTC](https://community.fly.io/t/minting-restricted-sprite-api-tokens-programmatically/28958/7 "2026-11-11T15:44:54Z")

</div>

Closed on November 11, 2026, 3:44pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
