curl --request PATCH \
--url https://api.tryhamsa.com/v1/projects/api-keys \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"apiKeyId": "key_9f2c4e1a7b3d5f6081a2c3d4e5f60718",
"name": "Call center server"
}
'{
"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": 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"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}API Keys
Update API Key
Changes the name, allowed domains or agents of one of your keys. Send only what changes. What a key can do (type, scopes, kind and environment) is set when it is created and can’t be changed: an edit that changes any of them is refused with 400 ApiKeyAccessNotEditable, params.fields naming them, and nothing is saved. To give different access, create a new key and revoke this one. The project’s Default key cannot be updated, and expired keys cannot be changed.
PATCH
/
v1
/
projects
/
api-keys
curl --request PATCH \
--url https://api.tryhamsa.com/v1/projects/api-keys \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"apiKeyId": "key_9f2c4e1a7b3d5f6081a2c3d4e5f60718",
"name": "Call center server"
}
'{
"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": 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"
}
}{
"code": 5409,
"message": "This API key was already revoked.",
"messageKey": "ApiKeyAlreadyRevoked",
"params": {
"action": "api_keys:revoke"
}
}Authorizations
Query Parameters
Body
application/json
Hostnames the key may be used from, such as example.com or *.example.com (any subdomain). No protocol, at most 255 characters each. Empty: any domain. A public key checks them against the Origin header. Replaces the saved list; [] removes the limit.
Required string length:
1 - 255Example:
["example.com"]
Was this page helpful?