# Revoke an API key.

> Session only.
> https://koi.dog/docs/api/api-keys/revoke-api-key/

`POST /api/v1/api-keys/{id}/revoke` · Key: `session only`

Takes effect at once and cannot be undone. To call it outside the dashboard, send the dashboard's `koidog_session` cookie and `Origin: https://app.koi.dog`. No query parameters, and no body.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The API key's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Makes a retry safe: the same key with the same request returns the first answer and does nothing else. |

## Response.

200 OK: a `ApiKey`. The example has placeholder values.

## Request.

```sh
# The dashboard session only: an API key is refused (403 session_required).
curl -X POST "https://app.koi.dog/api/v1/api-keys/$ID/revoke" \
    -H "Cookie: koidog_session=$KOIDOG_SESSION" \
    -H "Origin: https://app.koi.dog" \
    -H "Idempotency-Key: $(uuidgen)"
```

```js
// The dashboard session only: an API key is refused (403 session_required).
const res = await fetch(`https://app.koi.dog/api/v1/api-keys/${process.env.ID}/revoke`, {
  method: "POST",
  headers: {
    Cookie: `koidog_session=${process.env.KOIDOG_SESSION}`,
    Origin: "https://app.koi.dog",
    "Idempotency-Key": crypto.randomUUID(),
  },
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

# The dashboard session only: an API key is refused (403 session_required).
r = requests.post(
    f"https://app.koi.dog/api/v1/api-keys/{os.environ['ID']}/revoke",
    headers={
        "Cookie": f"koidog_session={os.environ['KOIDOG_SESSION']}",
        "Origin": "https://app.koi.dog",
        "Idempotency-Key": str(uuid.uuid4()),
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "name": "string",
  "prefix": "string",
  "scopes": [],
  "rateLimitPerMinute": 0,
  "state": "active",
  "createdAt": "string",
  "lastUsedAt": "string",
  "expiresAt": "string",
  "revokedAt": "string"
}
```
