CreateSession - Create a Conversation Session

Create a new conversation session (Session) to organize one or more question-and-answer interactions.

Interface Description

A Session represents a conversation context. After creation, a sessionId is returned. Subsequent question requests must be associated with a Session.

If the client already has a reusable sessionId, this step can be skipped and a question can be submitted directly.

Usage Notes

  • A single Session can contain multiple questions.
  • A Session can be reused multiple times; you do not need to create a new one for every question.

Request Method

POST /open/session/safe_new?tenantId={tenantId}&userId={userId}&loginToken={loginToken}

Request Parameters

ParameterLocationTypeRequiredDescription
tenantIdQuery + BodyIntegerYesTenant ID
userIdQuery + BodyIntegerYesUser ID
domainIdBodyIntegerYesData domain ID, corresponding to a dataset
titleBodyStringNoSession title, used to identify the Session
loginTokenQuery + BodyStringYesAuthentication Token obtained via GenerateAuthToken

Response Parameters

ParameterTypeDescription
successBooleanWhether the request was successful
dataIntegerThe sessionId of the newly created session

Request Example

POST /open/session/safe_new Content-Type: application/json { "tenantId": 10, "userId": 1, "domainId": 106, "title": "Q1 Sales Analysis", "loginToken": "eyJhbGciOiJIUzI1NiJ9..." }

Response Example

Successful response:

{ "success": true, "data": 4729 }

The value 4729 in data is the newly created sessionId.

Error Codes

Error CodeDescription
success=falseToken is invalid, parameters are missing, or insufficient permissions