Call requirements, permissions, request fields, response fields, and error handling.
Request and permissions
POST https://openapi.qwenwork.ai/v1/session/sessions/{session_id}/cancel
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:
Interrupt the executing turn. The session remains alive; use DELETE /sessions/{session_id} to end it.
The response explains what was cancelled:
- 202,
status: cancelling—a turn was executing and an interruption request has been sent. This does not mean the turn has stopped; confirm throughGET /sessions/{session_id}. - 200,
status: noop—nothing was executing.reasonspecifies the situation:no_active_turnornot_started. - 409—the session has ended.
DELETE /sessions/{session_id}/prompt-queue/{prompt_id}.
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. Send an empty JSON object. A validated cancellation acknowledgment returns 202 and status=cancelling, which does not mean execution has stopped; confirm the terminal event separately. Conditional cancellation of a specified turn is unsupported.
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 optional.
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 | URL of the JSON Schema for this object. Format: "uri" |
Successful responses
Preserve the original response structure of each business endpoint; do not add a common code/msg/data wrapper.
HTTP 200
Nothing was cancelled. status is noop; reason explains why: no_active_turn (the session is idle) or not_started (the runtime is still preparing). This is not an error—the request was understood, but there was no running turn to interrupt.
Response type: application/json
| Field | Type | Required | Description and constraints |
|---|---|---|---|
$schema | string | No | URL of the JSON Schema for this object. Format: "uri" |
command_id | string | No | The id of this cancellation, present only when cancellation was actually sent. It is passed to the agent as commandId and appears in runtime logs and traces, making it useful when reporting that cancellation did not take effect. It is not echoed in the event stream. |
reason | string | No | Why nothing was cancelled; present only when status is "noop". "no_active_turn": the session is idle. "not_started": the session is still preparing its runtime. |
status | string | Yes | "cancelling" means cancel has been sent to the executing turn—this is a request, not confirmation that it has stopped. Poll GET /sessions/{id} until the turn leaves running. "noop" means nothing could be cancelled at that time; see reason. |
turn_id | string | No | The turn being cancelled. null or absent when nothing was running. |
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" |
command_id | string | No | At least one of: branch 1 The id of this cancellation, present only when cancellation was actually sent. It is passed to the agent as commandId and appears in runtime logs and traces, making it useful when reporting that cancellation did not take effect. It is not echoed in the event stream. |
reason | string | No | At least one of: branch 1 Why nothing was cancelled; present only when status is "noop". "no_active_turn": the session is idle. "not_started": the session is still preparing its runtime. |
status | string | Yes | At least one of: branch 1 "cancelling" means cancel has been sent to the executing turn—this is a request, not confirmation that it has stopped. Poll GET /sessions/{id} until the turn leaves running. "noop" means nothing could be cancelled at that time; see reason. |
turn_id | string | No | At least one of: branch 1 The turn being cancelled. null or absent when nothing was running. |
$schema | string | No | At least one of: branch 2 URL of the JSON Schema for this object. Format: "uri" |
session_id | string | Yes | At least one of: branch 2 — |
status | string | Yes | At least one of: branch 2 The command has been acknowledged; wait for the turn's terminal event to confirm it has stopped. Allowed values: ["cancelling"] |
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