---
title: "List Caveman Code sessions"
method: GET
path: "/code/sessions"
---

# List Caveman Code sessions

`GET /code/sessions`

## Request

- Base URL: `https://api.caveman.so/api/v1`
- URL: `https://api.caveman.so/api/v1/code/sessions`
- Auth: one of:
  - OAuth 2
    - Authorization code: `/api/v1/oauth/authorize`
    - Token URL: `/api/v1/oauth/token` scopes: `code:read`
  - HTTP bearer
  - API key in cookie `cave_access`
  - API key in cookie `__Secure-cave_identity.session_token`

GET /api/v1/code/sessions on the Caveman Cloud control plane. Requires the code:read scope. Not exposed to autonomous agents: Caveman Code's registry is driven by the Code app and the runtimes it enrolls. An agent works inside a Code session and reaches its tree through the session mailbox, never by listing, starting or archiving workspaces or enrolling runtimes from a control-plane connection.

## Query parameters

- `workspace_id` string, uuid
- `origin` 'person' | 'api' | 'automation'
- `agent_id` string, uuid

## Response `200`

Sessions, newest first

- object
  - `sessions` CodeSession[], required
    - `id` string, uuid, required
    - `organization_id` string, uuid
    - `workspace_id` string, uuid, required
    - `computer_id` string, uuid, nullable
    - `origin` 'person' | 'api' | 'automation', required
    - `service_account_id` string, uuid, nullable
    - `agent` object, nullable
      - `id` string, uuid, required
      - `version` integer, required
    - `repo` string
    - `branch` string
    - `engine` string
    - `model` string
    - `title` string
    - `status` 'starting' | 'running' | 'requires_action' | 'idle' | 'terminated', required
    - `stop_reason` 'end_turn' | 'requires_action' | 'budget_reached' | 'error' | 'interrupted' | 'null', nullable
    - `usage` object, required
      - `input_tokens` integer, required
      - `output_tokens` integer, required
      - `cache_read_tokens` integer, required
      - `cost_usd` number, required: Measured: the sum of the calls that carried a cost.
      - `cost_priced` boolean, required: False once a call with tokens carried no cost (a subscription login, or a model with no price): cost_usd is then only the priced part.
    - `pull_requests` object[], required
      - `url` string, required
      - `state` string, required
    - `created_at` string, date-time, required
    - `updated_at` string, date-time, required
    - `ended_at` string, date-time, nullable
    - `metadata` object, required

## Other responses

- `401`: A person's sign-in or a code:run key is required.
- `403`: The role, the key's scope, or an inactive service account (cave_code_service_account_inactive) refuses.
- `2XX`: Successful response. Exact status depends on synchronous or durable delivery outcome.
- `4XX`: Structured failure. `error.code` is stable; `error.request_id` is echoed in the x-cave-request-id header.
- `5XX`: Structured failure. `error.code` is stable; `error.request_id` is echoed in the x-cave-request-id header.

---

[API](https://skmtc.dev/caveman/apis/caveman-cloud-api.md) - [All operations](https://skmtc.dev/caveman/apis/caveman-cloud-api/llms.txt) - [OpenAPI document](https://skmtc.dev/caveman/apis/caveman-cloud-api/revisions/508312d01cfc?raw)
