# Replace agent

URL: https://docs.hanzo.ai/docs/openapi/transport/put-transport-agent

> Binds agents to the caller org's transport and answers the bindings as GET would.

`PUT /v1/transport/agent`

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

|               |                                           |
| ------------- | ----------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/transport/agent` |
| **Method**    | `PUT`                                     |
| **Operation** | `put_transport_agent`                     |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`    |

Binds agents to the caller org's transport and answers the bindings as
GET would. It requires ORG ADMIN. The agent is named by its ref — the name an
org gave it at POST /v1/agent, or a built-in such as dev, des or vi.

## Request

5 fields, body `application/json` (required).

| Field        | In   | Type      | Required | Description                                                                                      |
| ------------ | ---- | --------- | -------- | ------------------------------------------------------------------------------------------------ |
| `channels`   | body | object    | —        | Channels binds platform channel ids to agents; channels not named are left alone.                |
| `channels.*` | body | string    | —        |                                                                                                  |
| `default`    | body | string    | —        | Default sets the agent for channels with no binding of their own; "hanzo" restores the built-in. |
| `transport`  | body | string    | —        | Transport is the transport to edit.                                                              |
| `unbind`     | body | string\[] | —        | Unbind removes the bindings of these channels, so they fall back to Default.                     |

## Response

| Status    | Body                      | Meaning |
| --------- | ------------------------- | ------- |
| `200`     | transport.transportAgents | ok      |
| `default` | problem-details           | refused |

`200` body — 4 fields.

| Field        | In   | Type   | Always | Description                                                                                                         |
| ------------ | ---- | ------ | ------ | ------------------------------------------------------------------------------------------------------------------- |
| `channels`   | body | object | —      | Channels maps a platform channel id to the agent that answers there.                                                |
| `channels.*` | body | string | —      |                                                                                                                     |
| `default`    | body | string | —      | Default is the agent that answers any channel without a binding of its own; "hanzo" when the org has never set one. |
| `transport`  | body | string | —      | Transport is the transport these bindings are for.                                                                  |

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

## Examples

**CLI**

```bash
hanzo transport agent replace
```

**SDK**

**.ts**

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

const api = new TransportApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.putTransportAgent({ channels: {}, default: "<default>" });
```

**.py**

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

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = TransportApi(client).put_transport_agent(channels={}, default="<default>")
```

**.go**

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

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

**.rs**

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

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

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

**.java**

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

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

var result = new TransportApi(client).putTransportAgent();
```

The method above is the one at the current release of the document. `hanzoai@8.5.914` (npm) and `hanzoai@8.5.914` (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. [SDKs →](https://docs.hanzo.ai/docs/sdks)

**HTTP**

```bash
curl -X PUT https://api.hanzo.ai/v1/transport/agent \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "channels": {},
       "default": "<default>"
     }'
```

**MCP**

MCP reaches **transport** through the `transport` tool, which names its 8 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_transports"
         }
       }
     }'
```

---

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