> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memorylake.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 绑定 Agent 到工作空间

> 将 Agent 绑定到工作空间以启用 A2A 通信

```
POST /openapi/memorylake/api/v3/workspaces/{workspaceId}/agents
```

将现有 Agent 绑定到指定工作空间。绑定后，Agent 可在工作空间内进行 A2A（Agent 对 Agent）通信和任务执行。一个 Agent 可以绑定到多个工作空间。

<Note>
  **所需权限：** `workspace:agent_bind`
</Note>

### 路径参数

<ParamField path="workspaceId" type="string" required>
  工作空间标识符
</ParamField>

### 请求体

<ParamField body="agent_id" type="string" required>
  要绑定到工作空间的 Agent 标识符
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://app.memorylake.cn/openapi/memorylake/api/v3/workspaces/ws_abc123/agents' \
    -H 'Authorization: Bearer sk_xxxxxx' \
    -H 'Content-Type: application/json' \
    -d '{
      "agent_id": "agt_r8k2m1n3"
    }'
  ```
</RequestExample>

### 响应

<ResponseField name="data" type="object">
  <Expandable title="Agent 绑定对象">
    <ResponseField name="name" type="string">Agent 名称</ResponseField>
    <ResponseField name="agent_id" type="string">Agent 标识符</ResponseField>
    <ResponseField name="custom_id" type="string">用于外部系统集成的自定义标识符</ResponseField>
    <ResponseField name="latest_version" type="integer">Agent 的最新版本号</ResponseField>
    <ResponseField name="bound_at" type="string">Agent 绑定到工作空间的时间戳</ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json Success (200) theme={null}
  {
    "success": true,
    "data": {
      "name": "Support Assistant",
      "agent_id": "agt_r8k2m1n3",
      "custom_id": "support-assistant-v1",
      "latest_version": 3,
      "bound_at": "2025-04-01T08:00:00Z"
    }
  }
  ```
</ResponseExample>
