# Revoke API key

Canonical URL: https://sosoapi.ai/docs/api/identity-api-api-keys-revoke

Contract: sha256:563d2d581da0ad29

Revoke an API key by id so it stops working immediately; an already-revoked key reports already_revoked. An agent can revoke only keys its own grant created. Needs the Manage API keys grant.

POST /identity-api/api-keys/revoke

## Authentication and permissions

- **Accepted credential classes:** user_session, delegated_oauth

- **Delegated capability:** agent:manage_api_keys

- **Minimum workspace role:** No workspace-role minimum in this contract; ownership and grant checks still apply.

- **Access scope:** Account-level authority

- **All-workspace consent required:** Yes

- **Changes state:** Yes

- **When the operation is complete:** synchronous_http_response

A token can use only the rights held by its owner. Each request checks workspace membership, resource ownership, selected workspaces and granted capabilities. Core and full profiles change which tools are displayed; they do not grant access.

## Request fields

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    }
  },
  "required": [
    "id"
  ],
  "additionalProperties": false
}
```

## Response and completion

Success HTTP statuses: 200

A successful HTTP response can mean that a request was accepted rather than completed. For background work, save the returned ID and check the same operation until it finishes. A scheduled or accepted post is published only when the platform confirms it; a client timeout does not establish the result.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "already_revoked": {
      "type": "boolean"
    }
  },
  "required": [
    "ok",
    "already_revoked"
  ]
}
```

## Errors and safe retries

Check the HTTP status and response body. A 400 validation error may contain a ZodError; handler errors use error, message and code fields. Keep request_id or x-request-id for diagnosis, without credentials. Fix 401/403 access errors before retrying, and follow Retry-After for 429. If a write is uncertain or returns 5xx, read the existing result first. Reuse an idempotency key only where supported; retry behaviour varies by operation and does not guarantee exactly-once delivery.

## Examples

These examples use fictional values checked against the schemas. Replace the IDs with ones you are authorized to use, the media with ready assets and the dates with your confirmed publishing time. Check the account’s eligibility before submitting a write. This page sends no API requests.

Set SOSOAPI_ACCESS_TOKEN on your server to a credential accepted by this operation, and keep it out of browser code. For an agent, use sosoapi auth login to sign in through the browser and let the CLI refresh its credentials.

request.json

```json
{
  "id": "11111111-1111-4111-8111-111111111111"
}
```

cURL

```bash
curl --request POST \
  "https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/api-keys/revoke" \
  -H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json
```

JavaScript

```js
// Server-side JavaScript. Do not print tokens or credential-bearing responses.
const token = process.env.SOSOAPI_ACCESS_TOKEN;
if (!token) throw new Error("Set an accepted credential for this operation");
const response = await fetch("https://gqeshlawtcexsapabaui.supabase.co/functions/v1/identity-api/api-keys/revoke", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
  body: JSON.stringify({
  "id": "11111111-1111-4111-8111-111111111111"
})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.
```

CLI

```bash
npx sosoapi api post /identity-api/api-keys/revoke < request.json
```

Synthetic response example

```json
{
  "ok": true,
  "already_revoked": false
}
```

## Related tools and guides

MCP: sosoapi_revoke_api_key

[API reference](https://sosoapi.ai/docs/api)
