Send Event

Updated at:

Writes events to a session: user messages, interrupts, tool approvals, function result backfills, and outcome criteria declarations. The request body contains only the top-level input field, which is an array of events (length 1-50).

Prerequisites

A session must already be created. For details, see Create Session.

Endpoint

POST /sessions/{session_id}/events

The request body contains only one top-level field input, which is an array of events (length 1-50). Each event must contain at least role and type.

Request body structure

{
  "input": [
    { "role": "user", "type": "message", "content": [...] }
  ]
}

Client event types

type

role

Purpose and key fields

message

user

Sends a user message, triggering the agent to enter running state. Required field: content (array)

ContentBlock: message content

content is an array of ContentBlocks. Each block is distinguished by type and must use exactly one carrier.

type

Mutually exclusive fields

Description

text

text

Plain text

data

data (object)

Structured data (JSON). Server-side status events also use this carrier

Example: send a text message

curl -X POST "$AGENTSTUDIO_URL/sessions/sesn_01K8ZQX3/events" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": [
      {
        "role": "user",
        "type": "message",
        "content": [
          {"type": "text", "text": "分析 /mnt/session/uploads/sales.csv 中 Q3 的销售趋势"}
        ]
      }
    ]
  }'
client.sessions.events.send(
    "sesn_01K8ZQX3",
    events=[user_message("分析 /mnt/session/uploads/sales.csv 中 Q3 的销售趋势")],
)
client.sessions().events().send("sesn_01K8ZQX3",
    Collections.singletonList(
        ClientEvents.userMessage("分析 /mnt/session/uploads/sales.csv 中 Q3 的销售趋势")));

Response

200 OK returns the echo of successfully written events and the request ID:

{
  "data": [
    {
      "object": "message",
      "id": "msg_8f2a1c...",
      "created_at": "2025-10-24T08:15:30.123Z",
      "role": "user",
      "type": "message",
      "status": "completed",
      "content": [{"type": "text", "text": "..."}]
    }
  ],
  "request_id": "req_01K8ZQX..."
}

Response fields

Field

Type

Description

data

array<object>

Array of echoed successfully written events, aligned with the request input order

data[].object

string

Object type, always message

data[].id

string

Server-assigned message ID, format msg_<ULID>

data[].created_at

string

Server write time, ISO 8601

data[].role

string

Event role, echoes the user from the request

data[].type

string

Event type, echoes the message from the request

data[].content

array<object>

ContentBlock array, same structure as the request

request_id

string

Unique identifier for this request