Secret keys
A secret key is a project’s server credential: sk_test_… in dev and sk_live_… in prd. It reaches every service the project adopted, in the key’s environment, and with it the server mints user tokens. Only a dev key reads the test inbox.
Agentpost shows a secret key once and keeps only its hash, so a list of keys tells them apart by prefix. Keep it on the server, such as in an environment variable; never send it to a browser or put it in an app. A browser or a native app starts a sign-in with a publishable key instead.
Status
A secret key’s status is active until you rotate or revoke it. A key works while its status is active or grace.
- Rotated: a new key with the same name and environment replaces it. The request must send
grace, a duration string from"0s"to"7d". A grace of"0s"stops the old key at once and requiresconfirmset to the key’s name. The old key isgraceuntilgraceEndsAt, thenexpired. User tokens it minted keep working until their ownexpiresAt. Rotating a key that already has a replacement, even during its grace, or that was revoked or has expired answersconflict. - Revoked: it stops at once, with every user token it minted, and can’t be undone.
A request with a stopped key answers unauthenticated. A live event tail the key already opened stops within 30 seconds, whether the key was revoked or its grace ended.
Where to act on it
- Create a project and issue a key issues one in each environment.
- Rotate a secret key replaces one without downtime, and stops a leaked one at once.
- Revoke a key stops one that nothing uses.
- The keys reference has every field.
- Workspaces explains which key changes email the owners.