Rotate API key
POST
https://app.speybooks.com/api/v1/api-keys/{id}/rotateReplace 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 requiredAPI 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 objectShow child attributes
createdAt string date-timeenvironment stringid integerkey stringkeyPreview stringname stringscopes array<string>scopesSummary stringwarning stringoldKey objectShow child attributes
graceExpiresAt string date-timeid integerkeyPreview stringmessage stringError codes
400 Invalid key ID.
404 API key not found.
409 Key is already revoked or already being rotated.