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
idintegerrequiredAPI 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
newKeyobjectShow child attributes
createdAtstringdate-timeenvironmentstringidintegerkeystringkeyPreviewstringnamestringscopesarray<string>scopesSummarystringwarningstringoldKeyobjectShow child attributes
graceExpiresAtstringdate-timeidintegerkeyPreviewstringmessagestringError codes
400Invalid key ID.
404API key not found.
409Key is already revoked or already being rotated.