Skip to main content
Sessions

Create a session

Create a Forward session from an Identity and Template.

POST /api/v1/forward/sessions Creates a session by compiling the Template baseline with the Identity Config override, then starting a runtime Session.

Headers

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

Body parameters

ParameterTypeRequiredDescription
identity_idstringYesForward Identity ID.
template_idstringYesForward Template ID.
titlestringNoSession title.
metadataobjectNoCustom metadata.
configobjectNoPer-session configuration override. Only allowlisted fields are accepted.
config.environment_variablesobjectNoSession environment variables as key-value pairs. They are merged on top of the compiled Template + Identity Config result; Session-level values override base-layer values with the same key.
resourcesarrayNoSession-level resources, currently file mounts.
resources[].typestringYes when resources is usedResource type. Currently file.
resources[].file_idstringYes when resources is usedFile ID from the Files API.
resources[].mount_pathstringNoMount path inside the agent container. If omitted, Forward derives one from the filename.
Merge semantics for config.environment_variables:
  • Forward first compiles the Template environment_variables baseline and the Identity Config override layer to produce the base environment variables.
  • Key-value pairs supplied in the request are added to the base environment variables. New keys are added, while Session-level values override base-layer values with the same key.
  • Variables omitted from the request remain in the compiled Template + Identity Config result.

Example request

curl -s -X POST 'https://api.qoder.com/api/v1/forward/sessions' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "identity_id": "idn_xxx",
  "template_id": "tmpl_support",
  "title": "Customer support session",
  "metadata": {
    "source": "web",
    "biz_id": "ticket_123"
  },
  "config": {
    "environment_variables": {
      "API_KEY": "sk-xxx",
      "REGION": "cn-hangzhou"
    }
  },
  "resources": [
    {
      "type": "file",
      "file_id": "file_019e6a18dc09abcd",
      "mount_path": "/data/input.py"
    }
  ]
}'

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": "Customer support session",
  "metadata": {
    "source": "web"
  },
  "config": {
    "environment_variables": {
      "API_KEY": "sk-xxx"
    }
  },
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0
  },
  "usage": {
    "total_credits": 0
  },
  "archived_at": null,
  "created_at": "2026-06-22T10:00:00Z",
  "updated_at": "2026-06-22T10:00:00Z"
}

Response fields

FieldTypeDescription
idstringSession ID.
typestringAlways session.
identity_idstringForward Identity ID.
templateobjectTemplate summary.
source_typestringSession source. Direct API creation uses api.
statusstringidle, running, rescheduling, canceling, or terminated.
archived_atstring|nullArchive timestamp.
created_atstringCreation timestamp.
updated_atstringUpdate timestamp.

Errors

HTTPTypeCodeTrigger
400invalid_request_errorinvalid_request_bodyInvalid request body.
403permission_errortemplate_access_deniedIdentity cannot use the Template.
404not_found_erroridentity_not_foundIdentity does not exist or is deleted.
404not_found_errortemplate_not_foundTemplate does not exist.
409conflict_erroridentity_disabledIdentity is disabled.
422invalid_request_errorruntime_config_invalidEffective runtime config is invalid.
401authentication_errorauthentication_requiredThe PAT or SAT is invalid or expired.

Notes

  • source_type is assigned by Forward and is not accepted in the create request.
  • incremental_streaming_enabled is a legacy streaming toggle retained for backward compatibility. It is not recommended for new integrations and cannot be changed after creation. New integrations that need streaming output should use event_deltas[] when subscribing to the Session Event Stream. If this field is set to true, event_deltas[] does not take effect.
  • Uploaded files must already exist in the Files API before being passed in resources.