/Docs
Search docs or ask a question⌘K
DocsAgent
Changelog
API Reference Rotate API Key

Rotate API Key

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.

Was this page helpful? Yes No
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl -X POST https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/api-keys/key_789/rotate \
-H "Authorization: Bearer $SYNTEXT_JWT"
Responseapplication/json
201Created
{
"data": {
"id": "key_790",
"name": "CI deploy key",
"key": "stx_e5f6g7h8_newFullKeyShownOnlyOnce",
"prefix": "stx_e5f6g7h8",
"last4": "Once",
"scope": "build",
"expiresAt": "2026-10-01T10:00:00Z",
"createdAt": "2026-07-03T11:00:00Z",
"previousKeyId": "key_789"
}
}
Product
Resources
Company
© 2026 SyntextBuilt with Syntext