Send Event
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 |
|
|
|
Sends a user message, triggering the agent to enter |
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 |
|
|
|
Plain text |
|
|
|
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 |
|
|
array<object> |
Array of echoed successfully written events, aligned with the request |
|
|
string |
Object type, always |
|
|
string |
Server-assigned message ID, format |
|
|
string |
Server write time, ISO 8601 |
|
|
string |
Event role, echoes the |
|
|
string |
Event type, echoes the |
|
|
array<object> |
ContentBlock array, same structure as the request |
|
|
string |
Unique identifier for this request |