Skip to main content

Rotate Key

Generate a new key value while keeping the same key ID, name, and scopes. The old key value is invalidated immediately.

POST /api/v1/api-keys/:keyId/rotate

Authentication

JWT Bearer Token required via Authorization header.

Path Parameters

ParameterTypeDescription
keyIdstringThe key ID (e.g., key_abc123)

Response

200 OK

{
"id": "key_abc123",
"name": "Production Server",
"key": "as_live_sk_newkey123abc456",
"scopes": ["splits:read", "splits:write"],
"rotatedAt": "2026-03-29T10:00:00Z",
"createdAt": "2026-01-15T10:00:00Z"
}
caution

The new key value is only returned once. Store it securely before closing this response.

404 Not Found

{
"error": {
"code": "NOT_FOUND",
"message": "API key not found",
"status": 404
}
}

Code Examples

cURL

curl -X POST https://api.audiospliter.com/api/v1/api-keys/key_abc123/rotate \
-H "Authorization: Bearer your_jwt_token"

Node.js

const response = await fetch(
'https://api.audiospliter.com/api/v1/api-keys/key_abc123/rotate',
{
method: 'POST',
headers: { 'Authorization': `Bearer ${jwtToken}` },
}
);
const { key } = await response.json();
// Update your environment with the new key value
console.log('New key generated - update your config');

Python

import requests

response = requests.post(
'https://api.audiospliter.com/api/v1/api-keys/key_abc123/rotate',
headers={'Authorization': f'Bearer {jwt_token}'},
)
new_key = response.json()['key']
# Update your environment with the new key value
print('New key generated - update your config')