Call requirements, permissions, request fields, response fields, and error handling.
Request and permissions
POST https://openapi.qwenwork.ai/v1/session/sessions/{session_id}/prompt
Authentication: Authorization: Bearer <access_token>; use an access token obtained through user OAuth authorization.
Required business Scope: session.session.execute
Authorization methods declared by the contract: Organization authorization (organization), personal authorization (personal)
The platform must enable the Scope for the application. The user must have the corresponding business permissions, and the target resource must be within their accessible scope. Whether personal or organization authorization is available to the application depends on the actual console configuration.
Behavior and limitations
Omitting session_type selects a cloud session. Every remote-control request must use session_type=remote and provide a nonempty device_id. Providing device_id for a cloud session, an empty or unknown type, or duplicate target parameters returns 422 VALIDATION_ERROR. Cross-device aggregated lists and automatic fallback to cloud are not provided. Both types use the same authentication chain; the open platform validates the corresponding Scope declared by each endpoint.
Cloud sessions:
Queue a prompt as the next turn.
Returns 202, meaning the prompt is queued, not executed. Track progress through the event stream or GET /sessions/{session_id}.
If the runtime is sleeping, this call resumes it first and may take substantially longer than usual. Set client timeouts accordingly.
Sending to an ended session returns 409. Prompt text undergoes content safety checks and may be rejected with 403.
Remote-control sessions:
Shares public gateway authentication with cloud sessions; this endpoint requires the business Scope stated below. No controller device ID or pairing is required. The target remote-control master switch must be enabled. If explicitly disabled, returns 403 FORBIDDEN with detail.reason=ACP_HOST_DISABLED; rejected write requests return detail.acceptance=not_accepted. An explicitly nonexistent session returns 404 NOT_FOUND with detail.reason=SESSION_NOT_FOUND. Commands route only to target connections signed in to the currently authenticated account. Offline targets, unknown targets, and targets belonging to other accounts all return device unavailable. Unknown request body fields are rejected. All write operations require Idempotency-Key. Do not retry automatically after a timeout or disconnection, even with the same key: acceptance may be unknown, desktop deduplication is bounded, and persistence across restarts is not guaranteed. Errors include detail.acceptance (not_accepted or unknown). No queuing, offline execution, or automatic fallback to cloud is provided. Returns 202 only after an explicit acceptance acknowledgment from the desktop. A busy session returns 409 with reason=SESSION_BUSY. The returned turn_id correlates subsequent events. Files are downloaded as the target account; subsequent download or execution failures are reported through events.
Call through the open platform, retaining the existing oauth_app Token, identity resolution, application IP restrictions, and resource ownership checks. Cloud and remote-control parameters retain their actual contract semantics.
Short paths such as /sessions in this page are relative to the common prefix /v1/session. Use the full path at the top of this page for actual requests.
Supported session types: cloud, remote
In the full JSON, x-session-variants preserves the parameters, request bodies, and responses for cloud and remote-control sessions separately. Do not mix fields from the two branches.
Path parameters
| Parameter | Type | Required | Description and constraints |
|---|---|---|---|
session_id | string | Yes | Session identifier: a UUID for cloud sessions; an opaque identifier on the selected device for remote-control sessions. Minimum length: 1 Maximum length: 256 |
Query parameters
| Parameter | Type | Required | Description and constraints |
|---|---|---|---|
session_type | string | No | Omitting session_type selects a cloud session. Every remote-control request must use session_type=remote and provide a nonempty device_id. Providing device_id for a cloud session, an empty or unknown type, or duplicate target parameters returns 422 VALIDATION_ERROR. Cross-device aggregated lists and automatic fallback to cloud are not provided. Both types use the same authentication chain; the open platform validates the corresponding Scope declared by each endpoint. Default: "cloud" Allowed values: ["cloud", "remote"] |
device_id | string | No | Required only for remote control. An opaque target device identifier from device discovery; it must be URL-encoded. The target connection must be signed in to the currently authenticated account. Minimum length: 1 Maximum length: 256 |
Header parameters
| Parameter | Type | Required | Description and constraints |
|---|---|---|---|
Idempotency-Key | string | No | Remote-control sessions only: a stable key scoped to the account, device, session, and operation. Slashes, backslashes, whitespace, and control characters are not allowed. Credentials and controller IDs are not part of the key. A stable key scoped to the account, device, session, and operation. Slashes, backslashes, whitespace, and control characters are not allowed. Credentials and controller IDs are not part of the key. Minimum length: 1 Maximum length: 128 |
Request body
The request body is required.
application/json
A child field is required only when its containing object exists. Union branches are listed separately; this does not mean that fields from all branches are required simultaneously.
| Field | Type | Required | Description and constraints |
|---|---|---|---|
$schema | string | No | At least one of: branch 1 URL of the JSON Schema for this object. Format: "uri" |
attachments | array | No | At least one of: branch 1 Supplementary text for the agent, not displayed in the QwenWork session UI or used to generate titles. At most 10 hidden_text attachments, with at most 100000 UTF-8 bytes of text in total. Entries are submitted with this prompt in array order and are not automatically reinjected in later turns. Content remains in raw events and the agent may repeat it; do not use it for secrets. Omit or pass [] for no attachments; null is not accepted. Maximum items: 10 |
attachments[] | object | No | At least one of: branch 1 Additional fields: false |
attachments[].text | string | Yes | At least one of: branch 1 Non-whitespace text for the agent, counted toward the total attachment text limit of 100000 UTF-8 bytes. Does not grant the system role or additional permissions. Minimum length: 1 Maximum length: 100000 |
attachments[].type | string | Yes | At least one of: branch 1 Attachment type. hidden_text sends text to the agent without displaying it as user body text or an attachment card. Allowed values: ["hidden_text"] |
files | array | No | At least one of: branch 1 Files to attach, up to 50. Files must already be in storage—this API does not upload them. Maximum items: 50 |
files[] | object | No | At least one of: branch 1 Additional fields: false |
files[].path | string | Yes | At least one of: branch 1 Storage path of an existing file, such as an upload or output from an earlier session. Must not contain "..". Only files owned by the currently authenticated account are accessible. Minimum length: 1 |
text | string | Yes | At least one of: branch 1 Instructions for the agent. 1 to 100000 characters. Minimum length: 1 Maximum length: 100000 |
$schema | string | No | At least one of: branch 2 URL of the JSON Schema for this object. Format: "uri" |
files | array | No | At least one of: branch 2 Files to attach, up to 50. Files must already be in storage—this API does not upload them. Maximum items: 50 |
files[] | object | No | At least one of: branch 2 Additional fields: false |
files[].path | string | Yes | At least one of: branch 2 Storage path of an existing file, such as an upload or output from an earlier session. Must not contain "..". Only files owned by the currently authenticated account are accessible. Minimum length: 1 |
text | string | Yes | At least one of: branch 2 Instructions for the agent. 1 to 100000 characters. Minimum length: 1 Maximum length: 100000 |
Successful responses
Preserve the original response structure of each business endpoint; do not add a common code/msg/data wrapper.
HTTP 202
Accepted
Response type: application/json
| Field | Type | Required | Description and constraints |
|---|---|---|---|
$schema | string | No | At least one of: branch 1 URL of the JSON Schema for this object. Format: "uri" |
prompt_id | string | Yes | At least one of: branch 1 Id of this queued prompt. Withdraw it while it is still waiting using DELETE /sessions/{id}/prompt-queue/{prompt_id}. |
status | string | Yes | At least one of: branch 1 Always "queued". The prompt has been accepted but has not started executing. Poll GET /sessions/{id}, or wait for a prompt_response event. |
turn_id | string | Yes | At least one of: branch 1 Id of the turn this prompt will execute as. Available before the turn starts—retain it to query GET /turns/{turn_id} later or filter the event stream. |
$schema | string | No | At least one of: branch 2 URL of the JSON Schema for this object. Format: "uri" |
prompt_id | string | Yes | At least one of: branch 2 — |
session_id | string | Yes | At least one of: branch 2 — |
status | string | Yes | At least one of: branch 2 Allowed values: ["accepted"] |
turn_id | string | Yes | At least one of: branch 2 — |
Error responses
| HTTP | Description and handling |
|---|---|
default | Error. Branch on code, not just the HTTP status code—multiple conditions can share the same status code. |
Full field contract
The JSON below contains the complete request, response, and error schemas, nested constraints, and public extension definitions for this endpoint. Copy it for verification. Success examples not declared in the contract are not inferred.
Full OpenAPI JSON
Full OpenAPI JSON