API keys
Create, store, rotate, and revoke the secret keys and public tokens that connect your code to Toggld.
Your code authenticates to Toggld with a credential in the Authorization: Bearer header. Each credential belongs to one environment of one workspace. The credential selects both, so you never send them in a request.
Secret keys are shown only once, when you create them. Create a key
Needed for the Management API. Use a key with the management role.
Pasted keys stay in this browser tab and clear when you close it. The docs never send them anywhere. Only requests you run from the API playground use them.
Credential types
| Credential | Dashboard name | Prefix | Use it in | It can |
|---|---|---|---|---|
Secret key, evaluation role | Server SDK key (Read-only) | ffk_ | Backend services and SDKs | Evaluate flags and download full flag definitions, including targeting rules. It cannot change anything. |
Secret key, management role | Management key (Full access) | ffk_ | CI, automation, and tooling | Do everything a server SDK key can, and read and change flags, segments, environments, and keys through the Management API. |
| Public token | Public token (Non-secret) | ffp_ | Browser and mobile code | Evaluate flags. It cannot download definitions, read the Management API, or change anything. |
Choose the least powerful credential that does the job. For a backend that only reads flags, use a server SDK key.
Never ship secret keys to clients
Anyone with a server SDK key can read your full flag configuration, including targeting rules and segment members. Anyone with a management key can change your flags. Keep secret keys on trusted servers, out of browser bundles, mobile apps, logs, and source control.
Where to find them
Open Settings → API Keys. The page shows the API endpoint to use with your SDK, then one section per environment. Each section has:
- One Public token, with a Copy button.
- A list of Secret API keys, with the name, type, a masked prefix, and the creation date.
Owners, admins, and members can view and manage credentials. Only owners and admins can create management keys, because a management key can also change environments and keys. Readers cannot see this page.
Create a secret key
- Open Settings → API Keys.
- In the section for the environment that you need, select Create key.
- Enter a Key name, such as
Checkout API production. Only your team sees it. - Under Access, choose Server SDK key or Management key. Only owners and admins see Management key.
- Select Create key.
- Copy the key and store it in your secret manager.
Shown once
Toggld shows the full secret key only once. It stores a SHA-256 hash, not the key, so nobody can show it to you again. If you lose a key, delete it and create a new one.
Set the key in your server environment, not in code:
TOGGLD_SDK_KEY=ffk_YOUR_SECRET_KEYPublic tokens
Every environment has exactly one public token. Toggld creates it for you. Public tokens are safe to embed in client-side code, because they can only evaluate flags. See Browser.
const PUBLIC_TOKEN = "ffp_YOUR_PUBLIC_TOKEN";You cannot rotate or revoke a public token. It stops working only when you delete its environment. Because anyone can read evaluated values with it, never put secrets in variant values or flag metadata.
Rotate a secret key
Rotate keys regularly, and at once if a key may be exposed.
- Create a new key in the same environment, with the same access.
- Deploy the new key to every application that uses the old one.
- Confirm that the applications work with the new key.
- Delete the old key.
Delete (revoke) a secret key
- Open Settings → API Keys.
- Find the key and select the delete icon.
- In Delete this secret key?, select Delete key.
Applications that use the key lose API access. You cannot undo the deletion. On the hosted API, a deleted key can keep working for up to 60 seconds while edge caches expire.
If a key leaks
- Create a replacement key and deploy it.
- Delete the leaked key.
- Check the audit log for changes made with the key. The actor of each event shows the API key ID.
Never send keys to Toggld support.
Management keys and environments
A management key reads and writes the flag configuration of its own environment. Some operations still reach the whole workspace:
- Changes to shared flag fields (name, description, tags, metadata) apply to every environment.
- Deleting a flag removes it from every environment.
- Segment changes apply to every environment.
- A management key can create and delete environments, and create and revoke keys for any environment.
Treat every management key as workspace-wide access.
Manage keys with the API
Key endpoints require a management key.
Create a key. environment is required. It is the key of the environment that the new key belongs to:
curl https://api.toggld.io/api/v1/keys \
-H "Authorization: Bearer ffk_YOUR_MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{ "role": "evaluation", "name": "Checkout API", "environment": "production" }'The response (HTTP 201) includes token, the full secret key. It is the only time the API returns it.
List keys. The response shows each key's prefix, never the full key:
curl https://api.toggld.io/api/v1/keys \
-H "Authorization: Bearer ffk_YOUR_MANAGEMENT_KEY"Revoke a key by its id:
curl -X DELETE https://api.toggld.io/api/v1/keys/KEY_ID \
-H "Authorization: Bearer ffk_YOUR_MANAGEMENT_KEY"List the public tokens of every environment:
curl https://api.toggld.io/api/v1/public-tokens \
-H "Authorization: Bearer ffk_YOUR_MANAGEMENT_KEY"See Authentication for which credential each endpoint accepts.