All Products
Search
Document Center

Qoder CN Series:Create a session

Last Updated:Jul 15, 2026

Create a Forward Session based on an Identity and Template.

POST /api/v1/forward/sessions

Forward compiles the Template baseline and Identity Config overlay, then creates a runtime Session.

Request headers

Header

Required

Description

Authorization

Yes

Bearer <PAT>

Content-Type

Yes

application/json

Idempotency-Key

No

Optional idempotency key for side-effecting requests.

Request body parameters

Parameter

Type

Required

Description

identity_id

string

Yes

Forward Identity ID.

template_id

string

Yes

Forward Template ID.

title

string

No

Session title.

incremental_streaming_enabled

boolean

No

Whether to enable incremental streaming events for the assistant. Default false.

metadata

object

No

Business metadata.

config

object

No

Per-session configuration override; only whitelisted fields are accepted.

config.environment_variables

object

No

Session environment variable key-value pairs.

resources

array

No

Session-level resources, currently used for mounting files.

resources[].type

string

Conditionally required

Resource type, currently file.

resources[].file_id

string

Conditionally required

File ID returned by the Files API.

resources[].mount_path

string

No

Mount path inside the Agent container; omit to let Forward generate a path from the filename.

Sample request

curl -s -X POST 'https://api.qoder.com.cn/api/v1/forward/sessions' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
  "identity_id": "idn_xxx",
  "template_id": "tmpl_support",
  "title": "Customer support session",
  "incremental_streaming_enabled": true,
  "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"
    }
  ]
}'

Sample 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",
  "incremental_streaming_enabled": true,
  "metadata": {
    "source": "web"
  },
  "config": {
    "environment_variables": {
      "API_KEY": "sk-xxx"
    }
  },
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0
  },
  "created_at": "2026-06-22T10:00:00Z",
  "updated_at": "2026-06-22T10:00:00Z"
}

Response fields

Field

Type

Description

id

string

Session ID.

type

string

Always session.

identity_id

string

Forward Identity ID.

template

object

Template summary.

source_type

string

Session source; api for direct API creation.

status

string

idle, running, rescheduling, canceling, or terminated.

incremental_streaming_enabled

boolean

Whether incremental streaming events are enabled.

Errors

HTTP

Type

Code

Trigger condition

400

invalid_request_error

invalid_request_body

Invalid request body.

403

permission_error

template_access_denied

Identity does not have access to this Template.

404

not_found_error

identity_not_found

Identity does not exist or has been deleted.

404

not_found_error

template_not_found

Template does not exist.

409

conflict_error

identity_disabled

Identity has been disabled.

422

invalid_request_error

runtime_config_invalid

Effective runtime configuration is invalid.

401

authentication_error

authentication_required

PAT is invalid or expired.

Notes

  • source_type is set by Forward and is not accepted in the create request.

  • incremental_streaming_enabled is persisted on the Session at creation time and cannot be modified afterward.

  • Files in resources must have already been uploaded via the Files API.