# 重命名团队会话

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

修改指定团队会话的名称。


```http
PATCH https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agent-teams/{team_id}/sessions/{context_id}
```

## 调用前准备

`BASE_URL` 使用产品 API 前缀 `https://api.moi.matrixorigin.cn/v5`；专有部署填写对应的产品 API 地址。

[准备同环境产品身份与对象标识](objects.md#prepare)。

## 请求

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} 输入示例

```bash
curl --request PATCH \
  "$BASE_URL/workspaces/$WORKSPACE_ID/agent-teams/$TEAM_ID/sessions/$CONTEXT_ID" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID" \
  --header "Content-Type: application/json" \
  --data '{"name":"资料核对","expected_version":1}'
```

:::::
:::::{tab-item} 参数说明

| 参数 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `workspace_id` | 路径 | string | 是 | 当前工作区ID，与产品身份和请求头保持同环境一致。 |
| `team_id` | 路径 | string | 是 | 团队ID，来自团队列表或创建响应。 |
| `context_id` | 路径 | string | 是 | 团队会话ID，来自会话创建或列表。 |
| `name` | 请求体 | string | 是 | 非空会话名称。 |
| `expected_version` | 请求体 | integer | 是 | 当前会话 version。 |

使用该会话自己的 version。名称去除首尾空白后非空，expected_version须正数且匹配；改名不重置 active_task_id、pending_ingress_id 或提供商会话。

:::::
::::::
:::::::

## 成功响应

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{
  "code": 0,
  "data": {
    "workspace_id": "workspace-example",
    "team_id": "team-example",
    "context_id": "context-example",
    "name": "资料核对",
    "created_by_moi_user_id": "user-example",
    "updated_by_moi_user_id": "user-example",
    "version": 2,
    "created_at": "2026-11-12T01:00:00Z",
    "updated_at": "2026-11-12T01:00:00Z"
  }
}
```

:::::
:::::{tab-item} 字段说明

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `code` | integer | 成功为0。 |
| `data` | object | [对应返回对象](objects.md#responses)。 |

HTTP200；返回[对应对象](objects.md#responses)，写后使用对应读取动作确认。

:::::
::::::
:::::::

## 错误响应

[错误与并发处理](lifecycle.md#errors)区分参数、版本、成员/会话状态及准入失败。
