Stop the old value of a rotated key
curl --request DELETE \
--url https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous \
--header 'Authorization: <api-key>'import requests
url = "https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous"
headers = {"Authorization": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<api-key>'}};
fetch('https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"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
Stop Previous API Key Value
Ends a rotation’s overlap early: the old value of one of your public or secret keys stops working now. Use it once your apps use the new value, or when the old value leaked. Nothing changes when no old value is still working.
DELETE
/
v1
/
projects
/
api-keys
/
{apiKeyId}
/
previous
Stop the old value of a rotated key
curl --request DELETE \
--url https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous \
--header 'Authorization: <api-key>'import requests
url = "https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous"
headers = {"Authorization": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<api-key>'}};
fetch('https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tryhamsa.com/v1/projects/api-keys/{apiKeyId}/previous")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"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
Was this page helpful?