# Revoke the key

> Revoke a private-key principal's key at once, so it obtains no more access tokens.

> Nevia is in beta and open to selected teams. Public launch in Dec 2026. The CLI installs with `curl -fsSL https://get.nevia.cloud | sh`, and the MCP server is at https://api.nevia.cloud/mcp. A person signs in once in the browser.
> Setup, sign-in and requesting access: [SKILL.md](https://nevia.cloud/SKILL.md). When Nevia fits and when it doesn't: [why.md](https://nevia.cloud/why.md).

> For the complete documentation index, see [llms.txt](https://nevia.cloud/llms.txt). This page's HTML version: https://nevia.cloud/docs/reference/api/access/revokeKey

`DELETE https://api.nevia.cloud/v1/workspaces/{ws}/access/{principal}/key`

## Authorization

- `bearerAuth`: HTTP bearer in the Authorization header

Send the token in the `Authorization: Bearer <token>` header. See [Authenticate](https://nevia.cloud/docs/reference/api.md#authenticate).

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `ws` | path | string | yes | Workspace id: 27 lowercase letters and digits. Match `^[A-Za-z0-9_-]{1,64}$`. |
| `principal` | path | string | yes | Principal id: 27 lowercase letters and digits. Match `^[A-Za-z0-9_-]{1,64}$`. |
| `Idempotency-Key` | header | string | no | Optional retry key, kept 24 hours. Length `1 <= length <= 255`. |

## Behavior

The key is addressed through the principal, so no key id is needed. Every access token the principal holds at this moment is refused on its next request with `401 token_revoked`. An expired key is revoked the same way, since the tokens it minted may still be in use. The principal keeps its access, and its `key_state` reads `revoked` until the next rotation. Revoking an already revoked key returns it again.

## Example request

### cURL

```bash
curl -X DELETE "https://api.nevia.cloud/v1/workspaces/01d4cnjjq40hnnh0nwmkg35nv2h/access/01d4cnjmn4fbb1r5btxb5mypv62/key" \
  -H "Authorization: Bearer $TOKEN"
```

### JavaScript

```js
fetch("https://api.nevia.cloud/v1/workspaces/01d4cnjjq40hnnh0nwmkg35nv2h/access/01d4cnjmn4fbb1r5btxb5mypv62/key", {
  method: "DELETE",
  headers: {
    "Authorization": `Bearer ${process.env.TOKEN}`
  }
})
```

### Python

```python
import os
import requests

url = "https://api.nevia.cloud/v1/workspaces/01d4cnjjq40hnnh0nwmkg35nv2h/access/01d4cnjmn4fbb1r5btxb5mypv62/key"

response = requests.request("DELETE", url, headers = {
  "Authorization": f"Bearer {os.environ['TOKEN']}"
})

print(response.text)
```

## Responses

### 200

The revoked key, as it stands after revocation.

Content type: `application/json`

Schema: `KeyResponse`

| Field | Type | Required | Description |
|---|---|---|---|
| `key` | AccessKey | yes | Key of a private-key principal. |
| `operations` | array<OperationId> | yes | Operations this request started. |

Example:

```json
{
  "key": {
    "id": "01d4cnjq8r0tvwxyb3c4d5f6g7h",
    "principal": "01d4cnjmn4fbb1r5btxb5mypv62",
    "byok": true,
    "created_by": "01d4cnjmn4fbb1r5btxb5mypv62",
    "expires_at": "2026-09-10T12:34:56Z",
    "last_used_at": "2026-09-10T12:34:56Z",
    "created_at": "2026-09-10T12:34:56Z",
    "revoked_at": "2026-09-10T12:34:56Z"
  },
  "operations": [
    "01d4cnjm89yk0r3xtv80dy0x7by"
  ]
}
```

### 400

`validation_failed`: malformed body, unknown field, or invalid id or name. Fix `details.field` and retry.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `validation_failed`:

```json
{
  "error": {
    "code": "validation_failed",
    "message": "Unknown field `colour` in the request body. Remove it; request bodies are strict.",
    "details": {
      "field": "colour",
      "in": "body"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 401

`unauthorized`: the credential is missing, malformed, expired, or revoked. Send a valid bearer token.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `unauthorized`:

```json
{
  "error": {
    "code": "unauthorized",
    "message": "Missing credential. Send `Authorization: Bearer <token>` with an access token.",
    "details": {},
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 403

`forbidden`: the token is read-only or scoped elsewhere, or the role cannot do this. Use a token or role that allows it.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `forbidden`:

```json
{
  "error": {
    "code": "forbidden",
    "message": "You can view computer 01d4cnjk3xg90y576w8y6t4gdwm but your role does not allow computer#edit. Ask a workspace admin to change your role (PATCH /v1/workspaces/{ws}/access/{principal}).",
    "details": {
      "computer": "01d4cnjk3xg90y576w8y6t4gdwm",
      "permission": "computer#edit"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 404

`not_found`: the workspace does not exist, or you cannot see it. Both return the same response. `not_found`: the principal has no access to this workspace, or its account was deleted. `not_found`: the principal never had a key.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `not_found: the workspace does not exist, or you cannot see it. Both return the same response`:

```json
{
  "error": {
    "code": "not_found",
    "message": "Workspace 01d4cnjjq40hnnh0nwmkg35nv2h was not found. List the workspaces you can access with GET /v1/workspaces.",
    "details": {
      "workspace": "01d4cnjjq40hnnh0nwmkg35nv2h"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

Example `not_found: the principal has no access to this workspace, or its account was deleted`:

```json
{
  "error": {
    "code": "not_found",
    "message": "01d4cnjmn4fbb1r5btxb5mypv62 has no access to workspace 01d4cnjjq40hnnh0nwmkg35nv2h. List who has with GET /v1/workspaces/01d4cnjjq40hnnh0nwmkg35nv2h/access, or give it with POST /v1/workspaces/01d4cnjjq40hnnh0nwmkg35nv2h/access.",
    "details": {
      "workspace": "01d4cnjjq40hnnh0nwmkg35nv2h",
      "principal": "01d4cnjmn4fbb1r5btxb5mypv62"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

Example `not_found: the principal never had a key`:

```json
{
  "error": {
    "code": "not_found",
    "message": "01d4cnjmn4fbb1r5btxb5mypv62 has no key to revoke; none was ever issued. POST /v1/workspaces/{ws}/access/01d4cnjmn4fbb1r5btxb5mypv62/keys issues one.",
    "details": {
      "principal": "01d4cnjmn4fbb1r5btxb5mypv62"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 409

`invalid_state`: the key was rotated while it was being revoked. `details.key` is the key now live: retry to revoke it. `idempotency_conflict`: the `Idempotency-Key` was already used with a different body.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `invalid_state`:

```json
{
  "error": {
    "code": "invalid_state",
    "message": "01d4cnjmn4fbb1r5btxb5mypv62's key was rotated while it was being revoked, and key 01d4cnjq8r0tvwxyb3c4d5f6g7h is live now. Retry to revoke it.",
    "details": {
      "principal": "01d4cnjmn4fbb1r5btxb5mypv62",
      "key": "01d4cnjq8r0tvwxyb3c4d5f6g7h"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

Example `idempotency_conflict`:

```json
{
  "error": {
    "code": "idempotency_conflict",
    "message": "Idempotency-Key 8f1c2a7e-3b4d-4c5e-9f0a-1b2c3d4e5f60 was already used for a different DELETE /v1/workspaces/{ws}/access/{principal}/key request. Use a new key for a new request.",
    "details": {
      "idempotency_key": "8f1c2a7e-3b4d-4c5e-9f0a-1b2c3d4e5f60"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 422

`not_supported`: the principal signs in with a login, which has no keys.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `not_supported`:

```json
{
  "error": {
    "code": "not_supported",
    "message": "01d4cnjmn4fbb1r5btxb5mypv62 signs in with a login and has no keys. Keys belong to principals created with `auth: \"private_key\"`.",
    "details": {
      "principal": "01d4cnjmn4fbb1r5btxb5mypv62"
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 429

`rate_limited`: slow down. Retry after `Retry-After`.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `rate_limited`:

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests. Retry after 2 seconds.",
    "details": {
      "retry_after_seconds": 2
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 500

`request_failed`, or the failed action's own code, such as `creation_failed`, `authorization_failed` or `command_execution_failed`. Quote `request_id` when reporting. The diagnostic stays in server logs.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `request_failed`:

```json
{
  "error": {
    "code": "request_failed",
    "message": "request failed",
    "details": {},
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

### 503

`creation_failed`: The action is temporarily unavailable, named by its code (`creation_failed`, `wake_failed`, ...). Wait at least `Retry-After` seconds (60 by default). `details.retryable` says whether repeating the request is safe. Keep the original `Idempotency-Key`. Signing in again does not help. `deletion_failed`: the deployment has no identity provider for private keys. The live key is still live. Retry after an operator configures it. `deletion_failed`: the identity provider failed while revoking the key. The key stays live. Retry the request.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `creation_failed`:

```json
{
  "error": {
    "code": "creation_failed",
    "message": "The computer could not be created. Try again later, and quote request_id if it persists.",
    "details": {
      "retryable": true
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

Example `deletion_failed: the deployment has no identity provider for private keys. The live key is still live. Retry after an operator configures it`:

```json
{
  "error": {
    "code": "deletion_failed",
    "message": "Private-key access is not configured on this deployment. Quote request_id when reporting.",
    "details": {
      "reason": "not configured",
      "retryable": false
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```

Example `deletion_failed: the identity provider failed while revoking the key. The key stays live. Retry the request`:

```json
{
  "error": {
    "code": "deletion_failed",
    "message": "the principal could not be changed",
    "details": {
      "retryable": true
    },
    "request_id": "req_01j9k3m2p7q4r8s1"
  }
}
```
