> For a complete page index of the Captain API documentation, fetch https://docs.captain.dev/llms.txt?excludeSpec=true

# Revoke Key

DELETE https://acme.captain.dev/v1/keys/{key_id}

Revoke a key at once, with every key it created. Takes a write key for every index. A key can't revoke itself (409 KEY_IS_CALLER).

Reference: https://docs.captain.dev/reference/product-search/keys/revoke-key

## Authentication

- `Authorization` header (bearer token, required) — A write key, issued by Captain. Server side only. Sent as Authorization: Bearer \<key>.

## Request

### Path parameters

- `key_id` (string, required)

### Query parameters

- `cascade` (enum, optional, default: created) — created (default): also revoke every key this key created, and the keys those created, recursively. none: revoke only this key
  - Allowed values: `created`, `none`

### Headers

- `Idempotency-Key` (string, optional) — Replays within 24 hours return the stored response (header Idempotent-Replayed: true). The same key on a different request answers 422. A concurrent duplicate answers 409. Failed requests do not keep the key.

## Response

### 200

revoked

## Examples

**Response**

```json
{
  "deleted": "key_8a1f3c0d9e2b4f67",
  "revoked": [
    "key_8a1f3c0d9e2b4f67"
  ]
}
```

**SDK Code**

```python Python REST
import json
import requests
import uuid

BASE_URL = "https://acme.captain.dev"
API_KEY = "your_write_key"
KEY_ID = "key_8a1f3c0d9e2b4f67"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Idempotency-Key": str(uuid.uuid4()),
}

response = requests.delete(
    f"{BASE_URL}/v1/keys/{KEY_ID}",
    headers=headers,
    timeout=30.0,
)

print(json.dumps(response.json(), indent=2))
```

```typescript TypeScript REST
const BASE_URL = "https://acme.captain.dev";
const API_KEY = "your_write_key";
const keyId = "key_8a1f3c0d9e2b4f67";

const response = await fetch(`${BASE_URL}/v1/keys/${keyId}`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
  },
});

const result = await response.json();
console.log(JSON.stringify(result, null, 2));
```