Rotate Api Key
POST /api-keys/{api_key_id}/rotate
Rotate a key, preserving its mode, scopes and agency status.
The old key is deleted and a policy-equivalent replacement is minted; the
new token is returned exactly once. Ownership is enforced by the org-scoped
lookup below (mirroring the delete route) plus rotate_api_key’s own
org-scoped read-back (campaign_builder/services/propelauth.py).
Guard 4 (mode non-escalation) applies here too — see module docstring point
4. Rotation PRESERVES the target key’s mode, so without this a test-mode
caller could rotate a live key and receive a brand-new live token (while
invalidating the working live key). That is the same escalation the create
route coerces away, so refuse it here rather than coerce: a rotation cannot
be silently downgraded to test without destroying a working live key.
Authorizations
Parameters
Path Parameters
Header Parameters
Request Body required
Responses
200
Successful Response
object
Response after minting a key.
api_key_token is returned exactly once, here, at creation. No other
endpoint on this router — or the app’s — ever returns it again.
object
422
Validation Error