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.

HTTP
POST $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/conversations

Before you call

Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First query the agent list to confirm that the target agent is active. Obtain the agent ID and the workspace ID to which the agent belongs from the same list item. Save the two return values ​​as AGENT_ID and AGENT_WORKSPACE_ID respectively.

Request body

The example uses jq to construct the JSON request body. Install jq first and set the required environment variables. Do not JSON encode the variable values ​​again.

Purpose also accepts agent_authoring. The system agent conditions for workflow purposes apply individually, and it cannot be inferred from the purpose name that all agents can be used for creation.

Shell
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' \
  --data-binary "$(jq -n --arg AGENT_ID "$AGENT_ID" --arg AGENT_WORKSPACE_ID "$AGENT_WORKSPACE_ID" '
{
  "agent_id": $AGENT_ID,
  "agent_workspace_id": $AGENT_WORKSPACE_ID,
  "title": "销售分析",
  "purpose": "chat",
  "pinned": false
}
')"

Omit optional fields

Shell
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' \
  --data-binary "$(jq -n --arg AGENT_ID "$AGENT_ID" '
{
  "agent_id": $AGENT_ID,
  "title": "销售分析",
  "purpose": "chat",
  "pinned": false
}
')"

Path parameters

Field

Type

Required

Description

workspace_id

string

Yes

The current workspace ID must be consistent with X-Workspace-ID.

Request body

Field

Type

Required

Description

agent_id

string

Yes

Target agent ID. The target agent must be active.

agent_workspace_id

string

No

The workspace ID to which the target agent definition belongs. Use the workspace_id returned by the same item in the agent list. If not provided, the current workspace is used.

id

string

No

Session ID. Generated by the server if not provided.

title

string

No

Session title, the length cannot exceed 256.

status

string

No

Session state, which can be active or archived. active when not provided.

purpose

string

No

Session usage, which can be chat, workflow, or agent_authoring. chat when not provided. workflow only applies to system workflowagent.

visibility

string

No

Session visibility. This interface only accepts visible. Visible when not provided.

pinned

boolean

No

Whether to pin the conversation to the top.

Successful response

JSON
{
  "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",
    "title_user_edited": false
  }
}

Field

Type

Description

code

integer

success code.

data

object

The data returned by this operation.

data.id

string

Session ID.

data.workspace_id

string

The workspace ID to which the session belongs.

data.agent_workspace_id

string

Workspace ID to which the target agent belongs.

data.agent_id

string

Target agent ID.

data.agent_summary

object

agent displays summary. Can contain id, display_name, avatar_ref, status, available, and unavailable_reason.

data.agent_summary.id

string

ID of the current object.

data.agent_summary.workspace_id

string

The workspace ID to which it belongs.

data.agent_summary.display_name

string

Display name.

data.agent_summary.avatar_ref

string

Avatar Quotes.

data.agent_summary.status

string

status.

data.agent_summary.available

boolean

is available.

data.agent_summary.unavailable_reason

string

Reason for unavailability.

data.title

string

Title text.

data.title_user_edited

boolean

Whether the title is editable by the user.

data.status

string

Current session state. The values are active, archived

data.purpose

string

Current session usage. The values are chat, agent_authoring, workflow

data.visibility

string

Session visibility. The values are visible, hidden

data.parent_conversation_id

string

Association ID.

data.pinned

boolean

Whether to pin it to the top.

data.head_message_id

string

Recent message ID. Do not return if there is no message yet.

data.active_task_id

string

Activity task ID. Does not return when there are no active tasks.

data.latest_task_id

string

Recent task ID.

data.latest_task_state

string

Most recent task status: submitted, queued, working, input_required, auth_required, completed, failed, canceled, rejected, cancel_requested, reconciling.

data.last_message_at

string

Most recent message time in RFC 3339 format. Omitted when there are no messages.

data.created_at

string

Creation and last update times, in RFC 3339 format.

data.updated_at

string

Creation and last update times, in RFC 3339 format.

Error response

If querying the session summary fails after saving, the endpoint still returns an error even though the session may have been saved. Query existing sessions before retrying creation or archiving. Supplying your own session ID does not guarantee a repeated submission will succeed.

JSON
{
  "code": 2,
  "message": "请求参数无效",
  "details": {
    "cause": "invalid runtime conversation"
  }
}

Common HTTP errors

HTTP status

Error code

Common cause

Recommended action

400

2

Invalid request field, workspace, or operation precondition.

Fix the request parameters and submit again.

401

6

Missing or invalid authentication credentials.

Check the credential type, expiration, and authentication header.

403

5

The current identity or active role does not have permission for this operation.

Use an authorized identity or contact an administrator to grant access.

404

3

The target object or required reference was not found.

Verify the object identifier, workspace, and current status.

500

1

Internal processing failed; write operations may have been partially applied.

Retain request and trace details, and verify the current state before retrying.

503

15

A business, runtime, or authorization dependency is temporarily unavailable.

After the dependency recovers, check existing results first instead of blindly repeating writes.

Last updated on