Call requirements, permissions, request fields, response fields, and error handling.
Request and permissions
GET https://openapi.qwenwork.ai/v1/session/sessions/{session_id}/events
Authentication: Authorization: Bearer <access_token>; use an access token obtained through user OAuth authorization.
Required business Scope: session.session.read
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:
Cursor-paginated event stream. Pass the returned next_cursor to the next call and persist it so you can resume from the saved cursor after a restart rather than replaying from the beginning.
seq_id is a 64-bit integer that increases monotonically within a session. Process events in seq_id order.
A malformed cursor returns 422 rather than starting over.
Events are already assembled: an agent message arrives as one event with its full content; you do not need to reassemble fragments.
type is always method, result, or error. Dispatch on the combination (type, method, sub_type); x-event-catalogue in the events schema lists each combination and its payload structure.
Content safety. Safety checks apply to text already emitted, but retraction signals are not part of this event stream, so callers reading this endpoint cannot be notified of retractions. Text read here is not authorized for republication to end users.
Stability of raw. Envelope fields change only with API versions. Event discriminators and their internal fields evolve only through additions. Fields under _meta have no compatibility guarantees.
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. Reads desktop history, not a cloud archive. An offline device returns an error, not an empty page. next_cursor can resume history or SSE, including when has_more=false. Cursors are bound to the account, device, session, and event stream. Event stream changes or unrecoverable history gaps return explicit errors. A cursor ahead of the current end returns 422 VALIDATION_ERROR; a cursor at the current end returns an empty page. Aggregate text by id, deduplicate by sequence number, append raw fragments, and replace them with assembled multi-sequence text.
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 |
|---|---|---|---|
cursor | string | No | Resume position; omit or pass 0 to start from the beginning. This endpoint and /events/stream share the same seq_id space, so cursors are interchangeable. The same rule applies: send the end of the first contiguous sequence range you hold, not the largest value observed; within a record, advance to the maximum seq_ids value, not seq_id.Remote-control sessions: an opaque string cursor bound to the account, device, session, and event stream. Pass unchanged as a string in HTTP parameters: a decimal sequence number for cloud sessions, an opaque cursor for remote control. The service validates it according to session type. Maximum length: 8192 |
limit | integer | No | Page size. Cloud: default 100, range 1 to 500. Remote control: default 50, range 1 to 100. Number of entries per page. Format: "int64" Minimum (inclusive): 1 Maximum (inclusive): 500 |
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 |
Request body
The public contract declares no request body. Do not add identity fields or undeclared business fields.
Successful responses
Preserve the original response structure of each business endpoint; do not add a common code/msg/data wrapper.
HTTP 200
Success
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" |
has_more | boolean | Yes | At least one of: branch 1 true means more events are already available; call again immediately without waiting. false means no more events are currently available. |
items | array | Yes | At least one of: branch 1 Events in ascending seq_id order. An empty array, never null, when no more events exist. An empty page is a normal response, not an error. |
items[] | object | No | At least one of: branch 1 Additional fields: false |
items[].created_at | string | Yes | At least one of: branch 1 When the event was recorded. ISO 8601, with microseconds and timezone. Sort by seq_id, not this value—database insertion order may differ from timestamp order. |
items[].id | string | Yes | At least one of: branch 1 Unique id of this event. |
items[].method | string | null | Yes | At least one of: branch 1 JSON-RPC method when type=method; null for result and error frames. Currently session/update or session/request_permission. This is an open set—tolerate unrecognized values. |
items[].raw | object | Yes | At least one of: branch 1 JSON-RPC 2.0 message, passed through verbatim. Payload locations: raw.params.update for session/update, raw.params for other methods, and raw.result for type=result. See x-event-catalogue in open-events-schema.json for the payload shape of each (type, method, sub_type) combination. 🔴 Do not read ids from here. raw contains the runtime's own identifiers—especially raw.params.sessionId, which is the agent runtime's session handle, not the same value as this API's session_id (observed: a UUID such as 9bf6533e-… in the envelope versus ses_f8dc… in raw). Use session_id / turn_id / seq_id on the envelope—every endpoint in this API recognizes only these identifiers.Additional fields: "Constrained by Schema; see the full contract" |
items[].seq_id | integer | Yes | At least one of: branch 1 Monotonically increasing sequence number within the session, also used as a pagination cursor. Persist the highest processed value and pass it back as ?cursor= to resume without gaps or duplicates. Format: "int64" |
items[].seq_ids | array | Yes | At least one of: branch 1 Sequence numbers covered by this envelope, in ascending order. This is how to distinguish deltas from complete messages, which must be handled differently. Group by id first, then within each group: - len(seq_ids) == 1—streaming delta. Append its text to the existing content for that id. - len(seq_ids) > 1—an assembled complete message covering those deltas. Replace all existing content for that id; do not append. Why both exist: each streaming fragment arrives in an envelope with the same id. Once complete, the message is stored as one event containing the entire message text. History readers, or callers reconnecting mid-message, receive the whole message at once—appending it to existing fragments would duplicate content. Observed example. Five live envelopes, id=e57bee1f, with seq_ids [26], [27], [28], [29], [30] and text fragments meaning "I will", "make a", "water-ink", "style", "five"—append. A later envelope with the same id, seq_ids=[26..38], contains the full text meaning "I will make a water-ink-style Gomoku game. First, build the overall structure."—replace. Cursors: within one envelope, advance to the maximum value here, not seq_id (the smallest sequence number covered; resuming from it redelivers the message tail). Across envelopes, resume from the end of the first contiguous sequence range you hold, not the largest observed value. Missing numbers are normal and will never arrive—some events consume sequence numbers but are not published here. Gaps do not mean lost events, but resuming past a gap skips everything after it. |
items[].seq_ids[] | integer | No | At least one of: branch 1 Format: "int64" |
items[].session_id | string | Yes | At least one of: branch 1 The session this event belongs to. |
items[].sub_type | string | null | Yes | At least one of: branch 1 Variant discriminator: the sessionUpdate value, or prompt_response on a result frame ending a turn. null when the method needs no further subdivision, such as session/request_permission. See x-event-catalogue in the events schema for all types. Open enum; tolerate unrecognized values. |
items[].turn_id | string | null | Yes | At least one of: branch 1 The turn this event belongs to. null for events outside a turn—session startup, idle state, and out-of-band publication genuinely belong to no turn. |
items[].type | string | Yes | At least one of: branch 1 JSON-RPC frame type. Dispatch on (type, method, sub_type); see x-event-catalogue in the events schema. Allowed values: ["method", "result", "error"] |
next_cursor | integer | Yes | At least one of: branch 1 The largest seq_id on this page. Pass it back as ?cursor= on the next call and persist it to resume here after a restart. 0 when this page is empty; keep using the original cursor in that case. Format: "int64" |
$schema | string | No | At least one of: branch 2 URL of the JSON Schema for this object. Format: "uri" |
has_more | boolean | Yes | At least one of: branch 2 — |
items | array | Yes | At least one of: branch 2 — |
items[] | object | No | At least one of: branch 2 Additional fields: false |
items[].created_at | string | Yes | At least one of: branch 2 — |
items[].id | string | Yes | At least one of: branch 2 — |
items[].method | string | null | Yes | At least one of: branch 2 — |
items[].raw | object | Yes | At least one of: branch 2 JSON-RPC after the existing safe outbound projection, not executor logs. Additional fields: "Constrained by Schema; see the full contract" |
items[].seq_id | integer | Yes | At least one of: branch 2 The first covered sequence number in the current event stream. Use the opaque cursor to resume. Format: "int64" |
items[].seq_ids | array | Yes | At least one of: branch 2 Set of covered sequence numbers. Deduplicate single-sequence text fragments by sequence number before appending; multi-sequence aggregated text replaces existing fragments with the same id. |
items[].seq_ids[] | integer | No | At least one of: branch 2 Format: "int64" |
items[].session_id | string | Yes | At least one of: branch 2 — |
items[].sub_type | string | null | Yes | At least one of: branch 2 — |
items[].turn_id | string | null | Yes | At least one of: branch 2 — |
items[].type | string | Yes | At least one of: branch 2 — |
next_cursor | string | Yes | At least one of: branch 2 Resource-scoped cursor for the next history read or SSE subscription, even when has_more is false. |
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