Rotate API key

POSThttps://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

idintegerrequired
API key ID to rotate.

Response

201New key created. Old key enters a 24-hour grace period where both keys work. The new full key is returned ONCE.
Show response fields
newKeyobject
Show child attributes
createdAtstringdate-time
environmentstring
idinteger
keystring
keyPreviewstring
namestring
scopesarray<string>
scopesSummarystring
warningstring
oldKeyobject
Show child attributes
graceExpiresAtstringdate-time
idinteger
keyPreviewstring
messagestring

Error codes

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