# `token.revoke`

<span class="badge">bearer</span>

**Revoke a personal access token**

Permanently revokes one PAT by id. Revoking a token does not affect the caller's other tokens or password sessions. JWT session only.

## Parameters

Passed by name in the `params` object.

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | UUID of the token to revoke |

## Result

Returns an empty object `{}` on success.

## Errors

| Code | Message | When |
|---|---|---|
| `2002` | `validation_failed` | Malformed request; see error.data. |
| `2001` | `not_found` | No such resource owned by the caller. |

See the [error reference](/docs/errors) for the full catalog, including the authentication codes.

## Example

Request:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "token.revoke",
  "params": {
    "id": "018f3a8e-3c9d-7a2b-b5e6-7f8a9b0c1d2e"
  }
}
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {}
}
```

**curl**

```bash
curl -s https://peinture.gumeniuk.com/rpc \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"token.revoke","params":{"id":"018f3a8e-3c9d-7a2b-b5e6-7f8a9b0c1d2e"}}'
```

**JavaScript**

```js
const res = await fetch("https://peinture.gumeniuk.com/rpc", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${token}`,
  },
  body: JSON.stringify({
    jsonrpc: "2.0", id: 1, method: "token.revoke", params: {"id":"018f3a8e-3c9d-7a2b-b5e6-7f8a9b0c1d2e"},
  }),
});
const { result, error } = await res.json();
```

**Go**

```go
body := []byte(`{"jsonrpc":"2.0","id":1,"method":"token.revoke","params":{"id":"018f3a8e-3c9d-7a2b-b5e6-7f8a9b0c1d2e"}}`)
req, _ := http.NewRequest("POST", "https://peinture.gumeniuk.com/rpc", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
```

