Skip to main content
Sessions

Update a session

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

POST /api/v1/forward/sessions/{session_id} Updates stable Session fields. In config, this endpoint currently supports only environment_variables.

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. Currently, only environment_variables is allowed. null is invalid.
config.environment_variablesobjectNoSession environment variable key-value pairs. Values must be strings. null is invalid. 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.
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.
  • 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.

Example request

curl -s -X POST 'https://api.qoder.com/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": {
    "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": {
    "environment_variables": {
      "API_KEY": "sk-xxx",
      "REGION": "cn-hangzhou"
    }
  },
  "stats": {
    "active_seconds": 30,
    "duration_seconds": 3600
  },
  "usage": {
    "total_credits": 12.7
  },
  "archived_at": null,
  "created_at": "2026-06-22T10:00:00Z",
  "updated_at": "2026-06-22T12:00:00Z"
}

Response fields

Returns the updated Session object.

Errors

HTTPTypeCodeTrigger
400invalid_request_errorinvalid_requestInvalid update body.
400invalid_request_errorinvalid_request_bodyInvalid JSON body, or config or config.environment_variables is null.
401authentication_errorauthentication_requiredPAT or SAT invalid or expired.
404not_found_errorsession_not_foundSession does not exist.
409conflict_errorsession_archivedSession is archived.

Notes

  • 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.