Skip to content

Send Events

POST/v1/sessions/{session_id}/events

Send one or more events to a session. Sending a user.message triggers the agent to run; user.interrupt stops a running agent.

Path Parameters

ParameterTypeRequiredDescription
session_idstringyesThe session ID (sess_...)

Request Parameters

ParameterTypeRequiredDescription
eventsarrayyesEvents to send to the session (at least one).

Input Event Types

user.message

Send a user message. This is the primary way to drive the agent.

FieldTypeRequiredDescription
typestringyes"user.message"
contentarrayyesArray of content blocks (see Content Blocks)
json
{
  "type": "user.message",
  "content": [
    { "type": "text", "text": "Where is my order #1234?" }
  ]
}

user.interrupt

Pause agent execution and return control to the user. The session transitions back to idle.

FieldTypeRequiredDescription
typestringyes"user.interrupt"
json
{ "type": "user.interrupt" }

Roadmap — tool result events

Claude also accepts user.tool_confirmation (approve/deny a tool call under an always_ask policy) and user.custom_tool_result (return a client-executed custom tool result). SandBase does not yet accept these event types — sending them returns 400 invalid_request. They will be added alongside tool permission policies and custom tools.

Content Blocks

Content blocks are used in user.message.

Text

json
{ "type": "text", "text": "Hello" }

Image

jsonc
// Base64
{ "type": "image", "source": { "type": "base64", "media_type": "image/png", "data": "iVBOR..." } }

// URL
{ "type": "image", "source": { "type": "url", "url": "https://example.com/img.png" } }

// File reference
{ "type": "image", "source": { "type": "file", "file_id": "file_01abc..." } }

Document

jsonc
// Base64 (e.g. PDF)
{ "type": "document", "source": { "type": "base64", "media_type": "application/pdf", "data": "JVBER..." } }

// Plain text
{ "type": "document", "source": { "type": "text", "media_type": "text/plain", "data": "..." } }

// URL
{ "type": "document", "source": { "type": "url", "url": "https://example.com/doc.pdf" } }

Optional fields on document blocks: title (string), context (string, extra context for the model).

Request Examples

python
from anthropic import Anthropic

client = Anthropic(
    api_key="sk-sb-YOUR_KEY",
    base_url="https://api.sandbase.ai"
)

result = client.beta.sessions.events.send(
    session_id="sess_01abc...",
    events=[
        {
            "type": "user.message",
            "content": [{ "type": "text", "text": "Where is my order #1234?" }]
        }
    ]
)
print(result.data)
bash
curl -X POST https://api.sandbase.ai/v1/sessions/sess_01abc.../events \
  -H "Authorization: Bearer sk-sb-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      { "type": "user.message", "content": [{ "type": "text", "text": "Where is my order #1234?" }] }
    ]
  }'

Response

Returns the events that were accepted, each with a server-assigned id and processed_at.

json
{
  "data": [
    {
      "id": "sevt_01abc...",
      "type": "user.message",
      "content": [{ "type": "text", "text": "Where is my order #1234?" }],
      "stop_reason": null,
      "model_used": null,
      "tokens_in": 0,
      "tokens_out": 0,
      "duration_ms": null,
      "processed_at": "2026-05-29T10:00:00Z",
      "created_at": "2026-05-29T10:00:00Z"
    }
  ]
}

After sending a user.message, subscribe to Stream Events to receive the agent's response, or poll List Events.

Errors

StatusTypeDescription
400invalid_requestInvalid event format, missing fields, or unsupported event type
401authentication_errorInvalid or missing API key
404not_foundSession not found
409conflictSession is not idle (running), or terminated