curl --request DELETE \
--url https://api.example.com/api/agents/{agent_id}/api-key \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/api/agents/{agent_id}/api-key"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.example.com/api/agents/{agent_id}/api-key', 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.example.com/api/agents/{agent_id}/api-key",
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: Bearer <token>"
],
]);
$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.example.com/api/agents/{agent_id}/api-key"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.example.com/api/agents/{agent_id}/api-key")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/agents/{agent_id}/api-key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"revoked": true,
"revoked_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Revoke Agent Api Key
Soft-revoke the agent’s active API key.
Idempotent: calling DELETE on an agent with no active key still
returns HTTP 200 with revoked=false. This lets clients call
DELETE blindly without first getting it to check existence.
Args: agent_id: Path parameter. current_user: Resolved from JWT. db: SQLAlchemy session.
Returns:
:class:APIKeyRevokeResponse with:
revoked=true, revoked_at=<now>if an active key was just revoked.revoked=false, revoked_at=nullif no active key existed.
Raises: HTTPException 401: missing or invalid JWT. HTTPException 404: agent missing / not owned.
Notes:
Revoked rows stay in the table forever (we only flip revoked_at).
The audit trail of “when was a key created and when was it
revoked” is the entire point of soft-delete here; hard-deleting
would also lose the ability to answer “is this old hash one
we issued?” during incident response.
curl --request DELETE \
--url https://api.example.com/api/agents/{agent_id}/api-key \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/api/agents/{agent_id}/api-key"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.example.com/api/agents/{agent_id}/api-key', 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.example.com/api/agents/{agent_id}/api-key",
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: Bearer <token>"
],
]);
$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.example.com/api/agents/{agent_id}/api-key"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.example.com/api/agents/{agent_id}/api-key")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/agents/{agent_id}/api-key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"revoked": true,
"revoked_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Response
Successful Response
Response model for DELETE /api/agents/{agent_id}/api-key.
The endpoint is idempotent and always returns HTTP 200 when the
caller owns the agent. revoked distinguishes the two cases:
True: there was an active key and this call flipped itsrevoked_atto now.False: no active key existed; the call was a safe no-op.revoked_atisNonein this case.

