import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.api_keys.revoke(
"key_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.revoke_api_key(
"key_01JZX8K3M9Q4P7VN2YB6RTDC0E",
)
print(result)curl -X DELETE 'https://api.mails.ai/v1/api-keys/key_01JZX8K3M9Q4P7VN2YB6RTDC0E' \
-H "Authorization: Bearer $MAILS_API_KEY"mails api-keys revoke key_01JABC --yes{
"name": "mails_api_keys_revoke",
"arguments": {
"key_id": "key_01JZX8K3M9Q4P7VN2YB6RTDC0E"
}
}{
"id": "key_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"revoked_at": "2026-10-04T12:00:00.000Z"
}200 The revoked key.
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
404 Resource not found in this workspace, or the agent
a send names is archived (agent_archived).
500 Internal server error.Revoke an API key
Revokes a key immediately.
import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.api_keys.revoke(
"key_01JZX8K3M9Q4P7VN2YB6RTDC0E",
);
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.revoke_api_key(
"key_01JZX8K3M9Q4P7VN2YB6RTDC0E",
)
print(result)curl -X DELETE 'https://api.mails.ai/v1/api-keys/key_01JZX8K3M9Q4P7VN2YB6RTDC0E' \
-H "Authorization: Bearer $MAILS_API_KEY"mails api-keys revoke key_01JABC --yes{
"name": "mails_api_keys_revoke",
"arguments": {
"key_id": "key_01JZX8K3M9Q4P7VN2YB6RTDC0E"
}
}{
"id": "key_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"revoked_at": "2026-10-04T12:00:00.000Z"
}200 The revoked key.
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
404 Resource not found in this workspace, or the agent
a send names is archived (agent_archived).
500 Internal server error.Path Parameters
idstringrequired
API key id.
Idempotent — revoking an already-revoked key returns its existing revoked_at. A test key cannot revoke a live key (403 live_mode_required): revoke it with a live key or in the dashboard.
Response
idstring
Id of the revoked key (key_…): the id in the path.
revoked_atstring
When the key was revoked; for a key already revoked, the original time.
Was this page helpful?