# Link

URL: https://docs.hanzo.ai/docs/openapi/link

> The unified AI login manager's registry: the org+user-scoped record of WHICH provider accounts (Claude Max, ChatGPT Plus, a Hanzo API key, a raw provider key) a developer has signed into, ON WHICH MACHINES, with each account's latest usage snapshot.

Also for this capability: **API** · [CLI](https://docs.hanzo.ai/docs/cli/link) · [MCP](https://docs.hanzo.ai/docs/mcp-tools/link) · [SDKs](https://docs.hanzo.ai/docs/sdks)

The unified AI login manager's registry: the org+user-scoped record of WHICH provider accounts (Claude Max, ChatGPT Plus, a Hanzo API key, a raw provider key) a developer has signed into, ON WHICH MACHINES, with each account's latest usage snapshot.

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

|                |                                        |
| -------------- | -------------------------------------- |
| **Base URL**   | `https://api.hanzo.ai`                 |
| **Operations** | 11                                     |
| **Auth**       | `Authorization: Bearer $HANZO_API_KEY` |

## Specification

Specification pending — no HIP in [hanzoai/hips](https://github.com/hanzoai/hips) declares `capability: link` yet. What this capability serves is below, from the API document; what it is — the store it owns, how it meters, what it publishes — is written as a HIP under HIP-0139.

## Four surfaces

| Surface  | Reaches this capability as                   | Coverage                                                                   |
| -------- | -------------------------------------------- | -------------------------------------------------------------------------- |
| **REST** | `link` at its own prefix                     | 11 operations                                                              |
| **CLI**  | `hanzo auth …`                               | 11 of 11                                                                   |
| **SDK**  | `LinkApi` in every published client          | 11 methods                                                                 |
| **MCP**  | tool `link` on `https://api.hanzo.ai/v1/mcp` | 11 operations, 4 under the document's own id — ask `describe` for the rest |

## Quickstart

```bash
export HANZO_API_KEY=sk-...   # console.hanzo.ai → API keys
```

Then the first call — a read that needs nothing but the key. `GET /v1/link`, operation `get_link`:

**CLI**

```bash
hanzo auth link list
```

**SDK**

**.ts**

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

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

**.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).get_link()
```

**.go**

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

resp, _, err := client.LinkAPI.GetLink(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::get_link(&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).getLink();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/link \
  -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"
         }
       }
     }'
```

Answers `200` with `object` — ok.

## Endpoints

| Endpoint                                                                                                                | What it does                                                       |
| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| [`GET /v1/link/{id}`](https://docs.hanzo.ai/docs/openapi/link/get-link-by-id)                                           | Reads one linked account.                                          |
| [`DELETE /v1/link/{id}`](https://docs.hanzo.ai/docs/openapi/link/delete-link-by-id)                                     | Logs out one account and stops the sessions it was running.        |
| [`POST /v1/link/devices/{machine}/revoke`](https://docs.hanzo.ai/docs/openapi/link/post-link-devices-by-machine-revoke) | Logs out every account on one machine and stops its sessions.      |
| [`GET /v1/link/devices/{machine}`](https://docs.hanzo.ai/docs/openapi/link/get-link-devices-by-machine)                 | Shows one machine: its accounts, usage and live sessions.          |
| [`GET /v1/link/route`](https://docs.hanzo.ai/docs/openapi/link/get-link-route)                                          | Gets the failover order across your linked accounts.               |
| [`GET /v1/link/usage/accounts`](https://docs.hanzo.ai/docs/openapi/link/get-link-usage-accounts)                        | Breaks down what the gateway routed through each of your accounts. |
| [`GET /v1/link/usage/summary`](https://docs.hanzo.ai/docs/openapi/link/get-link-usage-summary)                          | Shows plan consumption and Hanzo spend side by side.               |
| [`GET /v1/link/usage`](https://docs.hanzo.ai/docs/openapi/link/get-link-usage)                                          | Shows one provider account's own usage dashboard.                  |
| [`POST /v1/link/usage`](https://docs.hanzo.ai/docs/openapi/link/post-link-usage)                                        | Reports usage samples from the device collector.                   |
| [`GET /v1/link`](https://docs.hanzo.ai/docs/openapi/link/get-link)                                                      | Lists your linked accounts and the devices they sit on.            |
| [`POST /v1/link`](https://docs.hanzo.ai/docs/openapi/link/post-link)                                                    | Registers a signed-in AI provider account on a machine.            |

---

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