Revoke a key and issue a replacement with the same name and scope.
POST/v1/projects/{projectId}/api-keys/{keyId}/rotateTry it
Session token
Revokes an existing key and issues a new one — with a new id — with the same name, scope, and expiry. The old key stops working immediately.
Note
Requires the admin or owner role. A member of the workspace gets 403 forbidden ("Only workspace admins can rotate API keys.") with details.requiredRole and details.currentRole. Any member can list keys.
Path Parameters
NameDescription
projectId:stringpathRequired
The project ID.
keyId:stringpathRequired
The ID of the key to rotate.
Response — 201 Created
last4 is the last four characters of the new key. Rotating a key that predates last4 gives the new key one.
Warning
Rotation is immediate — update the key everywhere it's used (CI secrets, environment variables) right away, since the old key is already revoked.
404 Not Found
Returned if the key doesn't exist, belongs to another project, or was already revoked — including by another rotation of the same key that finished first, so two rotations at once never leave two new keys.