Sessions API

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

All session endpoints require an API key with the Sessions permission.

Create Session

Create a new agent session.

text

Request Body

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

Getting the agent ID: Copy the ID from the agent URL in the platform (e.g., octavus.ai/agents/clxyz123), or use the CLI (octavus sync ./agents/my-agent) for local development workflows.

Response

json

Example

bash

Get Session

Retrieve session state. Returns UI-ready messages for active sessions, or expiration info for expired sessions.

text

Query Parameters

ParameterTypeDescription
formatstringOptional. Use format=ui for UI-ready messages only

Response (Active Session)

When the session is active, the response includes UIMessage objects:

json

Response (Expired Session)

When the session has expired, the response indicates the expiration status:

json

Use the Restore Session endpoint to restore an expired session from stored messages.

text

Restore Session

Restore an expired session from stored messages. This allows you to continue a conversation after the server-side state has expired.

text

Request Body

json
FieldTypeRequiredDescription
messagesUIMessage[]YesPreviously stored chat history
inputobjectNoSession input for system prompt interpolation (same as create)

Response

json
FieldTypeDescription
sessionIdstringThe session ID
restoredbooleantrue if restored from messages, false if session was already active

Example

bash

Note: Store the UIMessage[] array after each interaction to enable restoration. The restore endpoint reconstructs the conversation state from these messages.

Clear Session

Clear session state, transitioning it to expired status. The session can be restored afterwards with the Restore Session endpoint.

This is idempotent — clearing an already expired session succeeds without error.

text

Response

json

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
file-availableFile ready for display/download
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.

Upload URLs

Get presigned URLs for file uploads. Files are uploaded directly to S3.

text

Request Body

json
FieldTypeRequiredDescription
sessionIdstringYesSession ID to associate files with
filesarrayYesArray of file metadata (1-20 files)
files[].filenamestringYesOriginal filename
files[].mediaTypestringYesMIME type (e.g., image/png)
files[].sizenumberYesFile size in bytes

Response

json

Upload Flow

  1. Request upload URLs from the platform
  2. PUT file content to uploadUrl with Content-Type header
  3. Use downloadUrl as the url in FileReference
  4. Include FileReference in trigger input

Supported Types

CategoryMedia Types
Imagesimage/jpeg, image/png, image/gif, image/webp
Documentsapplication/pdf, text/plain, text/markdown, application/json

Limits

LimitValue
Max file size10 MB
Max total per request50 MB
Max files per request20
Upload URL expiry15 minutes
Download URL expiry24 hours