Rotate an API key
const url = 'https://api.emite.cr/v1/auth/api-keys/example/rotate';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"revokeImmediately":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.emite.cr/v1/auth/api-keys/example/rotate \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "revokeImmediately": false }'Creates a new key inheriting name, scopes, and expiresAt from the source key, then revokes the old one. By default the old key gets a 5-minute grace period during which both keys are accepted — enough time to update a deployed service. Pass revokeImmediately: true when responding to a suspected compromise.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”ApiKey UUID to rotate.
Request Body
Section titled “Request Body”object
Revoke the old key immediately. Default false gives a 5-minute grace period — set true when rotating due to suspected compromise.
Responses
Section titled “Responses”CreatedApiKeyResponseDto for the NEW key (with plaintext rawKey).
object
Identifier of the key — also the middle segment of the raw key (<prefix>_<id>_<secret>). Use it to rotate or revoke the key.
The label given at creation, kept by a rotation. Unique among the active keys of the environment: a revoked key frees its name.
Prefix segment of the raw key. ec_test_* for sandbox keys, ec_live_* for production keys (Stripe-style). The secret segment is never returned after creation (the middle segment is the key's id).
Environment the key is bound to. A sandbox key authenticates against sandbox data only; a production key against production data only. Immutable after creation — to switch environments, create a new key.
Last 4 chars of the key id. Useful for visual reconciliation in the UI and in audit logs ("the key ending in …a3b4"). NEVER exposes secret bytes.
The scopes stored on the key, as chosen at creation (a rotation keeps them). * grants every scope an API key may hold — never the session-only ones (members, API keys, billing, credentials, ownership).
Derived, never stored: revoked once revokedAt has passed (it wins over an expiry), expired once expiresAt has passed, otherwise active — also during the grace window of a rotation, while revokedAt is still in the future.
When the key was created (a rotation creates a new key).
Last verified use (best-effort, populated on guard verify).
When the key stops authenticating on its own, as set at creation (a rotation keeps it). null = it never expires.
When the key was revoked; null if it never was. A rotation sets it in the future — the grace window — and the old key keeps working until then.
Display name of the user who created the key. null if the user was deleted.
User who created the key.
Plaintext API key. Returned once only. Use as the x-api-key header value. Cannot be recovered after this response.
Example
{ "environment": "sandbox", "status": "active", "rawKey": "ec_test_01a00c73-5c07-7bb5-8b9e-d20f16537e42_aBcDeF..."}Missing or invalid JWT.
API key management requires a JWT session — API keys cannot mint other keys.
Source key not found or already revoked.