Skip to main content

Create an application session

Call requirements, permissions, request fields, response fields, and error handling.

Request and permissions

POST https://openapi.qwenwork.ai/v1/session/sessions 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

Create a session using the application's currently effective configuration. Use an oauth_app user Bearer Token; app_id must match the token. System prompts, skills, connectors, and expert suites are injected from the currently effective application and Agent versions. Callers must not set user_id, initial_prompt, attachments, or additional_resources, or override these configurations. The request body uses fields such as app_id and text; this creation endpoint does not currently support session_type/device_id parameters for remote-control creation. 202 means accepted; query the session or subscribe to events under the same /v1/session prefix. This operation provides no idempotency guarantee: creation may have succeeded after a timeout or disconnection, so do not retry automatically. 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.

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.
FieldTypeRequiredDescription and constraints
agent_idstringNoAgent ID within the application; if omitted, existing creation logic selects the default Agent.
app_idstringYesApplication ID; must match app_id in the oauth_app user Token.
Minimum length: 1
localestringNoLanguage preference, passed through using the original creation logic.
modestringNoSession mode; if omitted, the Session service determines the default.
namestringNoSession name, passed through using the original creation logic.
textstringYesFirst-turn task text; must not be whitespace-only, with at most 100000 Unicode characters.
Minimum length: 1
Maximum length: 100000
timezonestringNoTimezone preference, passed through using the original creation logic.
ttl_secondsintegerNoSession lifetime in seconds. The Session service validates the allowed range; not passed through if omitted.
{
  "app_id": "app_example",
  "locale": "zh-CN",
  "text": "请生成本周工作总结"
}

Successful responses

Preserve the original response structure of each business endpoint; do not add a common code/msg/data wrapper.

HTTP 202

Creation accepted. Uses the original creation endpoint's response without an additional outer wrapper. Response type: application/json
FieldTypeRequiredDescription and constraints
agent_idstringYesApplication Agent ID actually used.
app_idstringYesApplication ID actually used.
created_atstringYesSession creation time, in the original creation endpoint's format.
first_turn_idstringYesFirst-turn identifier, as returned by Session.
session_idstringYesID of the created session.
statusstringYesSession state returned by Session, without enum restrictions.
version_idstringYesEffective application version ID whose configuration was actually injected.

Error responses

