# Replace agent

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

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

`PUT /v1/channel/agent`

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

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

Binds agents to the caller org's channel 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                                                                                   |
| --------- | ---- | --------- | -------- | --------------------------------------------------------------------------------------------- |
| `channel` | body | string    | —        | Channel is the transport to edit.                                                             |
| `default` | body | string    | —        | Default sets the agent for rooms with no binding of their own; "hanzo" restores the built-in. |
| `rooms`   | body | object    | —        | Rooms binds platform room ids to agents; rooms not named are left alone.                      |
| `rooms.*` | body | string    | —        |                                                                                               |
| `unbind`  | body | string\[] | —        | Unbind removes the bindings of these rooms, so they fall back to Default.                     |

## Response

| Status    | Body                  | Meaning |
| --------- | --------------------- | ------- |
| `200`     | channel.channelAgents | ok      |
| `default` | problem-details       | refused |

`200` body — 4 fields.

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

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

## Examples

**CLI**

```bash
hanzo channel agent replace
```

**SDK**

**.ts**

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

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

**.py**

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

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = ChannelApi(client).put_channel_agent(channel="<channel>", default="<default>")
```

**.go**

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

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

**.rs**

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

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

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

**.java**

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

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

var result = new ChannelApi(client).putChannelAgent();
```

**HTTP**

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

**MCP**

MCP reaches **channel** through the `channel` 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_channels"
         }
       }
     }'
```

---

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