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

# 更新 Session

> 更新 Forward Session 的标题或 metadata。

`POST /api/v1/forward/sessions/{session_id}`

只更新稳定的会话字段；运行时配置在创建后不可变。

## 请求头

| Header          | 是否必填 | 说明                 |
| --------------- | ---- | ------------------ |
| Authorization   | 是    | `Bearer <PAT>`     |
| Content-Type    | 是    | `application/json` |
| Idempotency-Key | 否    | 有副作用请求可选的幂等键。      |

## 路径参数

| 参数          | 类型     | 是否必填 | 说明          |
| ----------- | ------ | ---- | ----------- |
| session\_id | string | 是    | Session ID。 |

## 请求体参数

| 参数       | 类型     | 是否必填 | 说明                                                 |
| -------- | ------ | ---- | -------------------------------------------------- |
| title    | string | 否    | 新的 Session 标题。                                     |
| metadata | object | 否    | metadata merge patch；传入的 key 覆盖已有 key，未出现的 key 保留。 |

## 示例请求

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/sessions/sess_xxx' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Updated session title",
  "metadata": {
    "source": "mobile",
    "biz_id": "ticket_123"
  }
}'
```

## 示例响应

**HTTP 200 OK**

```json theme={null}
{
  "id": "sess_xxx",
  "type": "session",
  "identity_id": "idn_xxx",
  "template": {
    "id": "tmpl_support",
    "type": "template",
    "name": "Support assistant",
    "model": "ultimate",
    "version": 3
  },
  "source_type": "api",
  "status": "idle",
  "title": "Updated session title",
  "incremental_streaming_enabled": true,
  "metadata": {
    "source": "mobile",
    "biz_id": "ticket_123"
  },
  "config": {
    "environment_variables": {
      "API_KEY": "sk-xxx"
    }
  },
  "stats": {
    "active_seconds": 30,
    "duration_seconds": 3600
  },
  "usage": {
    "credits": 12.7
  },
  "created_at": "2026-06-22T10:00:00Z",
  "updated_at": "2026-06-22T12:00:00Z"
}
```

## 响应字段

| 字段  | 类型     | 说明               |
| --- | ------ | ---------------- |
| 返回值 | object | 更新后的 Session 对象。 |

## 错误

| HTTP | Type                    | Code                      | 触发条件         |
| ---- | ----------------------- | ------------------------- | ------------ |
| 400  | `invalid_request_error` | `invalid_request`         | 更新请求体不合法。    |
| 404  | `not_found_error`       | `session_not_found`       | Session 不存在。 |
| 409  | `conflict_error`        | `session_archived`        | Session 已归档。 |
| 401  | `authentication_error`  | `authentication_required` | PAT 无效或已过期。  |

## 注意事项

* `config`、`resources` 和 `incremental_streaming_enabled` 是创建时配置，不能通过本接口修改。

## 相关

<CardGroup cols={2}>
  <Card title="获取 Session" icon="file-lines" href="/cloud-agents/api/forward/sessions/get" />

  <Card title="归档 Session" icon="archive" href="/cloud-agents/api/forward/sessions/archive" />
</CardGroup>
