Rotate an API key
Generates a replacement key and transitions the existing key into a grace period. The old key remains usable until its grace period expires, giving you time to deploy the new value before the old one stops working.
The new key’s full value is returned in this response and never again — store it immediately.
The grace period defaults to 24 hours. Set grace_period_hours to any
value between 1 and 168 (7 days). The grace period cannot extend past the
old key’s configured expiry time.
Authorizations
A merchant standard (sk_…) or restricted (rk_…) secret key sent as Authorization: Bearer <key>.
Path Parameters
The API key identifier (sk_… for secret keys, pk_… for publishable keys).
Body
All fields are optional.
How long the old key stays active after rotation, in hours. Must be between 1 and 168 (7 days). Defaults to 24. Cannot extend past the old key's existing expiry time.
1 <= x <= 168Response
The rotation result, including the new key's full value and the old key's expiry.
Returned when a key is created or rotated. Includes the full authenticatable
value (key), which is shown exactly once and is not stored by Ionic. Store
it immediately.
Identifier of the key that was rotated out.
Unix epoch seconds when the old key stops authenticating requests (end of the grace period).

