Rotate API key

POST https://app.speybooks.com/api/v1/api-keys/{id}/rotate

Replace an API key with a new one. The old key enters a 24-hour grace period during which both old and new keys authenticate successfully. After the grace period, the old key stops working.

The new key inherits the name and scopes of the old key. The full plaintext of the new key is returned exactly once — the response includes the complete key metadata (environment, scopes, scopesSummary, createdAt).

Revoked keys and keys already being rotated return 409 Conflict.

Path parameters

id integer required
API key ID to rotate.

Response

201 New key created. Old key enters a 24-hour grace period where both keys work. The new full key is returned ONCE.
Show response fields
newKey object
Show child attributes
createdAt string date-time
environment string
id integer
key string
keyPreview string
name string
scopes array<string>
scopesSummary string
warning string
oldKey object
Show child attributes
graceExpiresAt string date-time
id integer
keyPreview string
message string

Error codes

400 Invalid key ID.
404 API key not found.
409 Key is already revoked or already being rotated.