Minting restricted Sprite API tokens programmatically

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 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.

There is a way to do this today, though create_token() doesn’t expose it. Use that method to exchange your 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 :

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.

Awesome, thanks so much!