Levain LabsLevain Labs
ApiSessions

Cancel Session

Interrupt a session's in-flight turn.

Stops the current turn (if any) and lets the user send a follow-up message. The session itself stays alive — only the turn is cancelled — so build conversations remain resumable after the user changes their mind mid-build.

The cancellation event is recorded asynchronously, so this response echoes no events; poll GET /sessions/{id} to see the cancelled event land.

POST
/api/v1/sessions/{session_id}/cancel

Authorization

HTTPBearer
AuthorizationBearer <token>

In: header

Path Parameters

session_id*Session Id
Formatuuid

Header Parameters

X-API-Key?string|null

Response Body

application/json

application/json

curl -X POST "https://api.levainlabs.com/api/v1/sessions/497f6eca-6276-4993-bfeb-53cbbbba6f08/cancel"
{
  "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": {}
    }
  ]
}