CreateAgentSession

更新时间:
复制 MD 格式

Creates a new agent session and returns a session ID.

Operation description

Description

  • This API creates a new agent session.

  • You must specify the agent name to bind to the session using the _meta.agent.agentName parameter.

  • You can specify a session source identifier in the _meta.config.sessionSource parameter. This allows you to search for sessions by source later.

  • You can add session tags using the _meta.config.sessionTags[].sessionTagCode parameter.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST  HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

Jsonrpc

string

No

The JSON-RPC version. The value is fixed at 2.0.

2.0

Id

string

No

The request ID provided by the client. This ID is returned in the response without modification.

4758330557805415712

Params

object

No

The business parameters.

Meta

object

No

The extended metadata, which includes information such as agent binding, session source, and session tags.

Agent

object

No

The agent configuration for this session. The value must be one of the agents returned by the ListAgents API.

AgentName

string

No

The agent name to bind to the session. This parameter is required.

chat_cli_chatbi

Config

object

No

The configuration parameters for the session, such as filters based on session source and session tags.

SessionSource

string

No

The identifier for the session source. This allows you to search for sessions by their source. For example, if you use an agent on multiple pages, such as Page A and Page B, you can use this parameter to filter and display only the sessions created on Page A. The identifier can be up to 128 characters and can contain letters, digits, hyphens (-), and underscores (_).

openapi_sdk

SessionTags

array<object>

No

A list of session tags. You can use these tags to search and filter sessions.

object

No

SessionTagCode

string

No

The session tag. You can use session tags to filter sessions. For example, if your application calls the API with a fixed RAM sub-account but maintains its own user account system, you can pass a user's account ID as a tag. This allows you to filter the session list by your internal account IDs. The tag can be up to 128 characters and can contain letters, digits, hyphens (-), and underscores (_).

chatbi

Response elements

Element

Type

Description

Example

object

The response parameters.

RequestId

string

The ID of the request.

8A9D5E6C-5817-5837-9715-6E3967EC6123

JsonRpcResponse

object

The JSON-RPC response.

Jsonrpc

string

The JSON-RPC version. The value is fixed at 2.0.

2.0

Id

string

The request ID provided by the client. This ID is returned in the response without modification.

1

Result

object

The business data. This field is null if an error occurs.

SessionId

string

The ID of the created session.

sess_0f12abc34

Examples

Success response

JSON format

{
  "RequestId": "8A9D5E6C-5817-5837-9715-6E3967EC6123",
  "JsonRpcResponse": {
    "Jsonrpc": "2.0",
    "Id": "1",
    "Result": {
      "SessionId": "sess_0f12abc34"
    }
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.