# PUT /api/ai/agents/sessions/:id

Canonical URL: https://developers.iagenify.com/zh/api/reference/agentSessions/put-agents-sessions-id/
Language: zh

`PUT https://api.iagenify.com/api/ai/agents/sessions/ID`

PUT /api/ai/agents/sessions/:id 参考。

Status: 需要身份验证 · JSON

## Contract boundaries

This endpoint inventory is generated from the mounted API route. Its HTTP method, path, observed field names, and explicit status/error codes come from route source. It is not a complete OpenAPI schema: generic `value` types, descriptions such as `Request field`, and `YOUR_*` placeholders do not define JSON types, nested shapes, validation rules, enums, or all response properties. Do not copy placeholder values as a request body or invent missing constraints.

## HTTP 请求 {#http}

```bash
curl https://api.iagenify.com/api/ai/agents/sessions/ID -X PUT -H "Authorization: Bearer $IAGENIFY_TOKEN" -H "Content-Type: application/json" -d '{"model":"YOUR_MODEL","mode":"YOUR_MODE","machine":"YOUR_MACHINE","title":"YOUR_TITLE","context":"YOUR_CONTEXT"}'
```

## JavaScript {#javascript}

```javascript
const requestBody = {
  "model": "YOUR_MODEL",
  "mode": "YOUR_MODE",
  "machine": "YOUR_MACHINE",
  "title": "YOUR_TITLE",
  "context": "YOUR_CONTEXT"
};
const response = await fetch("https://api.iagenify.com/api/ai/agents/sessions/ID", {
  method: "PUT",
  headers: { Authorization: `Bearer ${process.env.IAGENIFY_TOKEN}`, "Content-Type": "application/json" },
  body: JSON.stringify(requestBody)
});
const result = await response.json();
if (!response.ok) throw new Error(result.error);
```

## Python {#python}

```python
import os
import requests

request_body = {
  "model": "YOUR_MODEL",
  "mode": "YOUR_MODE",
  "machine": "YOUR_MACHINE",
  "title": "YOUR_TITLE",
  "context": "YOUR_CONTEXT"
}

response = requests.request("PUT", "https://api.iagenify.com/api/ai/agents/sessions/ID", headers={"Authorization": "Bearer " + os.environ["IAGENIFY_TOKEN"], "Content-Type": "application/json"}, json=request_body, timeout=30)
response.raise_for_status()
result = response.json()
```

## 路径参数 {#path}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string | 必填 | :id 的值。 |

## 请求体 {#body}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `model` | value | 参见路由规则 | 请求字段 `model`。 |
| `mode` | value | 参见路由规则 | 请求字段 `mode`。 |
| `machine` | value | 参见路由规则 | 请求字段 `machine`。 |
| `title` | value | 参见路由规则 | 请求字段 `title`。 |
| `context` | value | 参见路由规则 | 请求字段 `context`。 |

## 响应与错误 {#response}

成功时，端点返回 JSON。明确列出的状态码：400, 409。错误代码：`invalid_session_id`, `session_kind_mismatch`。
