---
title: "Secret keys"
description: "Learn what a project's secret key reaches, how to keep it, and how long it works after a rotation, before you issue, rotate, or revoke one."
url: "https://agentpost.tools/docs/platform/concepts/secret-keys"
kind: concept
---

# 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](/docs/platform/concepts/environments.md), and with it the server mints [user tokens](/docs/platform/concepts/user-tokens.md). Only a `dev` key reads the [test inbox](/docs/platform/concepts/environments.md#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](/docs/platform/concepts/publishable-keys.md) 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 requires `confirm` set to the key’s name. The old key is `grace` until `graceEndsAt`, then `expired`. User tokens it minted keep working until their own `expiresAt`. Rotating a key that already has a replacement, even during its grace, or that was revoked or has expired answers [`conflict`](/docs/errors.md#conflict).
-   **Revoked:** it stops at once, with every user token it minted, and can’t be undone.

A request with a stopped key answers [`unauthenticated`](/docs/errors.md#unauthenticated). A live event tail the key already opened [stops within 30 seconds](/docs/platform/concepts/credentials.md#open-streams), whether the key was revoked or its grace ended.

## Where to act on it

-   [Create a project and issue a key](/docs/platform/guides/keys.md) issues one in each environment.
-   [Rotate a secret key](/docs/platform/guides/rotate-keys.md) replaces one without downtime, and stops a leaked one at once.
-   [Revoke a key](/docs/platform/reference/keys.md#revoke-a-key) stops one that nothing uses.
-   The [keys reference](/docs/platform/reference/keys.md) has every field.
-   [Workspaces](/docs/platform/concepts/workspaces.md) explains which key changes email the owners.
