- Bearer tokens — Used for management operations: creating flags, managing members, configuring environments, and other admin tasks. Obtained by logging in.
- API keys — Used by your application servers and SDKs to evaluate feature flags. Scoped to a specific environment.
- Bearer tokens
- API keys
Bearer tokens
Bearer tokens are JWT access tokens scoped to your current organization membership and permission set. You obtain them by logging in.Obtaining a token
token— JWT access token with a 1-hour expiry. Use this in theAuthorizationheader for all management requests.refresh_token— JWT refresh token with a 30-day expiry. Use this to obtain new access tokens without re-entering credentials.current_organization— The organization context the token is scoped to, including your role in that organization.organizations— All organizations you belong to. Use these IDs to switch context.
Using the token
Include the access token in theAuthorization header as a Bearer token on every management request:Token expiry and scoping
| Token | Expiry | Purpose |
|---|---|---|
token (access token) | 1 hour | Authenticate management API requests |
refresh_token | 30 days | Obtain new access tokens |
Token refresh
Access tokens expire after 1 hour. Use the refresh token to get a new access token without requiring the user to log in again. The refresh token is rotated on each use — the old refresh token is invalidated and a new one is returned.Always replace your stored refresh token with the new one returned in the response. The previous refresh token is immediately invalidated.
Organization switching
If you belong to multiple organizations, your access token is scoped to one organization at a time. To switch context, callPOST /api/v1/me/switch-organization with your target organization ID and your current refresh token.
token is now scoped to the new organization. The current_organization field reflects the switched context. The refresh token is rotated as part of this operation.
You must be a member of the target organization for the switch to succeed. A
403 Forbidden is returned if you are not.Security best practices
Store tokens securely
Store tokens securely
- Never store bearer tokens or API key secrets in source code, client-side JavaScript, or version control.
- Use environment variables or a secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault) to inject credentials at runtime.
- For browser-based applications, avoid storing tokens in
localStorage— preferhttpOnlycookies or in-memory storage.
Rotate API keys regularly
Rotate API keys regularly
API keys do not expire by default. Rotate them periodically or after any suspected compromise using
POST /api/v1/projects/{project_id}/api-keys/{id}/rotate. The old secret is immediately invalidated when rotated.You can also set an expires_at timestamp when creating or rotating a key to enforce automatic expiry.Use minimum required scopes
Use minimum required scopes
When creating API keys, choose the narrowest scope that meets your use case:
- Use
serverorsdkfor flag evaluation — notstreamunless you need real-time updates. - Never use a bearer token in application code that evaluates flags. Bearer tokens have broad management permissions and are not intended for machine-to-machine evaluation calls.
Handle token expiry gracefully
Handle token expiry gracefully
Access tokens expire after 1 hour. Build token refresh logic into your application:
- Catch
401 Unauthorizedresponses. - Call
POST /api/v1/refresh-tokenwith your stored refresh token. - Update your stored tokens with the new access token and rotated refresh token.
- Retry the original request.
Revoke keys when no longer needed
Revoke keys when no longer needed
When decommissioning a service or rotating credentials, revoke old API keys with
DELETE /api/v1/projects/{project_id}/api-keys/{id}. This immediately invalidates the key and prevents further use.