Skip to content

List Sessions

GET/v1/sessions

List sessions for your organization, ordered most-recently-created first. Returns a page of Session objects with an opaque cursor for the next page.

Query Parameters

ParameterTypeRequiredDescription
agent_idstringFilter sessions created with this agent ID
agent_versionintegerFilter by agent version. Only applies when agent_id is also set.
statusesstring[]Filter by status. Repeat to match any of multiple: ?statuses=idle&statuses=running
include_archivedbooleanInclude archived sessions. Default false.
created_at_gtestringOnly sessions created at or after this RFC 3339 time.
created_at_ltestringOnly sessions created at or before this RFC 3339 time.
limitintegerPage size. Default 20, max 100.
pagestringOpaque cursor from a previous response's next_page.

Status Values

  • idle — Waiting for input
  • running — Agent is actively executing
  • rescheduling — Transient error, retrying
  • terminated — Session ended

Request Examples

python
from anthropic import Anthropic

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

page = client.beta.sessions.list(agent_id="agent_01HqR2k7...", limit=20)
for session in page.data:
    print(f"{session.id}{session.status}{session.title}")
bash
curl "https://api.sandbase.ai/v1/sessions?agent_id=agent_01HqR2k7...&statuses=idle&limit=20" \
  -H "Authorization: Bearer sk-sb-YOUR_KEY"

Response

json
{
  "data": [
    {
      "id": "sess_01abc...",
      "type": "session",
      "status": "idle",
      "title": "Research task",
      "agent_id": "agent_01HqR2k7...",
      "agent_version": 1,
      "environment_id": "env_01abc...",
      "usage": null,
      "metadata": {},
      "archived_at": null,
      "created_at": "2026-05-29T10:00:00Z",
      "updated_at": "2026-05-29T10:02:00Z"
    }
  ],
  "next_page": "page_eyJjIjoiMjAyNi0wNS0yOVQxMDowMDowMFoiLCJpIjoic2Vzc18wMSJ9"
}

Pagination

Results are ordered by created_at descending (ties broken by id). When more results exist, the response includes a next_page cursor; pass it back as the page parameter. When next_page is absent, you've reached the last page.

Errors

StatusTypeDescription
400invalid_requestInvalid page cursor or query parameters
401authentication_errorInvalid or missing API key