HTTPDescription and handling
400Invalid request parameters, or app_id does not match the token.
401User Token is missing, invalid, or of an incompatible type.
403Access denied by application IP restrictions.
404Application or Agent does not exist.
409The application has no effective published version yet.
413Request body exceeds 1 MiB.
415Request content type is not JSON.
422Session rejected creation, for example because resource, mode, or quota validation failed.
429Business service rate limit exceeded.
500Internal processing error.
503Identity, configuration storage, or Session dependency is unavailable.
Retain the request ID and error fields in the response for troubleshooting. A write operation may already have taken effect after a timeout or disconnection. Do not automatically retry merely because no successful response was received.

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.
{
  "components": {
    "schemas": {
      "SessionAppCreateRequest": {
        "additionalProperties": false,
        "properties": {
          "agent_id": {
            "description": "Agent ID within the application; if omitted, existing creation logic selects the default Agent.",
            "type": "string"
          },
          "app_id": {
            "description": "Application ID; must match app_id in the oauth_app user Token.",
            "minLength": 1,
            "type": "string"
          },
          "locale": {
            "description": "Language preference, passed through using the original creation logic.",
            "type": "string"
          },
          "mode": {
            "description": "Session mode; if omitted, the Session service determines the default.",
            "type": "string"
          },
          "name": {
            "description": "Session name, passed through using the original creation logic.",
            "type": "string"
          },
          "text": {
            "description": "First-turn task text; must not be whitespace-only, with at most 100000 Unicode characters.",
            "maxLength": 100000,
            "minLength": 1,
            "type": "string"
          },
          "timezone": {
            "description": "Timezone preference, passed through using the original creation logic.",
            "type": "string"
          },
          "ttl_seconds": {
            "description": "Session lifetime in seconds. The Session service validates the allowed range; not passed through if omitted.",
            "type": "integer"
          }
        },
        "required": [
          "app_id",
          "text"
        ],
        "type": "object"
      },
      "SessionAppCreateResponse": {
        "additionalProperties": false,
        "properties": {
          "agent_id": {
            "description": "Application Agent ID actually used.",
            "type": "string"
          },
          "app_id": {
            "description": "Application ID actually used.",
            "type": "string"
          },
          "created_at": {
            "description": "Session creation time, in the original creation endpoint's format.",
            "type": "string"
          },
          "first_turn_id": {
            "description": "First-turn identifier, as returned by Session.",
            "type": "string"
          },
          "session_id": {
            "description": "ID of the created session.",
            "type": "string"
          },
          "status": {
            "description": "Session state returned by Session, without enum restrictions.",
            "type": "string"
          },
          "version_id": {
            "description": "Effective application version ID whose configuration was actually injected.",
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "first_turn_id",
          "status",
          "created_at",
          "app_id",
          "version_id",
          "agent_id"
        ],
        "type": "object"
      },
      "SessionRelayError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "type": "string"
          },
          "error_code": {
            "type": "string"
          },
          "error_description": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "error_description",
          "error_code"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "OpenPlatformBearer": {
        "description": "Authorization: Bearer <access_token>; JSON Content-Type: application/json; charset=utf-8. The current CN Review temporarily allows access only for routing debugging.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/session/sessions": {
      "post": {
        "description": "Create a session using the application's currently effective configuration. Use an oauth_app user Bearer Token; app_id must match the token. System prompts, skills, connectors, and expert suites are injected from the currently effective application and Agent versions. Callers must not set user_id, initial_prompt, attachments, or additional_resources, or override these configurations. The request body uses fields such as app_id and text; this creation endpoint does not currently support session_type/device_id parameters for remote-control creation. 202 means accepted; query the session or subscribe to events under the same /v1/session prefix. This operation provides no idempotency guarantee: creation may have succeeded after a timeout or disconnection, so do not retry automatically.",
        "operationId": "session-create",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "app_id": "app_example",
                "locale": "zh-CN",
                "text": "请生成本周工作总结"
              },
              "schema": {
                "$ref": "#/components/schemas/SessionAppCreateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionAppCreateResponse"
                }
              }
            },
            "description": "Creation accepted. Uses the original creation endpoint's response without an additional outer wrapper.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Invalid request parameters, or app_id does not match the token.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "User Token is missing, invalid, or of an incompatible type.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Access denied by application IP restrictions.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Application or Agent does not exist.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "The application has no effective published version yet.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Request body exceeds 1 MiB.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Request content type is not JSON.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Session rejected creation, for example because resource, mode, or quota validation failed.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Business service rate limit exceeded.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Internal processing error.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionRelayError"
                }
              }
            },
            "description": "Identity, configuration storage, or Session dependency is unavailable.",
            "headers": {
              "X-Request-ID": {
                "description": "Request ID generated by the open platform for each HTTP request, for log correlation and troubleshooting. Retries generate new IDs; this is not an idempotency key or distributed Trace ID.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              },
              "X-Trace-ID": {
                "description": "OpenTelemetry TraceID for the current open-platform request, correlated with X-Request-ID through request logs. A complete trace may be unavailable if the sample was not retained.",
                "schema": {
                  "pattern": "^[0-9a-f]{32}$",
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "OpenPlatformBearer": []
          }
        ],
        "summary": "Create an application session",
        "tags": [
          "会话管理"
        ]
      }
    }
  },
  "info": {
    "title": "Create an application session",
    "version": "2026-11-24"
  },
  "servers": [
    {
      "url": "https://openapi.qwenwork.ai"
    }
  ]
}
Back to the OpenAPI overview.