# Create token

URL: https://docs.hanzo.ai/docs/openapi/registry/post-registry-token

> Mints a short-lived, pull-only registry token for exactly one of the org's images, through the same IAM realm the docker CLI authenticates against.

`POST /v1/registry/token`

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

|               |                                          |
| ------------- | ---------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/registry/token` |
| **Method**    | `POST`                                   |
| **Operation** | `post_registry_token`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`   |

Mints a short-lived, pull-only registry token for exactly one of the
org's images, through the same IAM realm the docker CLI authenticates
against. The scope is pinned server-side to `<org>/<image>` with the `pull`
action — no field exists to name another org's image or ask for push. Use it
as `Authorization: Bearer …` on the OCI wire; it expires in minutes.

## Request

1 field, body `application/json` (required).

| Field   | In   | Type   | Required | Description                                                             |
| ------- | ---- | ------ | -------- | ----------------------------------------------------------------------- |
| `image` | body | string | —        | Image is the repository name inside the org's namespace (e.g. "cloud"). |

## Response

| Status    | Body                   | Meaning |
| --------- | ---------------------- | ------- |
| `200`     | registry.registryToken | ok      |
| `default` | problem-details        | refused |

`200` body — 3 fields.

| Field     | In   | Type            | Always | Description                                                                                                |
| --------- | ---- | --------------- | ------ | ---------------------------------------------------------------------------------------------------------- |
| `expires` | body | integer (int64) | —      | Expires is the token's lifetime in seconds.                                                                |
| `ref`     | body | string          | —      | Ref is the one repository reference the token can pull.                                                    |
| `token`   | body | string          | —      | Token is the bearer to present on the OCI wire (`Authorization: Bearer …` against the host's /v2/ routes). |

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

## Examples

**CLI**

```bash
hanzo registry token
```

**SDK**

**.ts**

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

const api = new RegistryApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postRegistryToken({ image: "<image>" });
```

**.py**

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

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = RegistryApi(client).post_registry_token(image="<image>")
```

**.go**

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

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

**.rs**

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

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

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

**.java**

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

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

var result = new RegistryApi(client).postRegistryToken();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/registry/token \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "image": "<image>"
     }'
```

**MCP**

MCP reaches **registry** through the `registry` tool, which names its 5 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_registry_images"
         }
       }
     }'
```

---

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