ApiSessions
Send Message
Append a user message to a session and run a turn.
Returns immediately with just the newly-appended user_message event echoed
back; the agent runs asynchronously. To watch the turn unfold, poll
GET /sessions/{id}/events?since=N for incremental events or
GET /sessions/{id}?since=N for the full snapshot.
Sessions accept new messages regardless of state. Idle sessions (no recent activity) resume on demand; cancelling a session interrupts the in-flight turn but leaves the session live for a follow-up.
Authorization
HTTPBearer AuthorizationBearer <token>
In: header
Path Parameters
session_id*Session Id
Format
uuidHeader Parameters
X-API-Key?string|null
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
curl -X POST "https://api.levainlabs.com/api/v1/sessions/497f6eca-6276-4993-bfeb-53cbbbba6f08/messages" \ -H "Content-Type: application/json" \ -d '{}'{
"id": "string",
"agent_id": "string",
"agent_version_id": "string",
"state": "string",
"created_at": "string",
"last_activity_at": "string",
"terminated_at": "string",
"rounds": [],
"events": []
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string",
"input": null,
"ctx": {}
}
]
}