curl --request POST \
--url https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/rotate \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"overlap": "7d"
}
'{
"success": true,
"message": "success",
"data": {
"id": "3f6c1a2e-8b4d-4e9a-9c1f-2a7d5e8b0c34",
"name": "Backend server",
"kind": "SECRET",
"type": "SCOPED",
"scopes": [
"agents:read",
"agents:call",
"phone_numbers:read",
"phone_numbers:update",
"call_history:read",
"call_history:monitor"
],
"allowedDomains": [
"example.com"
],
"environment": null,
"publicValue": "pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"secretLast4": "xxxx",
"agentIds": [
"8a1d2c3b-4e5f-4a6b-9c7d-0e1f2a3b4c5d"
],
"expiredAt": "2027-12-31T23:59:59.999Z",
"previousValidUntil": null,
"lastUsedAt": "2026-11-03T09:15:00.000Z",
"previousLastUsedAt": null,
"ref": "key_9f2c4e1a7b3d5f6081a2c3d4e5f60718",
"isDefault": false,
"createdAt": "2026-11-03T09:15:00.000Z",
"updatedAt": "2026-11-03T09:15:00.000Z",
"status": "VALID",
"isValid": true,
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"secret": "sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}API Keys
Rotate API Key
Gives one of your public or secret keys a new value. The key keeps its ID, scopes, domains and agents. The old value keeps working for the overlap you choose, so you can update your apps first; now stops it at once (use it after a leak). Rotating again during an overlap stops the older value at once. A new secret value is in secret in this response only. Legacy keys cannot be rotated: create a secret or public key instead.
POST
/
v1
/
projects
/
api-keys
/
{apiKeyId}
/
rotate
curl --request POST \
--url https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/rotate \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"overlap": "7d"
}
'{
"success": true,
"message": "success",
"data": {
"id": "3f6c1a2e-8b4d-4e9a-9c1f-2a7d5e8b0c34",
"name": "Backend server",
"kind": "SECRET",
"type": "SCOPED",
"scopes": [
"agents:read",
"agents:call",
"phone_numbers:read",
"phone_numbers:update",
"call_history:read",
"call_history:monitor"
],
"allowedDomains": [
"example.com"
],
"environment": null,
"publicValue": "pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"secretLast4": "xxxx",
"agentIds": [
"8a1d2c3b-4e5f-4a6b-9c7d-0e1f2a3b4c5d"
],
"expiredAt": "2027-12-31T23:59:59.999Z",
"previousValidUntil": null,
"lastUsedAt": "2026-11-03T09:15:00.000Z",
"previousLastUsedAt": null,
"ref": "key_9f2c4e1a7b3d5f6081a2c3d4e5f60718",
"isDefault": false,
"createdAt": "2026-11-03T09:15:00.000Z",
"updatedAt": "2026-11-03T09:15:00.000Z",
"status": "VALID",
"isValid": true,
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"secret": "sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}Authorizations
Path Parameters
Query Parameters
Body
application/json
Was this page helpful?