Keys and access
Rotation, revoking and security
Rotate a key without downtime
An application can have several active secret keys at once, so both the old and the new key work while you switch and no request fails.
- On the application's API keys & webhooks page, create a new secret key with the same role as the old one.
- Put the new key in the service's environment, for example
FOXLOGIN_SECRET_KEY, and redeploy or restart the service. - Watch the keys table. The new key shows a recent Last used time and the old key's time stops changing. Fox Login updates this time at most once a minute.
- Revoke the old key. A request that still sends it gets
401 invalid_api_key.
A script can run the whole rotation with an organization API key that has keys:write. POST /applications/{app_id}/secret_keys creates the new key, GET /applications/{app_id}/secret_keys returns last_used_at for every key, and DELETE /applications/{app_id}/secret_keys/{key_id} revokes the old one. See Secret key roles.
Rotate a key when someone who could read it leaves the team, and after any incident that may have exposed it.
Revoke a key
Choose Revoke next to the key on the application's API keys & webhooks page and confirm. The key stops working at once, and every call with it gets 401 invalid_api_key. It stays in the list with its revocation date. You cannot restore a revoked key; create a new one instead.
The API equivalent is DELETE /applications/{app_id}/secret_keys/{key_id}. It needs keys:write, so call it as a dashboard owner or admin or with an organization API key that has that scope. It answers 204 also when the key was already revoked. An ID that belongs to another application answers 404 not_found.
curl -X DELETE https://api.foxlogin.app/v1/applications/app_8f2c91a7/secret_keys/key_5d1e9a20 \
-H "Authorization: Bearer $FOXLOGIN_API_KEY"Organization API keys are revoked on the API access page in the sidebar.
If a key leaks
- Revoke the key right away. Each minute it stays active, whoever holds it can read your users.
- Create a replacement with the same role and deploy it to the services that used the old key.
- Look at the old key's Last used time. If it changed after the leak, someone else used the key.
- Remove the key from wherever it leaked: the git history, a log, a ticket or a chat message.
Security checklist
- Keep secret keys and organization keys on servers. Frontend code, mobile apps, desktop apps and browser extensions ship to users, and anyone can read a key inside them.
- Load keys from environment variables or a secret manager. Keep
.envfiles out of git and out of container images. - Send keys only in the
Authorizationheader. Do not put them in URLs, logs or error reports. - Give each service its own secret key with the smallest role it needs.
- Use an organization key only for work across applications or for creating applications.
- Give
keys:writeonly to the organization key of the tool that manages keys. - Revoke keys you no longer use. The Last used column shows which ones those are.
- The publishable key is public by design. It cannot read users or change settings.