Skip to main content
Sessions

Update a session

Update a Forward session title, metadata, environment variables, or model configuration.

POST /api/v1/forward/sessions/{session_id} config supports updates to environment_variables and model. Model updates apply only to this Session and do not modify the Template or Identity Config.

Headers

HeaderRequiredDescription
AuthorizationYesBearer <PAT or SAT>
Content-TypeYesapplication/json
Idempotency-KeyNoOptional idempotency key for unsafe requests.

Path parameters

ParameterTypeRequiredDescription
session_idstringYesSession ID.

Body parameters

ParameterTypeRequiredDescription
titlestringNoNew session title.
metadataobjectNoMetadata merge patch. Provided keys overwrite existing keys; omitted keys remain unchanged.
configobjectNoSession configuration update. Only environment_variables and model are allowed. null is invalid; omission or {} leaves the existing configuration unchanged.
config.environment_variablesobject<string, string> (recommended)NoSession environment variables. For new integrations, pass every value as a string. The supplied map replaces the entire existing set of Session-level environment variables. The replacement is then merged on top of the compiled Template + Identity Config result, with Session-level values overriding base-layer values with the same key.
config.modelstring | object | nullNoA non-null value replaces the entire Session model override; null removes the override and restores inheritance. Omission keeps the current override.
Update semantics for config.environment_variables:
  • Omitted, or config is {}: leave the environment variables unchanged.
  • Non-empty object: replace the entire Session-level environment variable map. It is not incrementally merged with the previous map, and existing keys that are omitted are deleted.
  • Empty object {}: clear all Session-level environment variables.
  • Use strings for values; object and array values are invalid.
  • The replacement applies only to the Session-level layer. After the update, the Session runtime environment variables are still merged on top of the compiled Template + Identity Config result, with Session-level values overriding base-layer values with the same key.
  • The runtime validates environment variable names, reserved words, and capacity limits. Invalid values return HTTP 400.

config.model

config.model accepts a non-empty model ID string (for example, "ultimate") or an object containing a model ID and optional tuning parameters, using the same format as Template / Identity Config. See List models for available models and supported options.
Object fieldTypeRequiredDescription
idstringYesNon-empty model ID from the id returned by List models.
effortstringNoReasoning effort: none, low, medium, high, xhigh, or max. Supported levels are defined by the model's efforts; if omitted, the model default is used.
speedstringNoInference speed: standard or high; defaults to standard. Supported speeds are defined by the model's speed array.
context_windowintegerNoContext window in tokens. Must be a positive integer selected from the model's available_context_windows; if omitted, the model default window is used.
The available model and option combinations depend on the capabilities returned by List models and runtime validation.
  • Omit config.model: keep the current configuration.
  • Pass a string or object: replace the entire model configuration. Previous options not supplied are not retained. The new configuration applies to subsequent model calls.
  • Pass null: remove the Session model override and inherit the current Template / Identity Config model.
  • Pass {}: returns HTTP 400. A model object must contain a non-empty id.
template.model is the template summary. See config.model in the response for the Session model override.

Example request

curl -s -X POST 'https://api.qoder.com.cn/api/v1/forward/sessions/sess_xxx' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Updated session title",
  "metadata": {
    "source": "mobile",
    "biz_id": "ticket_123"
  },
  "config": {
    "model": {
      "id": "ultimate",
      "effort": "high",
      "context_window": 200000
    },
    "environment_variables": {
      "API_KEY": "sk-xxx",
      "REGION": "cn-hangzhou"
    }
  }
}'

Example response

HTTP 200 OK
{
  "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",
  "metadata": {
    "source": "mobile",
    "biz_id": "ticket_123"
  },
  "config": {
    "model": {
      "id": "ultimate",
      "effort": "high",
      "context_window": 200000
    },
    "environment_variables": {
      "API_KEY": "sk-xxx",
      "REGION": "cn-hangzhou"
    }
  },
  "stats": {
    "active_seconds": 30,
    "duration_seconds": 3600
  },
  "usage": {
    "total_credits": 12.7
  },
  "outcome_evaluations": [],
  "archived_at": null,
  "created_at": "2026-06-22T10:00:00Z",
  "updated_at": "2026-06-22T12:00:00Z"
}

Response fields

Returns the updated Session object.
FieldTypeDescription
config.modelstring | objectThe saved Session model override retains its string or object form; omitted when the override is removed.

Errors

HTTPTypeCodeTrigger
503api_errorsession_materialization_busyRefreshing Session configuration for a config.environment_variables or config.model update encounters a runtime version or state conflict. The response includes Retry-After: 1; wait for the current Turn to finish before retrying.
400invalid_request_errorinvalid_requestInvalid update body, including invalid config.model ( {}, an empty ID, or invalid types or parameters), or unsupported configuration fields.
400invalid_request_errorinvalid_request_bodyInvalid JSON body, or invalid config or config.environment_variables.
404not_found_errorsession_not_foundSession does not exist.
409invalid_request_errorsession_archivedSession is archived.
401authentication_error-PAT or SAT invalid or expired.

Notes

  • Updating only the title or metadata does not trigger this configuration refresh. If an environment variable or model update returns session_materialization_busy, follow Retry-After, wait for the current Turn to finish, and retry with the same request body. If the original request included Idempotency-Key, reuse that key. This temporary rejection is not cached as a final idempotent response; this rule applies only to this error code.
  • resources is a create-time setting and cannot be changed here. To add a file resource while the session is in progress, use the Add a session resource endpoint.
  • config.environment_variables in the response reflects the updated result.
  • For compatibility with existing calls only, non-string scalar values are normalized to strings (null becomes an empty string). For new integrations, use string values.