# Revoke devices

URL: https://docs.hanzo.ai/docs/openapi/link/post-link-devices-by-machine-revoke

> Logs out every account on one machine and stops its sessions.

`POST /v1/link/devices/{machine}/revoke`

> [Link →](https://docs.hanzo.ai/docs/openapi/link) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                         |
| ------------- | ------------------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/link/devices/{machine}/revoke` |
| **Method**    | `POST`                                                  |
| **Operation** | `post_link_devices_by_machine_revoke`                   |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`                  |

Logs out every account on one machine and stops its sessions.

It revokes every one of the caller's accounts on one machine and stops the
agent sessions they were running, answering with how many of each. This is the
"I lost that laptop" button. Revoked links are RETAINED, not deleted, so usage
history and the audit trail survive a log-out — the rows come back in the
response with their new status. The session stop reaches only the REVOKING
user's own sessions, so a shared machine name can never be used to stop a
co-tenant's work, and a stop that fails does not fail the revoke: the revoked
row is the durable truth and the count then honestly reports fewer. A machine
with nothing left to revoke is 404.

## Request

1 field.

| Field     | In   | Type   | Required | Description                                      |
| --------- | ---- | ------ | -------- | ------------------------------------------------ |
| `machine` | path | string | yes      | Machine is the machine to act on, from the path. |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | link.revokeResp | ok      |
| `default` | problem-details | refused |

`200` body — 18 fields.

| Field               | In   | Type             | Always | Description                                                                                                                                          |
| ------------------- | ---- | ---------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `links`             | body | link.linkView\[] | —      | Links is each revoked row with its new status — retained, not deleted, so usage history and the audit trail survive the log-out.                     |
| `links[].account`   | body | string           | —      | Account is the provider-side account identifier, when the collector knows it.                                                                        |
| `links[].billing`   | body | string           | —      | Billing is how this account's inference bills — plan (the user's own subscription, metered here for visibility only) or commerce (the gateway path). |
| `links[].createdAt` | body | string           | —      | CreatedAt is when the link was first registered, RFC 3339 UTC.                                                                                       |
| `links[].host`      | body | string           | —      | Host is the machine's human hostname label, from its most recent report.                                                                             |
| `links[].id`        | body | string           | —      | ID is the link's opaque handle ("link\_" + 32 hex chars).                                                                                            |
| `links[].kind`      | body | string           | —      | Kind is how the account authenticates: subscription or apikey.                                                                                       |
| `links[].lastSeen`  | body | string           | —      | LastSeen is when the account last reported, RFC 3339 UTC.                                                                                            |
| `links[].machine`   | body | string           | —      | Machine is the stable machine identifier the collector reports.                                                                                      |
| `links[].os`        | body | string           | —      | OS is the machine's operating system label.                                                                                                          |
| `links[].plan`      | body | string           | —      | Plan is the provider plan label (e.g. "Claude Max").                                                                                                 |
| `links[].provider`  | body | string           | —      | Provider is the AI provider this account belongs to (claude, openai, hanzo…).                                                                        |
| `links[].status`    | body | string           | —      | Status is linked or revoked.                                                                                                                         |
| `links[].updatedAt` | body | string           | —      | UpdatedAt is when the link was last refreshed, RFC 3339 UTC.                                                                                         |
| `links[].usage`     | body | any              | —      | Usage is the last good usage snapshot, clamped and re-serialized to known fields at ingest.                                                          |
| `links[].user`      | body | string           | —      | User is the owning subject — the validated caller who registered the link.                                                                           |
| `revoked`           | body | integer (int64)  | —      | Revoked is how many links this call revoked.                                                                                                         |
| `sessionsStopped`   | body | integer (int64)  | —      | SessionsStopped is how many of the caller's own agent sessions stopped.                                                                              |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo auth link devices revoke <machine>
```

**SDK**

**.ts**

```ts
import { Configuration, LinkApi } from 'hanzoai';

const api = new LinkApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postLinkDevicesByMachineRevoke({ machine: 'machine' });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import LinkApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = LinkApi(client).post_link_devices_by_machine_revoke(machine='machine')
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.LinkAPI.PostLinkDevicesByMachineRevoke(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, link_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = link_api::post_link_devices_by_machine_revoke(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.LinkApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new LinkApi(client).postLinkDevicesByMachineRevoke();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/link/devices/<machine>/revoke \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **link** through the `link` tool, which names its 11 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_links"
         }
       }
     }'
```

---

[Link API](https://docs.hanzo.ai/docs/openapi/link) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
