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 |
|
Content-Type | Yes |
|
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 |
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 |
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 |
identity_id | string | Forward Identity ID. |
template | object | Template summary. |
source_type | string | Session source; |
status | string |
|
incremental_streaming_enabled | boolean | Whether incremental streaming events are enabled. |
Errors
HTTP | Type | Code | Trigger condition |
400 |
|
| Invalid request body. |
403 |
|
| Identity does not have access to this Template. |
404 |
|
| Identity does not exist or has been deleted. |
404 |
|
| Template does not exist. |
409 |
|
| Identity has been disabled. |
422 |
|
| Effective runtime configuration is invalid. |
401 |
|
| PAT is invalid or expired. |
Notes
source_typeis set by Forward and is not accepted in the create request.incremental_streaming_enabledis persisted on the Session at creation time and cannot be modified afterward.Files in
resourcesmust have already been uploaded via the Files API.