Update session metadata, model, reasoning effort, and service tier; changes apply to later turns only.
Endpoint
POST /agents/sessions/{session_id}
Returns 200 and the complete updated Session. Only metadata, agent.model, and agent.reasoning.effort can be updated.
Updates affect later turns only. They do not change a running turn or write back to the saved agent. Concurrent update conflicts return 409 conflict_error; retrieve the latest state and retry.
Request body
| Field | Required | Type | Description |
|---|---|---|---|
metadata | No | object / null | Metadata, replaced as a whole, omitted keeps the current value, null or {} clears. Up to 16 items, key non-empty and up to 64 characters, value a string up to 512 characters |
agent | No | object | Session-level settings, omitted keeps the current value, null is rejected, {} is valid but changes nothing. Unknown fields are rejected |
agent.model | No | string | Model for later turns, omitted keeps the current value, null or all whitespace is rejected. The update endpoint allows up to 1,048,576 characters, and a model change must use a model available in the current workspace |
agent.reasoning | No | object | Can contain only effort, not summary, omitted keeps the current value, null is rejected |
agent.reasoning.effort | No | string / null | Reasoning effort, none, minimal, low, medium, high, xhigh, max, or ultra; null resets to the model default |
metadata and agent must be present. An empty request body, JSON null, or a request body of {} returns 400.
agent: {} is valid by itself but does not change any setting. Update validates the settings before reading and merging the resource; if the settings are invalid and the resource does not exist at the same time, the API can return 400 first.
Request example
Response example
Response fields
Returns the complete updated session object. null when the fields are incomplete.
| Field | Type | Description |
|---|---|---|
id | string | Session ID; reuse it for follow-up turns |
object | string | Session object type, fixed as agent.session |
created_at | integer | Creation time in Unix seconds |
last_active_at | integer | Last activity time in Unix seconds; not a version number or lock |
status | string | Session status: idle, in_progress, requires_action, or failed |
agent | object | Effective agent snapshot. |
agent.id | string | Agent ID; inline configurations return a session snapshot ID, not a reusable saved agent, and it cannot be retrieved through Agent GET |
agent.model | string | Model ID |
agent.instructions | string / null | Custom instructions |
agent.name | string / null | Display name |
agent.reasoning | object / null | Reasoning configuration, contains effort and summary |
agent.text | object / null | Text output configuration; contains format and verbosity |
agent.tools | array | Tool configuration |
agent.multi_agent | object / null | Subagent configuration; contains enabled and max_concurrent_subagents |
environment | object | Safe environment summary; only type for none. |
environment.type | string | Environment type; none or openai_hosted |
environment.id | string | Environment ID, omitted when there is no authoritative value |
environment.status | string | Environment status: omitted when there is no authoritative value |
environment.environment_template_id | string | Environment template ID, omitted when there is no authoritative value |
environment.workspace_directory | string | Workspace directory, omitted when there is no authoritative value |
environment.error | string / null | Environment error description, omitted when there is no authoritative value |
environment.desktop | object / null | Desktop settings; contains enabled |
environment.capability_directories | array<string> / null | Capability discovery directories |
environment.network | object / null | Network policy; contains access and allowed_domains |
environment.packages | object / null | Package lists; contains npm, python, and system |
environment.files | array | Safe environment file metadata |
environment.skills | array | Safe skill metadata |
environment.plugins | array | Plugin information; [] for managed environments |
metadata | object | Session metadata; an empty value is {} |
vault_ids | array<string> | Vault IDs recorded at creation; this does not mean mounting is complete |
required_actions | array | Function calls that need client handling; [] when empty. |
required_actions[].type | string | Item type, fixed as function_call |
required_actions[].turn_id | string | Public turn ID |
required_actions[].call_id | string | Function call ID |
required_actions[].name | string | Function name |
required_actions[].arguments | object | Parsed call arguments |
error | string / null | Session-level error message, different from a turn's structured error |
usage | object / null | Token usage. |
usage.input_tokens | integer | Number of input tokens |
usage.input_tokens_details | object | Input token details. |
usage.input_tokens_details.cached_tokens | integer | Number of input tokens that hit the cache |
usage.output_tokens | integer | Number of output tokens |
usage.output_tokens_details | object | Output token details. |
usage.output_tokens_details.reasoning_tokens | integer | Number of reasoning tokens |
usage.total_tokens | integer | Total number of tokens |
spend_control | object | Spend control; returned only when a historical record has a value; creation and update do not accept writes. |
spend_control.limit | integer | Spending limit in cents |
spend_control.consumed | integer / null | Consumed amount in cents |
Error codes
Business errors return an error object with type, code, message, and param. Common errors:
| HTTP status | Error type / code | Solution |
|---|---|---|
400 | invalid_request_error / invalid_request_error | Send at least one of metadata or agent in a valid JSON object |
400 | invalid_request_error / unknown_parameter, invalid_type, invalid_value | Remove unknown fields and fix field types and enum values as described |
400 | invalid_request_error / object_above_max_properties, empty_property_name, property_name_above_max_length, string_above_max_length | Shorten metadata or the string field as described |
401 | authentication_error / invalid_api_key | Send a valid Authorization: Bearer $DASHSCOPE_API_KEY header |
404 | not_found_error / not_found_error | Use a well-formed, non-archived session ID from the current workspace |
409 | conflict_error / conflict_error | Retrieve the session again and retry |
502 | server_error / agents_api_upstream_unavailable | Retry later. If it keeps failing, submit a ticket with the x-request-id from the response headers |