Create session¶
Creates a visible session for the specified active agent. This interface only creates sessions and displays information, does not send messages, and does not start agent tasks.
POST $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/conversations
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First confirm that the target agent is active.
Set the operation-specific values used in the request:
$WORKSPACE_ID: Target workspace ID, passed through theX-Workspace-IDheader and asworkspace_idin the path.$AGENT_ID: target agent ID.
Request¶
curl -X POST "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/conversations" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"agent_id": "'"$AGENT_ID"'",
"title": "销售分析",
"purpose": "chat",
"pinned": false
}'
Path parameters
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Current workspace ID, must be consistent with |
Request body
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Target agent ID; target agent must be active. |
|
string |
No |
ID of the workspace to which the target agent belongs. If not provided, the current workspace is used; only the current workspace or the system workspace can be specified. |
|
string |
No |
Session ID. Generated by the server if not provided. |
|
string |
No |
Session title, length cannot exceed 256. |
|
string |
No |
Session state, can be |
|
string |
No |
Session usage, can be |
|
string |
No |
Session visibility. This interface only accepts |
|
boolean |
No |
Whether to pin the conversation to the top. |
The workspace_id, user_id, agent display name and avatar in the request are determined by the server based on the current identity, path and agent data, and do not need to be passed in. This interface does not accept hidden sessions, nor does it accept parent_conversation_id.
Successful response¶
Returns 201 on success. data is a newly created session; save data.id, which is used to read, update sessions and query saved messages.
{
"code": 0,
"data": {
"id": "conv_01",
"workspace_id": "ws_01",
"agent_workspace_id": "ws_01",
"agent_id": "agent_01",
"agent_summary": {
"id": "agent_01",
"display_name": "销售分析助手",
"available": true
},
"title": "销售分析",
"status": "active",
"purpose": "chat",
"visibility": "visible",
"pinned": false,
"created_at": "2026-01-02T15:04:05Z",
"updated_at": "2026-01-02T15:04:05Z"
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
Session ID. |
|
string |
ID of the workspace to which the session belongs. |
|
string |
ID of the workspace to which the target agent belongs. |
|
string |
Target agent ID. |
|
object |
Agent display summary; can contain |
|
string |
Session title; not returned if not set. |
|
string |
Current session status. |
|
string |
Current session usage. |
|
string |
Session visibility. |
|
boolean |
Whether to pin it to the top. |
|
string |
Recent message ID; does not return if there is no message yet. |
|
string |
Active task ID; not returned if there is no active task. |
|
string |
Last message time; does not return if there is no message yet. |
|
string |
Creation and last update times, in RFC 3339 format. |
|
string |
Creation and last update times, in RFC 3339 format. |
Error response¶
{
"code": 2,
"message": "请求参数无效",
"details": {
"cause": "invalid runtime conversation"
}
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body cannot be parsed, the agent workspace is not within the allowed range, or the session title, status, purpose, and visibility do not meet the requirements. |
Check the request fields; do not pass in a hidden session or parent session ID. |
|
|
The specified agent does not exist. |
Check |
|
|
The server cannot create a session or generate session display information. |
Record the request time and error message and try again. |
|
|
Session service is temporarily unavailable. |
Try again later. |
Follow-up operations¶
Use Query session messages to read messages that have been written during runtime. To send messages, use the agent call interface.