Sessions API

Sessions represent conversations with agents. They store conversation history, resources, and variables.

Create Session

Create a new agent session.

text

Request Body

json
FieldTypeRequiredDescription
agentIdstringYesAgent ID (the id field, not slug)
inputobjectNoInput variables for the agent

To get the agent ID, copy it from the platform URL, use Get Agent by slug (GET /api/agents/:slug?by=slug), or the SDK's agents.getBySlug() method.

Response

json

Example

bash

Get Session

Retrieve session state including UI-ready messages and resources.

text

Response

The response includes UIMessage objects that can be passed directly to the client SDK's initialMessages option:

json

UIMessage Parts

Messages contain typed parts that preserve content ordering:

Part TypeDescription
textText content with text and status fields
reasoningExtended reasoning with text and status fields
tool-callTool execution with toolCallId, toolName, displayName, args, result, status
operationInternal operations with operationId, name, operationType, status

Example

bash

Trigger Session

Execute a trigger on a session. Returns a Server-Sent Events stream.

text

Request Body

json
FieldTypeRequiredDescription
triggerNamestringYesName of the trigger to execute
inputobjectNoInput variables for the trigger
toolResultsarrayNoTool results for continuation (handled by SDK)

Response

Returns text/event-stream with SSE events:

text

Event Types

EventDescription
startStream started
finishExecution complete
errorError occurred
block-startExecution block started
block-endExecution block completed
text-startText generation started
text-deltaIncremental text content
text-endText generation ended
reasoning-startExtended reasoning started
reasoning-deltaReasoning content
reasoning-endExtended reasoning ended
tool-input-startTool call initiated
tool-input-deltaTool arguments streaming
tool-input-endTool arguments streaming ended
tool-input-availableTool input complete
tool-output-availableTool completed with result
tool-output-errorTool failed
tool-requestPlatform requesting tool execution
resource-updateResource value changed

Example

bash

Tool Continuation

When the agent calls external tools, you'll receive a tool-request event. Execute the tools and send results back:

json

The Server SDK handles this continuation pattern automatically.