---
title: "Read a Caveman Code session"
method: GET
path: "/code/sessions/{sessionId}"
---

# Read a Caveman Code session

`GET /code/sessions/{sessionId}`

## Request

- Base URL: `https://api.caveman.so/api/v1`
- URL: `https://api.caveman.so/api/v1/code/sessions/{sessionId}`
- 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/{sessionId} 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.

## Response `200`

The session

- CodeSession: A Caveman Code session: the session, the workspace it runs in and what started it.
  - `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.
- `404`: Not a session this caller may see.
- `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)
