{
  "openapi": "3.1.0",
  "info": {
    "title": "Context Agent API",
    "version": "1",
    "description": "Run Context agents from your own code: start a session, follow it live, approve its tool calls and read the result.\n\nYour deployment is the Context instance your organization signs in to. The base URL is its host plus `/v1`, for example `https://api.context.ai/v1`. Request and response bodies are JSON, except for file upload (`multipart/form-data`), file download (raw bytes) and the event stream (server-sent events)."
  },
  "servers": [
    {
      "url": "https://api.context.ai"
    }
  ],
  "security": [
    {
      "ManagedAgentsKey": []
    }
  ],
  "tags": [
    {
      "name": "Agents",
      "description": "An agent is the configured worker that a session runs. You can create and edit agents in the Context app or with this API, which follows Anthropic's Managed Agents API with the differences listed at the end of this page. An agent you create with the API appears in the Context app, and the owner of the API key owns it.\n\n> **Note:** To create or update an agent, you must use a [personal key](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities) with the `agents:write` capability.\n\n### The agent object\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | The agent's ID. Pass it as `agent` when you [create a session](https://docs.context.ai/build/agent-api/openapi/sessions#create-a-session). |\n| `type` | `string` | Always `agent`. |\n| `name` | `string` | The agent's name, as shown in the app. |\n| `description` | `string \\| null` | The agent's purpose. `null` when the agent has no description. |\n| `model` | `object` | The model the agent is **set to**, as an object with one field, `id`. The ID is `default` when the agent leaves the choice to your deployment, so this field does not name a model in that case. [`GET /v1/models`](https://docs.context.ai/build/agent-api/openapi/agents#list-models) lists the IDs you can set. |\n| `effective_model` | `object \\| null` | The model a session of this agent **would start on now**, as an object with one field, `id`. Read-only. This is what to show a person who asks which model an agent runs on. `null` when a session would be refused a model. |\n| `system` | `string \\| null` | The agent's instructions. They are returned only to a personal key with `agents:write` whose owner created the agent and still owns it. Any other key gets `null`. If the agent has no instructions, that key gets `\"\"`. |\n| `tools` | `array` | The agent's built-in tools, as one `agent_toolset_20260401` entry that lists all eight tools with their `enabled` and `permission_policy`. The list is empty when every built-in tool is off. |\n| `skills` | `array` | The agent's skills, each `{type, skill_id, version}`. A built-in skill has `type` `anthropic` and its slug as `skill_id`. A custom skill has `type` `custom` and its skill ID. `version` is always `latest`. |\n| `created_at` | `string` | When the agent was created, as an RFC 3339 timestamp. |\n| `updated_at` | `string` | When the agent was last changed, as an RFC 3339 timestamp. |\n\nEach built-in tool maps to its approval setting in the app. `always_allow` is **Allow**, `always_ask` is **Ask**\n(each call waits for a person to approve it), and `enabled: false` is **Deny**. `edit` and `write` share one\nsetting in the app, so they always read the same. `web_search` is always off, because agents search the web with\nyour deployment's own search tool. A tool that is off reads `always_ask`.\n\n`model` and `effective_model` answer two different questions, and both are needed. `model` is the stored choice,\nwhich a write round-trips; `effective_model` is the resolution, which no write accepts. They differ whenever `model`\ndoes not name the model that will run: an agent set to `default`, and an agent whose stored model your deployment no\nlonger serves.\n\n`effective_model` is resolved the way a session resolves it, by taking the first of these your deployment can serve:\n\n1. the agent's own model, when it is still in the catalog;\n2. a model **you** connected through your own subscription, if you have one;\n3. your deployment's default model.\n\nTwo consequences worth knowing. Because of rung 2, `effective_model.id` is usually one of the IDs\n[`GET /v1/models`](https://docs.context.ai/build/agent-api/openapi/agents#list-models) lists but need not be — that list is your\ndeployment's and leaves out models reached through a person's own connected account. And it is the answer for a\nsession created through this API, which runs in your deployment's cloud; a session on a paired computer chooses from\nthat computer's own models.\n\n`null` means a session would be refused a model rather than \"no model configured\": either the catalog serves nothing,\nor the deployment's configured default is not in it.\n\n> **Note:** `effective_model` cannot be sent on a create or update. Posting a whole agent object back is refused with\n> `400` naming it, along with the other read-only fields — so a client that round-trips an agent can never turn one that\n> was following your deployment's default into a pinned one by accident.\n\nSome fields always hold the same value: `version` is 1, `mcp_servers` is empty, `metadata` is `{}` (the `workspace_id` sent on create is not stored), `multiagent` and `archived_at` are null, and `execution_identity` is `{type: \"service_account\"}`.\n\n**Example**\n\n```json\n{\n  \"id\": \"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\",\n  \"archived_at\": null,\n  \"created_at\": \"2026-10-21T01:35:05.337Z\",\n  \"description\": \"Answers questions about the sales pipeline\",\n  \"execution_identity\": {\n    \"type\": \"service_account\"\n  },\n  \"mcp_servers\": [],\n  \"metadata\": {},\n  \"model\": {\n    \"id\": \"default\"\n  },\n  \"multiagent\": null,\n  \"name\": \"Research Assistant\",\n  \"skills\": [\n    {\n      \"type\": \"anthropic\",\n      \"skill_id\": \"xlsx\",\n      \"version\": \"latest\"\n    }\n  ],\n  \"system\": null,\n  \"tools\": [\n    {\n      \"type\": \"agent_toolset_20260401\",\n      \"default_config\": {\n        \"enabled\": true,\n        \"permission_policy\": {\n          \"type\": \"always_ask\"\n        }\n      },\n      \"configs\": [\n        {\n          \"type\": \"bash\",\n          \"name\": \"bash\",\n          \"enabled\": true,\n          \"permission_policy\": {\n            \"type\": \"always_ask\"\n          }\n        },\n        {\n          \"type\": \"edit\",\n          \"name\": \"edit\",\n          \"enabled\": true,\n          \"permission_policy\": {\n            \"type\": \"always_ask\"\n          }\n        },\n        {\n          \"type\": \"read\",\n          \"name\": \"read\",\n          \"enabled\": true,\n          \"permission_policy\": {\n            \"type\": \"always_allow\"\n          }\n        },\n        {\n          \"type\": \"write\",\n          \"name\": \"write\",\n          \"enabled\": true,\n          \"permission_policy\": {\n            \"type\": \"always_ask\"\n          }\n        },\n        {\n          \"type\": \"glob\",\n          \"name\": \"glob\",\n          \"enabled\": true,\n          \"permission_policy\": {\n            \"type\": \"always_allow\"\n          }\n        },\n        {\n          \"type\": \"grep\",\n          \"name\": \"grep\",\n          \"enabled\": true,\n          \"permission_policy\": {\n            \"type\": \"always_allow\"\n          }\n        },\n        {\n          \"type\": \"web_fetch\",\n          \"name\": \"web_fetch\",\n          \"enabled\": true,\n          \"permission_policy\": {\n            \"type\": \"always_ask\"\n          },\n          \"url_sources\": null\n        },\n        {\n          \"type\": \"web_search\",\n          \"name\": \"web_search\",\n          \"enabled\": false,\n          \"permission_policy\": {\n            \"type\": \"always_ask\"\n          }\n        }\n      ]\n    }\n  ],\n  \"type\": \"agent\",\n  \"updated_at\": \"2026-10-21T01:35:05.337Z\",\n  \"version\": 1\n}\n```\n\n### Differences from Anthropic's API\n\nThis API follows Anthropic's Managed Agents API, with these differences:\n\n- The agent version and archive endpoints return `404`. Every agent has one version, `1`, and an update changes it\n  in place, so a later update overwrites an earlier one without an error. In an update, `version` must be `1`.\n- The `model` object has only an `id` field. `effort`, `inference_geo` and `speed` return `400`.\n- `system` is `null` unless the key is a personal key with `agents:write` whose owner created the agent and still\n  owns it.\n- `tools` takes the built-in toolset and custom tools; a custom tool is answered by your client or by a paired\n  computer that advertises it, whichever is first. MCP servers, the `auto` permission policy and the domain\n  and location options of the web tools return `400`. `web_search` is always off. To give an agent MCP servers or\n  connected accounts, set them up in the Context app.\n- Skills take `latest` as their only version.\n- `multiagent` and any `execution_identity` other than `{type: \"service_account\"}` return `400`.\n- To create an agent in a workspace, send `metadata.workspace_id` or the `anthropic-workspace-id` header. If you send\n  both, they must name the same workspace, or the request returns `400`.\n\nFor every difference in one place, see [Coming from Anthropic's API](https://docs.context.ai/build/agent-api/coming-from-anthropic)."
    },
    {
      "name": "Environments",
      "description": "An environment is where a session runs. You choose one rather than create one. The one environment is `env_default`, which runs each session in the cloud, wherever the platform places it. Nothing about it can be configured over this API. Remote sandbox support is on the roadmap.\n\nPass `env_default` as `environment_id` when you [create a session](https://docs.context.ai/build/agent-api/openapi/sessions#create-a-session).\n\n### Anthropic compatibility\n\nAnthropic's SDKs also have `environments.create`, `update`, `delete` and `archive`. Code written for Anthropic's\nAPI often creates an environment before its first session. This API handles those calls as follows:\n\n- `POST /v1/environments` (`environments.create`) creates nothing, so it has no page of its own here; the API\n  reference the server serves lists it as **Create an environment**. It exists so that Anthropic SDK code runs\n  unchanged. The key must have `tasks:create`. With no `config`, or a `cloud` config with\n  unrestricted networking and no packages, it returns `200` with `env_default`. It ignores `name`, `description`\n  and `metadata`. Any other `config` returns `400 invalid_request_error`, as does any\n  field this API doesn't accept, such as `scope`.\n- Updating, deleting or archiving an environment returns `404 not_found_error`, because this API does not serve\n  those paths.\n\nThe only environment is `env_default`. Remote sandbox support is on the roadmap.\n\n### Network access\n\nEvery environment reports `networking.type` as `unrestricted`, which is the only value the API accepts.\n`unrestricted` means the session's sandbox can reach the public internet, unless your deployment restricts it (see\nthe note below). Model calls are separate. Context handles them, and the sandbox's network access doesn't govern them. Nothing you set\nthrough the API changes network access.\n\n> **Note:** Self-hosted (KOTS) deployments can restrict sandbox outbound traffic to a list of allowed domains. It's a\n> setting in the KOTS Admin Console, not in the API. Your administrator turns on **Sandbox Egress Proxy (domain\n> allowlist)** and lists the domains in **Sandbox Egress Proxy Allowlist**, or turns off **Sandbox Internet Access**.\n> With **Sandbox Workload Identity** on, the same choice is **Sandbox Egress Posture**, set to **Open internet**,\n> **Domain allowlist** or **Workspace only**. The API's `networking` label doesn't reflect this setting, so environments\n> report `unrestricted` even when the install is tighter. To set it up, ask your Context contact.\n\nA create with `limited` networking, `packages` or any other custom `config` returns `400`:\n\n```json\n{\n  \"type\": \"error\",\n  \"error\": {\n    \"type\": \"invalid_request_error\",\n    \"message\": \"This deployment serves one environment (cloud, unrestricted networking, no extra packages); a custom environment config is not supported\"\n  },\n  \"request_id\": \"a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d\"\n}\n```\n\n`limited` networking is on the [Roadmap](https://docs.context.ai/build/agent-api/roadmap#locked-down-environments).\n\n### The environment object\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | Always `env_default`. |\n| `type` | `string` | Always `environment`. |\n| `name` | `string` | Always `default`. |\n| `description` | `string` | A one-line description. |\n| `config` | `object` | An object whose `type` is `cloud`. It also holds `networking`, always `unrestricted`, and `packages`, always empty. |\n| `created_at` | `string` | When the environment was created, as an RFC 3339 timestamp. |\n| `updated_at` | `string` | When the environment last changed, as an RFC 3339 timestamp. |\n\nSome fields always hold the same value: `metadata` is `{}` and `archived_at` is null. Treat the following values on `env_default` as placeholders, because they don't describe the real environment. Its `description` is a fixed string. Its `config` always reports `networking: unrestricted` and empty `packages`. If a self-hosted install restricts sandbox network access in the KOTS Admin Console, `config` doesn't show that yet.\n\n**Example**\n\n```json\n{\n  \"id\": \"env_default\",\n  \"archived_at\": null,\n  \"config\": {\n    \"type\": \"cloud\",\n    \"networking\": {\n      \"type\": \"unrestricted\"\n    },\n    \"packages\": {\n      \"apt\": [],\n      \"cargo\": [],\n      \"gem\": [],\n      \"go\": [],\n      \"npm\": [],\n      \"pip\": []\n    }\n  },\n  \"created_at\": \"2026-10-14T00:00:00.000Z\",\n  \"description\": \"The platform's own runtime. Every session runs here.\",\n  \"metadata\": {},\n  \"name\": \"default\",\n  \"type\": \"environment\",\n  \"updated_at\": \"2026-10-14T00:00:00.000Z\"\n}\n```"
    },
    {
      "name": "Sessions",
      "description": "A session is a task you start over the API.\n\nA session is a task you start over the API, and it shows in the Context app like any other task. The owner of the key that created it owns the task. A service account key can name another member as the owner with the `x-context-owner-user-id` or `x-context-owner-user-email` header. The task has the same transcript and tool permissions as a task started in the app. A session ends when you archive it, and its history stays readable. Nothing deletes a session for you: your deployment keeps it until you delete it. To remove a session and its data permanently, delete it with a key that has `sessions:delete`, which keys don't have by default (see [Choosing a key](https://docs.context.ai/build/agent-api/choosing-a-key)). To send messages to a session and stream the agent's replies, see [Events](https://docs.context.ai/build/agent-api/openapi/events).\n\nNot every task is a session. A task is a session only when it is a top-level task (not a subagent's), runs on Context's own agent engine and was started over an API: by this API, by the Task API (`POST /api/v1/tasks`) or by a schedule. A task someone started in the app is not a session, even though it is the same kind of task: `GET /v1/sessions/{session_id}` returns `404` for it, and [List sessions](https://docs.context.ai/build/agent-api/openapi/sessions#list-sessions) leaves it out. So a session you create here can also be read with the Task API, under the same ID, but a task started in the app can't be picked up with this API.\n\n### Status\n\n| `status` | Meaning |\n|---|---|\n| `idle` | The session is waiting for a message or a tool approval, or hasn't started. |\n| `running` | A turn is in progress. |\n| `terminated` | The session is archived. Nothing else terminates a session. |\n| `rescheduling` | This status is never returned. [List sessions](https://docs.context.ai/build/agent-api/openapi/sessions#list-sessions) accepts it as a `statuses` filter, which then matches nothing. |\n\n### The session object\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | The session's ID, a UUID. It is also the task's ID in the app. |\n| `type` | `string` | Always `session`. |\n| `status` | `string` | The session's status. One of `idle`, `running` or `terminated`. See [Status](https://docs.context.ai/build/agent-api/openapi/sessions). |\n| `title` | `string \\| null` | The session's title. The maximum length is 280 characters. |\n| `agent` | `object` | The agent the session runs, as in [Agents](https://docs.context.ai/build/agent-api/openapi/agents) without its timestamps and `metadata`. |\n| `environment_id` | `string` | Where the session runs: `env_default`. See [Environments](https://docs.context.ai/build/agent-api/openapi/environments). |\n| `max_step_minutes` | `integer \\| null` | A Context extension. The longest one step of this session may run, in minutes, set when the session was created. See [Create a session](https://docs.context.ai/build/agent-api/openapi/sessions#create-a-session). `null` means no step limit runs: a session on a paired computer, or one created before this field existed. |\n| `resources` | `array<object>` | The files attached when the session was created, each `{id, type: \"file\", file_id, mount_path, created_at, updated_at}`. If you sent a `mount_path`, this is the file's absolute path on the agent's disk. Otherwise it is `inputs/<filename>`, in the session's `inputs/` folder. `id` equals `file_id`. |\n| `usage` | `object` | The totals for the whole session, subagents included: `input_tokens`, `output_tokens`, `cache_read_input_tokens`, `cache_creation`, `active_seconds` and `list_cost`. |\n| `usage.cache_creation` | `object` | Cache-write tokens, as `{ephemeral_5m_input_tokens, ephemeral_1h_input_tokens}`. `ephemeral_1h_input_tokens` is always `0`, because every cache write counts as a 5-minute write. |\n| `usage.active_seconds` | `number` | The seconds the session spent working, to the millisecond. Time spent waiting for a tool approval isn't counted. While a turn runs, the value grows on every read. |\n| `usage.list_cost` | `object \\| null` | The session's cost at list price, as `{amount, currency: \"USD\"}`. `amount` is a whole number of cents, as a string. It covers model calls plus web search, image search and media generation, priced for the session's owner. See the list below the table for when it is `null`. |\n| `created_at` | `string` | When the session was created, as an RFC 3339 timestamp. |\n| `updated_at` | `string` | When the session last changed, as an RFC 3339 timestamp. |\n| `archived_at` | `string \\| null` | For an archived session, the time it last changed, as an RFC 3339 timestamp. That is when it was archived, unless it was renamed after, which sets it to the time of the rename. `null` for a session that isn't archived. |\n\n`usage.list_cost` is `null` in these cases:\n\n- A turn is running. A cost shown earlier returns to `null` while a later turn runs.\n- Billing hasn't settled, which takes about 12 minutes after the session goes idle.\n- No model call was made.\n- Your organization counts usage in tokens.\n\nOnce it appears, `usage.list_cost` can still rise. A model call made outside a turn, such as one by a background\njob the agent started, is added when billing records it.\n\nSome fields always hold the same value: `budget` is `null`, `metadata` and `stats` are `{}`, and `outcome_evaluations` and `vault_ids` are empty.\n\n**Example**\n\n```json\n{\n  \"id\": \"dd13d728-93e3-440a-874c-4efeb58c97e0\",\n  \"agent\": {\n    \"id\": \"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\",\n    \"description\": \"Answers questions about the sales pipeline\",\n    \"execution_identity\": {\n      \"type\": \"service_account\"\n    },\n    \"mcp_servers\": [],\n    \"model\": {\n      \"id\": \"default\"\n    },\n    \"multiagent\": null,\n    \"name\": \"Research Assistant\",\n    \"skills\": [],\n    \"system\": null,\n    \"tools\": [],\n    \"type\": \"agent\",\n    \"version\": 1\n  },\n  \"archived_at\": null,\n  \"budget\": null,\n  \"created_at\": \"2026-10-21T01:42:16.079Z\",\n  \"environment_id\": \"env_default\",\n  \"max_step_minutes\": 240,\n  \"metadata\": {},\n  \"outcome_evaluations\": [],\n  \"resources\": [\n    {\n      \"id\": \"329409ba-f288-4b44-9c73-14a18150edee\",\n      \"created_at\": \"2026-10-21T01:41:11.028Z\",\n      \"file_id\": \"329409ba-f288-4b44-9c73-14a18150edee\",\n      \"mount_path\": \"inputs/cities.csv\",\n      \"type\": \"file\",\n      \"updated_at\": \"2026-10-21T01:41:11.028Z\"\n    }\n  ],\n  \"stats\": {},\n  \"status\": \"idle\",\n  \"title\": \"Quarterly city report\",\n  \"type\": \"session\",\n  \"updated_at\": \"2026-10-21T01:42:29.719Z\",\n  \"usage\": {\n    \"input_tokens\": 12,\n    \"output_tokens\": 318,\n    \"cache_read_input_tokens\": 133496,\n    \"cache_creation\": {\n      \"ephemeral_5m_input_tokens\": 2210,\n      \"ephemeral_1h_input_tokens\": 0\n    },\n    \"active_seconds\": 7.331,\n    \"list_cost\": {\n      \"amount\": \"6\",\n      \"currency\": \"USD\"\n    }\n  },\n  \"vault_ids\": []\n}\n```\n\n### Differences from Anthropic's API\n\nThis API follows Anthropic's Managed Agents API, with these differences:\n\n- Deleting a session needs the `sessions:delete` capability, which keys don't have by default. Deleting a session\n  while a turn runs returns `409`: interrupt the turn, wait for `idle`, then delete it. The delete response lists\n  what was removed and what was kept. See [Delete a session](https://docs.context.ai/build/agent-api/openapi/sessions#delete-a-session).\n- `POST /v1/sessions` takes `x-context-owner-user-id` or `x-context-owner-user-email`, so a service account key can\n  create a session for another member. Anthropic's API has no such headers.\n- `POST /v1/sessions` returns `400` if the request overrides an agent field (any field in the `agent` object\n  besides `type`, `id` and `version`), or sends a non-empty `metadata`, a non-empty `vault_ids` or a non-null\n  `budget`.\n- `initial_events` takes at most one event, a `user.message`. Anthropic's API takes up to 50 events of different\n  types.\n- Only `file` resources are supported. Any other type returns `400`.\n- A file sent without `mount_path` isn't placed on the agent's disk. Anthropic's API copies it to\n  `/mnt/session/uploads/<file_id>`. Here it stays in the session's `inputs/` folder in Drive, where the agent reads\n  it, and its `mount_path` reads `inputs/<filename>`.\n- `mount_path` takes a path under `/workspace/` or `/mnt/session/uploads/`. Any other absolute path is placed under\n  `/mnt/session/uploads`: `/data/a.csv` becomes `/mnt/session/uploads/data/a.csv`, and `mount_path` reports the\n  new path.\n- `usage.server_tool_use` isn't sent.\n- `title` takes up to 280 characters, and a session takes up to 50 files. Anthropic's API allows 500 of each.\n- A list response holds at most 100 sessions per page. Anthropic's API allows up to 1,000.\n- On list, `order=asc` and the `agent_version`, `deployment_id` and `memory_store_id` filters return `400`.\n\nFor every difference in one place, see [Coming from Anthropic's API](https://docs.context.ai/build/agent-api/coming-from-anthropic)."
    },
    {
      "name": "Events",
      "description": "Everything that happens in a session is an event: your messages, the agent's replies and tool calls, and status changes. You send events to steer the session and read them from the history or a live stream. The events follow Anthropic's Managed Agents API, with the differences listed at the end of this page.\n\n### The event object\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | The event's ID, in the form `sevt_<seq>_<index>`. |\n| `type` | `string` | One of the types below. |\n| `processed_at` | `string \\| null` | When the event was processed, as an RFC 3339 timestamp. It is `null` only on send receipts. |\n\nEach type adds its own fields, listed in [Event types](https://docs.context.ai/build/agent-api/openapi/events).\n\nIDs sort in the order the events happened. Compare them by their numbers, not as strings: `sevt_10_0` comes after\n`sevt_9_0`. To resume after an event, pass its ID as `page` on [List events](https://docs.context.ai/build/agent-api/openapi/events#list-events)\nor as the `Last-Event-ID` header on the [stream](https://docs.context.ai/build/agent-api/openapi/events#stream-events).\n\nWhen you send an event, the response holds a send receipt: an event object with an ID of the form\n`sevt_receipt_<uuid>` and a null `processed_at`. The receipt's ID is not the ID of the stored event. The stored\nevent, with its real ID, then appears on the stream and in the history.\n\n**Example**\n\n```json\n{\n  \"type\": \"agent.message\",\n  \"id\": \"sevt_40_0\",\n  \"processed_at\": \"2026-10-21T01:42:24.003Z\",\n  \"content\": [\n    {\n      \"type\": \"text\",\n      \"text\": \"The output is `first`.\"\n    }\n  ]\n}\n```\n\n### Event types\n\nTypes are named `<source>.<action>`. The session uses the 13 types below. More types might be added, so skip any type you do not recognize.\n\n#### Events you send\n\n| Type | Fields | Description |\n|---|---|---|\n| `user.message` | `content`: text blocks | Starts a turn. If a turn is already running, the message joins it, and one `session.status_idle` ends the combined turn. The first `user.message` also starts the session. |\n| `user.tool_confirmation` | `tool_use_id`, `result` (`allow` or `deny`), `deny_message` | Answers a tool call that waits for approval. `allow` approves that one call, and `deny` refuses it. The stored event carries `deny_message` only for a `deny`. |\n| `user.custom_tool_result` | `custom_tool_use_id`, `content`: text blocks, `is_error` | Answers an `agent.custom_tool_use`. The first answer counts, yours or that of the paired computer that serves the tool; a later answer is accepted and changes nothing. The session shows the answer that counted as a `user.custom_tool_result`, whoever sent it. |\n| `user.interrupt` | none | Stops the current turn. The session emits `session.status_idle` with `end_turn`. |\n\n#### Events the session emits\n\n| Type | Fields | Description |\n|---|---|---|\n| `agent.thinking` | none | The agent reasoned before replying. The event has no content and arrives with the reply, so it isn't a live indicator. |\n| `agent.message` | `content`: text blocks | The agent replied. |\n| `agent.tool_use` | `name`, `input` | The agent called a tool. |\n| `agent.custom_tool_use` | `name`, `input` | The agent called one of its custom tools. A `session.status_idle` with `requires_action` naming it follows, until its `user.custom_tool_result` arrives: from you, or from your paired computer whose servers advertise a tool of exactly that name, whichever answers first. The call waits up to 12 minutes. |\n| `agent.tool_result` | `tool_use_id`, `content`, `is_error` | A tool returned its result. |\n| `session.status_running` | none | A turn started. |\n| `session.status_idle` | `stop_reason`, `stop_details` | A turn ended. `stop_reason.type` is `end_turn`, `requires_action` (with `event_ids`, the `agent.tool_use` IDs waiting for your approval) or `retries_exhausted`. `stop_details` is always null. |\n| `session.error` | `error.type`, `error.message`, `error.retry_status` | A step of the turn failed. `error.type` is one of the types in [Session errors](https://docs.context.ai/build/agent-api/openapi/events). With `retry_status.type: \"retrying\"`, the session retries and stays `running`. With `\"exhausted\"`, the turn failed, and a `session.status_idle` with `retries_exhausted` follows. |\n| `session.usage` | `usage`: `input_tokens`, `output_tokens`, `cache_read_input_tokens`, `cache_creation`, `active_seconds` | Reports the session's running totals, subagents included. The session sends it after each model call and before every `session.status_idle`. This event doesn't include cost. To read cost, [retrieve the session](https://docs.context.ai/build/agent-api/openapi/sessions#get-a-session) and read its `usage.list_cost`. |\n\n> **Warning:** When `stop_reason.type` is `requires_action`, answer every ID in `event_ids`. The session doesn't send a new `session.status_idle` for the IDs you haven't answered. It runs again only after you answer the last one.\n\nSubagents that the agent starts do not emit events of their own. The one exception is a subagent tool call waiting for approval, which shows up as `agent.tool_use` and a `session.status_idle` with `requires_action`.\n\n#### Session errors\n\n| `error.type` | Cause |\n|---|---|\n| `model_rate_limited_error` | The model provider's rate limit, or your own usage limit, was reached. |\n| `model_overloaded_error` | The model provider is unavailable or overloaded. |\n| `model_request_failed_error` | The model call failed for another reason, for example a timeout, a network failure, a refused request or a context window overflow. |\n| `billing_error` | Credits, a spend limit or a budget ran out, or the agent has no billing seat in its workspace. |\n| `unknown_error` | Any other failure, including a step the platform retries on its own without a known cause. |\n\n`retry_status.type` is `retrying` or `exhausted`. Any `error.type` can come with `retrying`: the platform retries on its own and the turn continues. With `exhausted`, the turn failed. Send a new `user.message` to start the next turn.\n\n### Differences from Anthropic's API\n\nThis API follows Anthropic's Managed Agents API, with these differences:\n\n- Event deltas and session threads are not supported.\n- Sending `user.tool_result`, `user.define_outcome` or `system.message` returns `400`.\n- A custom tool can also be answered by a computer you paired with the Context app, and a call nobody answers ends after 12 minutes with an error result.\n- Send receipts have their own ID form. See [The event object](https://docs.context.ai/build/agent-api/openapi/events).\n- The stream accepts a `Last-Event-ID` header to resume after an event. Anthropic's API does not.\n- `retry_status.type` is never `terminal`, and MCP, credential and repository error types are not sent.\n\nFor every difference in one place, see [Coming from Anthropic's API](https://docs.context.ai/build/agent-api/coming-from-anthropic)."
    },
    {
      "name": "Files",
      "description": "A file is either a document you upload for an agent to read during a session, or an output an agent writes during a session. Upload a file, then attach it when you [create a session](https://docs.context.ai/build/agent-api/openapi/sessions#create-a-session). Each upload is stored in the Context app, in the Drive of the user who owns the API key.\n\nThe agent writes the files it produces to `/mnt/session/outputs/`, as on Anthropic's API. To get them, list files\nwith `scope_id` set to the session's ID, then download each one. They stay listed after you archive the session.\n\nDeleting a file is permanent: it can't be restored through this API or the app. You can delete only files you\nuploaded. Files a session produced can't be deleted or attached to another session. You can't delete a file\nattached to a session that isn't archived. The request returns `400`. Archive the session first.\n\n### The file object\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | The file's ID. An uploaded file's ID is a UUID. A file a session produced has an ID that starts with `sesnfile_`. Treat both as opaque. |\n| `type` | `string` | Always `file`. |\n| `filename` | `string` | The name sent with the upload. For a file a session produced, this is its path in the session's output folder, such as `charts/q3.csv`. |\n| `mime_type` | `string` | The media type sent with the upload, or `application/octet-stream` if none was sent. |\n| `size_bytes` | `integer` | The size in bytes, or `0` if the size wasn't recorded. |\n| `created_at` | `string` | When the file was uploaded or written, as an RFC 3339 timestamp. |\n| `downloadable` | `boolean` | Always `true`. |\n| `scope` | `object` | The session that produced the file, as `{type: \"session\", id}`, where `id` is the session's ID. Uploaded files have no `scope` field. |\n\n**Example**\n\n```json\n{\n  \"id\": \"329409ba-f288-4b44-9c73-14a18150edee\",\n  \"created_at\": \"2026-10-21T01:41:11.028Z\",\n  \"filename\": \"cities.csv\",\n  \"mime_type\": \"text/csv\",\n  \"size_bytes\": 46,\n  \"type\": \"file\",\n  \"downloadable\": true\n}\n```\n\n### Differences from Anthropic's API\n\nThis API follows Anthropic's Managed Agents API, with these differences:\n\n- Upload accepts `expires_in_seconds` from 3600 to 7776000, but doesn't apply it. Files don't expire, and the file\n  object has no `expires_at`.\n- List files doesn't support `ids`. Sending it returns `400`.\n- A list response holds at most 100 files per page. Anthropic's API allows up to 1,000.\n- An upload can be as large as your deployment's upload limit, which defaults to 5 GiB. Anthropic's limit is\n  500 MB.\n- The files a session produced can't be deleted or attached to another session through this API.\n- List files also accepts `after_id` and `before_id`, and returns `has_more`, `first_id` and `last_id`, which\n  Anthropic's list response doesn't include.\n- Deleting a file that a session still uses returns `400`. See [Delete a file](https://docs.context.ai/build/agent-api/openapi/files#delete-a-file).\n\nFor every difference in one place, see [Coming from Anthropic's API](https://docs.context.ai/build/agent-api/coming-from-anthropic)."
    },
    {
      "name": "Skills",
      "description": "A skill is a folder of instructions and files that an agent loads when a task needs it. Its `SKILL.md` file names the skill and says when to use it. With this API you can upload a skill, list the skills your key can read and download any version.\n\nA skill you create belongs to the key's owner and is private to them until they share it in the Context app.\nCreating, versioning and deleting skills needs a personal key with `skills:write`, which the key's owner must\ngrant. A built-in skill (`source.type` is `anthropic`) is read-only.\n\n### What an upload contains\n\nSend the skill's files as `multipart/form-data`. Either send each file as a `files[]` part whose filename is its\npath in the skill, or send one zip archive of the files.\n\n- `SKILL.md` sits at the root of the upload, or at the root of its one top-level folder. That folder's name is\n  dropped from every path.\n- `SKILL.md` is UTF-8 text with YAML front matter. `name` can be at most 64 characters of lowercase letters,\n  digits and hyphens. If `SKILL.md` has no `name`, the skill takes the top-level folder's name, and an upload with\n  neither returns `400`. `description` is required and can be at most 1,024 characters, with no XML tags.\n- The files total at most 30 MiB (31,457,280 bytes) uncompressed. A single file has no limit of its own. The\n  request itself can be up to 32 MiB.\n- Paths are relative. A path returns `400` if it starts with `/`, contains a backslash or has an empty, `.` or\n  `..` segment. Sending the same path twice also returns `400`. A zip's `__MACOSX/` and `.DS_Store` entries are\n  skipped.\n\nA key can have at most 2 uploads in progress at once.\n\nA skill's name is its `SKILL.md` name, and every version of a skill keeps that name. You can't own two skills with\nthe same name. Creating a skill whose name you already use returns `409` with the existing skill's ID, so you can\nupload a new version of it instead.\n\nA skill keeps its latest 500 versions, not counting versions given a name in the Context app. Saving more deletes\nthe oldest unnamed versions.\n\n### The skill object\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | The skill's ID. A built-in skill's ID is its slug, such as `pptx`. |\n| `type` | `string` | Always `skill`. |\n| `display_name` | `string` | The skill's name, the same as the `name` in its `SKILL.md`. |\n| `source` | `object` | Who made the skill. `source.type` is `custom` for a skill a user uploaded, or `anthropic` for one of your deployment's built-in skills. |\n| `latest_version_id` | `string` | The ID of the skill's newest version. An agent always runs a skill's newest version. |\n| `created_at` | `string` | When the skill was created, as an RFC 3339 timestamp. |\n| `updated_at` | `string` | When the skill last changed, as an RFC 3339 timestamp. |\n\nA skill version describes one saved state of the skill's files:\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | The version's ID. |\n| `type` | `string` | Always `skill_version`. |\n| `skill_id` | `string` | The ID of the skill the version belongs to. |\n| `name` | `string` | The `name` in `SKILL.md`. It is the same for every version of a skill. |\n| `description` | `string` | The `description` in `SKILL.md` at this version. |\n| `created_at` | `string` | When the version was saved, as an RFC 3339 timestamp. |\n\n**Example**\n\n```json\n{\n  \"id\": \"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\",\n  \"type\": \"skill\",\n  \"created_at\": \"2026-10-27T15:02:11.204Z\",\n  \"display_name\": \"pr-summary\",\n  \"latest_version_id\": \"b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e\",\n  \"source\": {\n    \"type\": \"custom\"\n  },\n  \"updated_at\": \"2026-10-27T15:02:11.204Z\"\n}\n```\n\n### Differences from Anthropic's API\n\nThis API follows Anthropic's Managed Agents API, with these differences:\n\n- A skill is personal to the key's owner and belongs to no workspace. If a request sends the `anthropic-workspace-id`\n  header, Context checks that the key's owner works in that workspace, then ignores it. If the owner doesn't work\n  there, the request returns `404`.\n- `display_name` must equal the `name` in `SKILL.md`, or be left out. A different value returns `400`.\n- Deleting a skill version returns `400`. Upload a new version, or delete the whole skill.\n- The built-in skills are this deployment's own, listed by slug (`pptx`, `xlsx`, `docx` and others). The list has\n  no `pdf` skill.\n- A list response holds at most 200 skills or 100 versions per page. Anthropic's API allows up to 1,000.\n- Uploads are limited to 32 MiB per request and 2 in progress per key.\n\nFor every difference in one place, see [Coming from Anthropic's API](https://docs.context.ai/build/agent-api/coming-from-anthropic)."
    }
  ],
  "components": {
    "securitySchemes": {
      "ManagedAgentsKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Authenticate with a task API key in the `x-api-key` header. `Authorization: Bearer <key>` also works. `anthropic-version` and `anthropic-beta` are accepted and ignored."
      }
    },
    "parameters": {
      "AnthropicWorkspaceId": {
        "in": "header",
        "name": "anthropic-workspace-id",
        "required": false,
        "description": "The ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns `404`. Without it, a new session runs in the agent's workspace or the owner's private workspace: see [Where a session runs](https://docs.context.ai/build/agent-api/coming-from-anthropic#where-a-session-runs).",
        "schema": {
          "type": "string",
          "description": "The ID of a workspace in the key's organization that the key's owner works in. Agent and session requests run in that workspace; other requests only check it. The response echoes it. If the owner doesn't work there, the request returns `404`. Without it, a new session runs in the agent's workspace or the owner's private workspace: see [Where a session runs](https://docs.context.ai/build/agent-api/coming-from-anthropic#where-a-session-runs)."
        }
      }
    }
  },
  "paths": {
    "/v1/agents": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "List agents",
        "description": "Lists the agents an API key can run, one page at a time.\n\nA personal key lists the agents its owner can run, sorted by `updated_at`, newest first. This is the same list\nthe agent picker in the Context app shows. A service account key lists every agent in the organization, sorted\nby `created_at`, newest first. If the key is limited to specific agents (its **Agent scope**), the result\nincludes only those. The list never includes archived agents.\n\nThe `system` field is `null` unless the key is a personal key with `agents:write` whose owner created the agent.\nA service account key always gets `null`.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a page of agent objects in `data` and a `next_page` value to pass as `page`. A page can contain fewer agents than `limit`, or none, and still have a `next_page` value. Keep requesting pages until `next_page` is `null`. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 100. Send a value from 1 to 100. |\n| 400 | `invalid_request_error` | `page` is not a `next_page` value from this API. Send the `next_page` value from the previous response, unchanged. |\n| 400 | `invalid_request_error` | `include_archived` is any value other than `false`. Omit it. |\n| 400 | `invalid_request_error` | The request sends a `created_at[*]` filter (`created_at[gte]` or `created_at[lte]`). Remove it. |",
        "operationId": "agents_list",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "The maximum number of agents to return. Must be between 1 and 100. A personal key returns at most 50 agents per page, even when `limit` is higher."
            },
            "description": "The maximum number of agents to return. Must be between 1 and 100. A personal key returns at most 50 agents per page, even when `limit` is higher."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "in": "query",
            "name": "include_archived",
            "required": false,
            "schema": {
              "type": "boolean",
              "enum": [
                false
              ],
              "default": false,
              "description": "Not supported. Omit it or send `false`. Any other value returns `400`."
            },
            "description": "Not supported. Omit it or send `false`. Any other value returns `400`."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a page of agent objects in `data` and a `next_page` value to pass as `page`. A page can contain fewer agents than `limit`, or none, and still have a `next_page` value. Keep requesting pages until `next_page` is `null`. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "archived_at": {
                            "type": "null"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "execution_identity": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "service_account"
                                ]
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          "mcp_servers": {
                            "type": "array",
                            "items": {},
                            "maxItems": 0
                          },
                          "metadata": {
                            "type": "object",
                            "properties": {},
                            "additionalProperties": false
                          },
                          "model": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          "effective_model": {
                            "type": [
                              "object",
                              "null"
                            ],
                            "properties": {
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          "multiagent": {
                            "type": "null"
                          },
                          "name": {
                            "type": "string"
                          },
                          "skills": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "anthropic",
                                    "custom"
                                  ]
                                },
                                "skill_id": {
                                  "type": "string"
                                },
                                "version": {
                                  "type": "string",
                                  "enum": [
                                    "latest"
                                  ]
                                }
                              },
                              "required": [
                                "type",
                                "skill_id",
                                "version"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "system": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "tools": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "agent_toolset_20260401"
                                      ]
                                    },
                                    "configs": {
                                      "type": "array",
                                      "items": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "bash"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "bash"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "edit"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "edit"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "read"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "read"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "write"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "write"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "glob"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "glob"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "grep"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "grep"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "web_fetch"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "web_fetch"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              },
                                              "url_sources": {
                                                "type": "null"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy",
                                              "url_sources"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "web_search"
                                                ]
                                              },
                                              "name": {
                                                "type": "string",
                                                "enum": [
                                                  "web_search"
                                                ]
                                              },
                                              "enabled": {
                                                "type": "boolean"
                                              },
                                              "permission_policy": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_allow"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "type": {
                                                        "type": "string",
                                                        "enum": [
                                                          "always_ask"
                                                        ]
                                                      }
                                                    },
                                                    "required": [
                                                      "type"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "name",
                                              "enabled",
                                              "permission_policy"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "default_config": {
                                      "type": "object",
                                      "properties": {
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "configs",
                                    "default_config"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "custom"
                                      ]
                                    },
                                    "name": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 64,
                                      "pattern": "^[a-z][a-z0-9_]*$"
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 2048,
                                      "default": ""
                                    },
                                    "input_schema": {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "object"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": true
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "name",
                                    "input_schema"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            }
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "agent"
                            ]
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "version": {
                            "type": "number",
                            "enum": [
                              1
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "archived_at",
                          "created_at",
                          "description",
                          "execution_identity",
                          "mcp_servers",
                          "metadata",
                          "model",
                          "effective_model",
                          "multiagent",
                          "name",
                          "skills",
                          "system",
                          "tools",
                          "type",
                          "updated_at",
                          "version"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                      "archived_at": null,
                      "created_at": "2026-10-21T01:35:05.337Z",
                      "description": "Answers questions about the sales pipeline",
                      "execution_identity": {
                        "type": "service_account"
                      },
                      "mcp_servers": [],
                      "metadata": {},
                      "model": {
                        "id": "default"
                      },
                      "effective_model": {
                        "id": "litellm/Claude Sonnet 5.5"
                      },
                      "multiagent": null,
                      "name": "Research Assistant",
                      "skills": [
                        {
                          "type": "anthropic",
                          "skill_id": "xlsx",
                          "version": "latest"
                        }
                      ],
                      "system": null,
                      "tools": [
                        {
                          "type": "agent_toolset_20260401",
                          "default_config": {
                            "enabled": true,
                            "permission_policy": {
                              "type": "always_ask"
                            }
                          },
                          "configs": [
                            {
                              "type": "bash",
                              "name": "bash",
                              "enabled": true,
                              "permission_policy": {
                                "type": "always_ask"
                              }
                            },
                            {
                              "type": "edit",
                              "name": "edit",
                              "enabled": true,
                              "permission_policy": {
                                "type": "always_ask"
                              }
                            },
                            {
                              "type": "read",
                              "name": "read",
                              "enabled": true,
                              "permission_policy": {
                                "type": "always_allow"
                              }
                            },
                            {
                              "type": "write",
                              "name": "write",
                              "enabled": true,
                              "permission_policy": {
                                "type": "always_ask"
                              }
                            },
                            {
                              "type": "glob",
                              "name": "glob",
                              "enabled": true,
                              "permission_policy": {
                                "type": "always_allow"
                              }
                            },
                            {
                              "type": "grep",
                              "name": "grep",
                              "enabled": true,
                              "permission_policy": {
                                "type": "always_allow"
                              }
                            },
                            {
                              "type": "web_fetch",
                              "name": "web_fetch",
                              "enabled": true,
                              "permission_policy": {
                                "type": "always_ask"
                              },
                              "url_sources": null
                            },
                            {
                              "type": "web_search",
                              "name": "web_search",
                              "enabled": false,
                              "permission_policy": {
                                "type": "always_ask"
                              }
                            }
                          ]
                        }
                      ],
                      "type": "agent",
                      "updated_at": "2026-10-21T01:35:05.337Z",
                      "version": 1
                    }
                  ],
                  "next_page": null
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 100. Send a value from 1 to 100.\n\n`page` is not a `next_page` value from this API. Send the `next_page` value from the previous response, unchanged.\n\n`include_archived` is any value other than `false`. Omit it.\n\nThe request sends a `created_at[*]` filter (`created_at[gte]` or `created_at[lte]`). Remove it.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/agents?limit=20\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "for agent in client.beta.agents.list(limit=20):  # auto-paginates\n    print(agent.id, agent.name)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "for await (const agent of client.beta.agents.list({ limit: 20 })) console.log(agent.id, agent.name)"
          }
        ]
      },
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Create an agent",
        "description": "Creates an agent that the key's owner owns.\n\nThe API applies the same checks and defaults as creating an agent in the Context app. You need permission to\ncreate agents in the organization, and the key must have no **Agent scope** (no list of specific agents). If the\nrequest fails, no agent is created.\n\nThe agent goes in the workspace named by `metadata.workspace_id`. Without it, the agent goes in your oldest\nshared (not private) workspace that you can work in, or in no workspace if there is none.\n\nThe key must be a personal key with the `agents:write` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the agent object. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `name` is empty or over 100 characters, or `model` is missing. Send a name of 1 to 100 characters and a model. |\n| 400 | `invalid_request_error` | `model` is not a model your deployment runs, or it sets `effort`, `inference_geo` or `speed`. Send `default` or a model ID only. |\n| 400 | `invalid_request_error` | `metadata` has a key other than `workspace_id`. Remove the other keys. |\n| 400 | `invalid_request_error` | The body sends `version`, a non-empty `mcp_servers`, a `multiagent` that is not null, an `execution_identity` other than `{type: \"service_account\"}`, or a field this API does not take. Remove it. |\n| 400 | `invalid_request_error` | `tools` has an `mcp_toolset`, a second `agent_toolset_20260401`, a tool named twice, or a custom tool whose name is not lowercase letters, digits and underscores. Send one built-in toolset that names each tool once, and name custom tools in that alphabet. |\n| 400 | `invalid_request_error` | A `permission_policy` is `auto`. Use `always_allow` or `always_ask`. |\n| 400 | `invalid_request_error` | `edit` and `write` have different settings. Give them the same `enabled` and `permission_policy`, because the app has one setting for both. |\n| 400 | `invalid_request_error` | `web_search` is enabled, or named without `enabled: false`. Leave it out or send `enabled: false`. |\n| 400 | `invalid_request_error` | A `web_fetch` or `web_search` config sets domain lists, `max_content_tokens`, `url_sources` or `user_location`. Send only `name`, `enabled` and `permission_policy`. |\n| 400 | `invalid_request_error` | A skill is listed twice, has a `version` other than `latest`, or names a built-in slug your deployment doesn't have. List each skill once, by a built-in slug your deployment has or by a custom skill ID from [List skills](https://docs.context.ai/build/agent-api/openapi/skills#list-skills). |\n| 403 | `permission_error` | This key lacks `agents:write`, is not a personal key, or has an **Agent scope**. Use a personal key with `agents:write` and no **Agent scope**. |\n| 403 | `permission_error` | You don't have permission to create agents in this organization, or you don't work in the workspace `metadata.workspace_id` names, or no workspace has that ID. Ask an administrator for access, or name a workspace you work in. |\n| 403 | `permission_error` | A custom skill isn't shared with the agent, and the API can't share it for you. Name skills you own, or create the agent in the skill's workspace. |\n| 404 | `not_found_error` | `metadata.workspace_id` is a workspace of another organization, or a custom skill you sent doesn't exist or isn't visible to the key's owner. Check the IDs. |",
        "operationId": "agents_create",
        "parameters": [
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The agent's purpose."
                  },
                  "execution_identity": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "service_account"
                        ]
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false,
                    "description": "Omit it, or send `null` or `{type: \"service_account\"}`, which changes nothing. Any other value returns `400`."
                  },
                  "mcp_servers": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {},
                    "maxItems": 0,
                    "description": "Not supported. Omit it, or send `null` or `[]`. Any other value returns `400`. Set up an agent's MCP servers and connections in the Context app."
                  },
                  "model": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": false
                      }
                    ],
                    "description": "A model ID your deployment runs ([`GET /v1/models`](https://docs.context.ai/build/agent-api/openapi/agents#list-models) lists them), or `default` for your deployment's default model. The object form `{id}` takes only `id`."
                  },
                  "multiagent": {
                    "type": "null",
                    "description": "Not supported. Omit it or send `null`. Any other value returns `400`."
                  },
                  "skills": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "anthropic",
                            "custom"
                          ]
                        },
                        "skill_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "version": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "enum": [
                            "latest",
                            null
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "skill_id"
                      ],
                      "additionalProperties": false
                    },
                    "description": "The agent's skills, each `{type, skill_id}`. Use `type` `anthropic` with a built-in skill's slug, such as `xlsx`, or `type` `custom` with a skill ID from [List skills](https://docs.context.ai/build/agent-api/openapi/skills#list-skills). `version` is optional and must be `latest`."
                  },
                  "system": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The agent's instructions."
                  },
                  "tools": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "agent_toolset_20260401"
                          ]
                        },
                        "configs": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "bash",
                                  "edit",
                                  "read",
                                  "write",
                                  "glob",
                                  "grep",
                                  "web_fetch",
                                  "web_search"
                                ]
                              },
                              "name": {
                                "type": "string",
                                "enum": [
                                  "bash",
                                  "edit",
                                  "read",
                                  "write",
                                  "glob",
                                  "grep",
                                  "web_fetch",
                                  "web_search"
                                ]
                              },
                              "enabled": {
                                "type": [
                                  "boolean",
                                  "null"
                                ]
                              },
                              "permission_policy": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "always_allow"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "always_ask"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              }
                            },
                            "required": [
                              "name"
                            ],
                            "additionalProperties": false
                          },
                          "description": "Per-tool settings, each `{name, enabled, permission_policy}`. `name` is one of `bash`, `edit`, `read`, `write`, `glob`, `grep`, `web_fetch` or `web_search`. `permission_policy` is `{type: \"always_allow\"}` or `{type: \"always_ask\"}`."
                        },
                        "default_config": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "enabled": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "permission_policy": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "always_allow"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "always_ask"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            }
                          },
                          "additionalProperties": false,
                          "description": "The setting for each built-in tool that `configs` doesn't name, as `{enabled, permission_policy}`. Defaults to `{enabled: true, permission_policy: {type: \"always_allow\"}}`. `web_search` stays off whatever this says."
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "description": "The agent's built-in tools, as at most one `agent_toolset_20260401` entry, and its custom tools. Leave it out to get the defaults the app gives a new agent: every tool on with **Allow**, except `web_search`, and no custom tools. Send `[]` to turn every built-in tool off and remove every custom tool. A custom tool is `{type: \"custom\", name, description, input_schema}`, its `name` lowercase letters, digits and underscores starting with a letter. Answer its `agent.custom_tool_use` with `user.custom_tool_result`. A Context addition: a computer you paired with the Context app whose `mcp.json` servers advertise a tool of exactly that name can answer it too, and the first answer counts."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "The agent's name. Must be between 1 and 100 characters after leading and trailing spaces are trimmed."
                  },
                  "metadata": {
                    "type": "object",
                    "properties": {
                      "workspace_id": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "description": "An object whose only key is `workspace_id`, the ID of a workspace you work in. The API creates the agent in that workspace and does not store `metadata`."
                  }
                },
                "required": [
                  "model",
                  "name"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Research Assistant",
                "model": "default",
                "system": "Answer from the attached files and cite them.",
                "tools": [
                  {
                    "type": "agent_toolset_20260401",
                    "configs": [
                      {
                        "name": "bash",
                        "permission_policy": {
                          "type": "always_ask"
                        }
                      }
                    ]
                  }
                ],
                "skills": [
                  {
                    "type": "anthropic",
                    "skill_id": "xlsx"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with the agent object. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "archived_at": {
                      "type": "null"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "execution_identity": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "service_account"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "mcp_servers": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "model": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    },
                    "effective_model": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    },
                    "multiagent": {
                      "type": "null"
                    },
                    "name": {
                      "type": "string"
                    },
                    "skills": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "anthropic",
                              "custom"
                            ]
                          },
                          "skill_id": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string",
                            "enum": [
                              "latest"
                            ]
                          }
                        },
                        "required": [
                          "type",
                          "skill_id",
                          "version"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "system": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent_toolset_20260401"
                                ]
                              },
                              "configs": {
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "bash"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "bash"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "edit"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "edit"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "read"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "read"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "write"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "write"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "glob"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "glob"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "grep"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "grep"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "web_fetch"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "web_fetch"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        },
                                        "url_sources": {
                                          "type": "null"
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy",
                                        "url_sources"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "web_search"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "web_search"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "default_config": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean"
                                  },
                                  "permission_policy": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "always_allow"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "always_ask"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "enabled",
                                  "permission_policy"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "configs",
                              "default_config"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "custom"
                                ]
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64,
                                "pattern": "^[a-z][a-z0-9_]*$"
                              },
                              "description": {
                                "type": "string",
                                "maxLength": 2048,
                                "default": ""
                              },
                              "input_schema": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "object"
                                    ]
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": true
                              }
                            },
                            "required": [
                              "type",
                              "name",
                              "input_schema"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "agent"
                      ]
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "version": {
                      "type": "number",
                      "enum": [
                        1
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "archived_at",
                    "created_at",
                    "description",
                    "execution_identity",
                    "mcp_servers",
                    "metadata",
                    "model",
                    "effective_model",
                    "multiagent",
                    "name",
                    "skills",
                    "system",
                    "tools",
                    "type",
                    "updated_at",
                    "version"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                  "archived_at": null,
                  "created_at": "2026-10-21T01:35:05.337Z",
                  "description": null,
                  "execution_identity": {
                    "type": "service_account"
                  },
                  "mcp_servers": [],
                  "metadata": {},
                  "model": {
                    "id": "default"
                  },
                  "effective_model": {
                    "id": "litellm/Claude Sonnet 5.5"
                  },
                  "multiagent": null,
                  "name": "Research Assistant",
                  "skills": [
                    {
                      "type": "anthropic",
                      "skill_id": "xlsx",
                      "version": "latest"
                    }
                  ],
                  "system": "Answer from the attached files and cite them.",
                  "tools": [
                    {
                      "type": "agent_toolset_20260401",
                      "default_config": {
                        "enabled": true,
                        "permission_policy": {
                          "type": "always_allow"
                        }
                      },
                      "configs": [
                        {
                          "type": "bash",
                          "name": "bash",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        },
                        {
                          "type": "edit",
                          "name": "edit",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "read",
                          "name": "read",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "write",
                          "name": "write",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "glob",
                          "name": "glob",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "grep",
                          "name": "grep",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "web_fetch",
                          "name": "web_fetch",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          },
                          "url_sources": null
                        },
                        {
                          "type": "web_search",
                          "name": "web_search",
                          "enabled": false,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        }
                      ]
                    }
                  ],
                  "type": "agent",
                  "updated_at": "2026-10-21T01:35:05.337Z",
                  "version": 1
                }
              }
            }
          },
          "400": {
            "description": "`name` is empty or over 100 characters, or `model` is missing. Send a name of 1 to 100 characters and a model.\n\n`model` is not a model your deployment runs, or it sets `effort`, `inference_geo` or `speed`. Send `default` or a model ID only.\n\n`metadata` has a key other than `workspace_id`. Remove the other keys.\n\nThe body sends `version`, a non-empty `mcp_servers`, a `multiagent` that is not null, an `execution_identity` other than `{type: \"service_account\"}`, or a field this API does not take. Remove it.\n\n`tools` has an `mcp_toolset`, a second `agent_toolset_20260401`, a tool named twice, or a custom tool whose name is not lowercase letters, digits and underscores. Send one built-in toolset that names each tool once, and name custom tools in that alphabet.\n\nA `permission_policy` is `auto`. Use `always_allow` or `always_ask`.\n\n`edit` and `write` have different settings. Give them the same `enabled` and `permission_policy`, because the app has one setting for both.\n\n`web_search` is enabled, or named without `enabled: false`. Leave it out or send `enabled: false`.\n\nA `web_fetch` or `web_search` config sets domain lists, `max_content_tokens`, `url_sources` or `user_location`. Send only `name`, `enabled` and `permission_policy`.\n\nA skill is listed twice, has a `version` other than `latest`, or names a built-in slug your deployment doesn't have. List each skill once, by a built-in slug your deployment has or by a custom skill ID from [List skills](https://docs.context.ai/build/agent-api/openapi/skills#list-skills).\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "This key lacks `agents:write`, is not a personal key, or has an **Agent scope**. Use a personal key with `agents:write` and no **Agent scope**.\n\nYou don't have permission to create agents in this organization, or you don't work in the workspace `metadata.workspace_id` names, or no workspace has that ID. Ask an administrator for access, or name a workspace you work in.\n\nA custom skill isn't shared with the agent, and the API can't share it for you. Name skills you own, or create the agent in the skill's workspace.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "`metadata.workspace_id` is a workspace of another organization, or a custom skill you sent doesn't exist or isn't visible to the key's owner. Check the IDs.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/agents\" -H \"x-api-key: $CONTEXT_API_KEY\" -H \"content-type: application/json\" \\\n  -d '{\"name\": \"Research Assistant\", \"model\": \"default\", \"system\": \"Answer from the attached files and cite them.\",\n       \"tools\": [{\"type\": \"agent_toolset_20260401\", \"configs\": [{\"name\": \"bash\", \"permission_policy\": {\"type\": \"always_ask\"}}]}],\n       \"skills\": [{\"type\": \"anthropic\", \"skill_id\": \"xlsx\"}]}'"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "agent = client.beta.agents.create(\n    name=\"Research Assistant\",\n    model=\"default\",\n    system=\"Answer from the attached files and cite them.\",\n    tools=[{\n        \"type\": \"agent_toolset_20260401\",\n        \"configs\": [{\"name\": \"bash\", \"permission_policy\": {\"type\": \"always_ask\"}}],\n    }],\n    skills=[{\"type\": \"anthropic\", \"skill_id\": \"xlsx\"}],\n)\nprint(agent.id)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const agent = await client.beta.agents.create({\n  name: \"Research Assistant\",\n  model: \"default\",\n  system: \"Answer from the attached files and cite them.\",\n  tools: [{\n    type: \"agent_toolset_20260401\",\n    configs: [{ name: \"bash\", permission_policy: { type: \"always_ask\" } }],\n  }],\n  skills: [{ type: \"anthropic\", skill_id: \"xlsx\" }],\n})\nconsole.log(agent.id)"
          }
        ]
      }
    },
    "/v1/agents/{agent_id}": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "Get an agent",
        "description": "Returns an agent that the calling API key can run.\n\nA key can read only the agents in its **Agent scope**, if it has one. An agent ID that does not exist returns `403`, not `404`: the same response as for an agent outside the key's **Agent scope**.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the agent object. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `version` is not `1`. Omit `version` or send `1`. |\n| 403 | `permission_error` | The key is not allowed to run this agent, or no agent has this ID. Check the agent ID and the key's **Agent scope**. |",
        "operationId": "agents_retrieve",
        "parameters": [
          {
            "in": "path",
            "name": "agent_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the agent to return."
            },
            "description": "The ID of the agent to return."
          },
          {
            "in": "query",
            "name": "version",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1,
              "description": "Not supported. Omit it or send `1`. Any other value returns `400`. Every agent has exactly one version."
            },
            "description": "Not supported. Omit it or send `1`. Any other value returns `400`. Every agent has exactly one version."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the agent object. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "archived_at": {
                      "type": "null"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "execution_identity": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "service_account"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "mcp_servers": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "model": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    },
                    "effective_model": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    },
                    "multiagent": {
                      "type": "null"
                    },
                    "name": {
                      "type": "string"
                    },
                    "skills": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "anthropic",
                              "custom"
                            ]
                          },
                          "skill_id": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string",
                            "enum": [
                              "latest"
                            ]
                          }
                        },
                        "required": [
                          "type",
                          "skill_id",
                          "version"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "system": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent_toolset_20260401"
                                ]
                              },
                              "configs": {
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "bash"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "bash"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "edit"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "edit"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "read"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "read"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "write"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "write"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "glob"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "glob"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "grep"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "grep"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "web_fetch"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "web_fetch"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        },
                                        "url_sources": {
                                          "type": "null"
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy",
                                        "url_sources"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "web_search"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "web_search"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "default_config": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean"
                                  },
                                  "permission_policy": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "always_allow"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "always_ask"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "enabled",
                                  "permission_policy"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "configs",
                              "default_config"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "custom"
                                ]
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64,
                                "pattern": "^[a-z][a-z0-9_]*$"
                              },
                              "description": {
                                "type": "string",
                                "maxLength": 2048,
                                "default": ""
                              },
                              "input_schema": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "object"
                                    ]
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": true
                              }
                            },
                            "required": [
                              "type",
                              "name",
                              "input_schema"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "agent"
                      ]
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "version": {
                      "type": "number",
                      "enum": [
                        1
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "archived_at",
                    "created_at",
                    "description",
                    "execution_identity",
                    "mcp_servers",
                    "metadata",
                    "model",
                    "effective_model",
                    "multiagent",
                    "name",
                    "skills",
                    "system",
                    "tools",
                    "type",
                    "updated_at",
                    "version"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                  "archived_at": null,
                  "created_at": "2026-10-21T01:35:05.337Z",
                  "description": "Answers questions about the sales pipeline",
                  "execution_identity": {
                    "type": "service_account"
                  },
                  "mcp_servers": [],
                  "metadata": {},
                  "model": {
                    "id": "default"
                  },
                  "effective_model": {
                    "id": "litellm/Claude Sonnet 5.5"
                  },
                  "multiagent": null,
                  "name": "Research Assistant",
                  "skills": [
                    {
                      "type": "anthropic",
                      "skill_id": "xlsx",
                      "version": "latest"
                    }
                  ],
                  "system": null,
                  "tools": [
                    {
                      "type": "agent_toolset_20260401",
                      "default_config": {
                        "enabled": true,
                        "permission_policy": {
                          "type": "always_ask"
                        }
                      },
                      "configs": [
                        {
                          "type": "bash",
                          "name": "bash",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        },
                        {
                          "type": "edit",
                          "name": "edit",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        },
                        {
                          "type": "read",
                          "name": "read",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "write",
                          "name": "write",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        },
                        {
                          "type": "glob",
                          "name": "glob",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "grep",
                          "name": "grep",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "web_fetch",
                          "name": "web_fetch",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          },
                          "url_sources": null
                        },
                        {
                          "type": "web_search",
                          "name": "web_search",
                          "enabled": false,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        }
                      ]
                    }
                  ],
                  "type": "agent",
                  "updated_at": "2026-10-21T01:35:05.337Z",
                  "version": 1
                }
              }
            }
          },
          "400": {
            "description": "`version` is not `1`. Omit `version` or send `1`.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key is not allowed to run this agent, or no agent has this ID. Check the agent ID and the key's **Agent scope**.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/agents/6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "agent = client.beta.agents.retrieve(\"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const agent = await client.beta.agents.retrieve(\"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\")"
          }
        ]
      },
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Update an agent",
        "description": "Updates an agent. Fields you leave out keep their values.\n\nThe API applies the same checks as an edit in the Context app. You must be allowed to edit the agent, and the\nkey's **Agent scope**, if it has one, must include the agent. `tools` and `skills` replace the whole list when\nyou send them. Every agent has one version, `1`: an update changes the agent in place and does not check for\nedits made since you read it, so the last update wins.\n\nIf part of an update is saved and a later part is refused, the error message names the saved fields. Get the\nagent before you retry.\n\nThe key must be a personal key with the `agents:write` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the agent object. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `version` is not `1`. Omit it or send `1`. |\n| 400 | `invalid_request_error` | `metadata` is not empty. Omit it or send `{}`. To change an agent's workspace, use the Context app. |\n| 400 | `invalid_request_error` | A field breaks a rule of [Create an agent](https://docs.context.ai/build/agent-api/openapi/agents#create-an-agent), such as an unknown model or a custom tool. Fix the field as the matching row there describes. |\n| 400 | `invalid_request_error` | The agent's permission mode is read-only, or its permissions are a hand-written permission block, so its tools can't be changed here. Choose another permission mode for the agent in the app first. |\n| 400 | `invalid_request_error` | The tool settings you sent conflict with the agent's permission mode or with permission rules set in the app. Change those settings in the app, or send tool settings that match them. |\n| 403 | `permission_error` | This key lacks `agents:write`, is not a personal key, or its **Agent scope** doesn't include this agent. Use a personal key with `agents:write` whose **Agent scope**, if any, includes this agent. |\n| 403 | `permission_error` | You are not allowed to edit this agent. Ask its owner for access. |\n| 403 | `permission_error` | A custom skill isn't shared with the agent, and the API can't share it for you. Name skills you own, or move the agent to the skill's workspace in the app. |\n| 404 | `not_found_error` | No agent in this key's organization has this ID, or a custom skill you sent doesn't exist or isn't visible to the key's owner. Check the IDs. |",
        "operationId": "agents_update",
        "parameters": [
          {
            "in": "path",
            "name": "agent_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the agent to update."
            },
            "description": "The ID of the agent to update."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The agent's purpose. `null` clears it."
                  },
                  "execution_identity": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "service_account"
                        ]
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false,
                    "description": "Omit it, or send `null` or `{type: \"service_account\"}`, which changes nothing. Any other value returns `400`."
                  },
                  "mcp_servers": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {},
                    "maxItems": 0,
                    "description": "Not supported. Omit it, or send `null` or `[]`. Any other value returns `400`. Set up an agent's MCP servers and connections in the Context app."
                  },
                  "model": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": false
                      }
                    ],
                    "description": "A model ID your deployment runs ([`GET /v1/models`](https://docs.context.ai/build/agent-api/openapi/agents#list-models) lists them), or the object form `{id}`. `default` removes the agent's own model, so it uses your deployment's default."
                  },
                  "multiagent": {
                    "type": "null",
                    "description": "Not supported. Omit it or send `null`. Any other value returns `400`."
                  },
                  "skills": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "anthropic",
                            "custom"
                          ]
                        },
                        "skill_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "version": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "enum": [
                            "latest",
                            null
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "skill_id"
                      ],
                      "additionalProperties": false
                    },
                    "description": "The agent's skills, in the same shape as on [Create an agent](https://docs.context.ai/build/agent-api/openapi/agents#create-an-agent). Replaces the whole list. `null` or `[]` removes them."
                  },
                  "system": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The agent's instructions. `null` clears them."
                  },
                  "tools": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "agent_toolset_20260401"
                          ]
                        },
                        "configs": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "bash",
                                  "edit",
                                  "read",
                                  "write",
                                  "glob",
                                  "grep",
                                  "web_fetch",
                                  "web_search"
                                ]
                              },
                              "name": {
                                "type": "string",
                                "enum": [
                                  "bash",
                                  "edit",
                                  "read",
                                  "write",
                                  "glob",
                                  "grep",
                                  "web_fetch",
                                  "web_search"
                                ]
                              },
                              "enabled": {
                                "type": [
                                  "boolean",
                                  "null"
                                ]
                              },
                              "permission_policy": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "always_allow"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "always_ask"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              }
                            },
                            "required": [
                              "name"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "default_config": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "enabled": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "permission_policy": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "always_allow"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "always_ask"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "description": "The agent's built-in tool settings, in the same shape as on [Create an agent](https://docs.context.ai/build/agent-api/openapi/agents#create-an-agent). Replaces the whole list. `null` or `[]` turns every built-in tool off."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "The agent's name. Must be between 1 and 100 characters after leading and trailing spaces are trimmed."
                  },
                  "metadata": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {},
                    "additionalProperties": false,
                    "description": "Not supported. Omit it, or send `null` or `{}`. Any other value returns `400`."
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1,
                    "description": "The agent's version. Must be `1`. Any other value returns `400`."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "system": "Answer in one paragraph."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with the agent object. For every field, see [Agents](https://docs.context.ai/build/agent-api/openapi/agents).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "archived_at": {
                      "type": "null"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "execution_identity": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "service_account"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "mcp_servers": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "model": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    },
                    "effective_model": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    },
                    "multiagent": {
                      "type": "null"
                    },
                    "name": {
                      "type": "string"
                    },
                    "skills": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "anthropic",
                              "custom"
                            ]
                          },
                          "skill_id": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string",
                            "enum": [
                              "latest"
                            ]
                          }
                        },
                        "required": [
                          "type",
                          "skill_id",
                          "version"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "system": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent_toolset_20260401"
                                ]
                              },
                              "configs": {
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "bash"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "bash"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "edit"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "edit"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "read"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "read"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "write"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "write"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "glob"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "glob"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "grep"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "grep"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "web_fetch"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "web_fetch"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        },
                                        "url_sources": {
                                          "type": "null"
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy",
                                        "url_sources"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "web_search"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "enum": [
                                            "web_search"
                                          ]
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        },
                                        "permission_policy": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_allow"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "enum": [
                                                    "always_ask"
                                                  ]
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "enabled",
                                        "permission_policy"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "default_config": {
                                "type": "object",
                                "properties": {
                                  "enabled": {
                                    "type": "boolean"
                                  },
                                  "permission_policy": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "always_allow"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "always_ask"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "enabled",
                                  "permission_policy"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "configs",
                              "default_config"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "custom"
                                ]
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64,
                                "pattern": "^[a-z][a-z0-9_]*$"
                              },
                              "description": {
                                "type": "string",
                                "maxLength": 2048,
                                "default": ""
                              },
                              "input_schema": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "object"
                                    ]
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": true
                              }
                            },
                            "required": [
                              "type",
                              "name",
                              "input_schema"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "agent"
                      ]
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "version": {
                      "type": "number",
                      "enum": [
                        1
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "archived_at",
                    "created_at",
                    "description",
                    "execution_identity",
                    "mcp_servers",
                    "metadata",
                    "model",
                    "effective_model",
                    "multiagent",
                    "name",
                    "skills",
                    "system",
                    "tools",
                    "type",
                    "updated_at",
                    "version"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                  "archived_at": null,
                  "created_at": "2026-10-21T01:35:05.337Z",
                  "description": "Answers questions about the sales pipeline",
                  "execution_identity": {
                    "type": "service_account"
                  },
                  "mcp_servers": [],
                  "metadata": {},
                  "model": {
                    "id": "default"
                  },
                  "effective_model": {
                    "id": "litellm/Claude Sonnet 5.5"
                  },
                  "multiagent": null,
                  "name": "Research Assistant",
                  "skills": [
                    {
                      "type": "anthropic",
                      "skill_id": "xlsx",
                      "version": "latest"
                    }
                  ],
                  "system": "Answer in one paragraph.",
                  "tools": [
                    {
                      "type": "agent_toolset_20260401",
                      "default_config": {
                        "enabled": true,
                        "permission_policy": {
                          "type": "always_ask"
                        }
                      },
                      "configs": [
                        {
                          "type": "bash",
                          "name": "bash",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        },
                        {
                          "type": "edit",
                          "name": "edit",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        },
                        {
                          "type": "read",
                          "name": "read",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "write",
                          "name": "write",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        },
                        {
                          "type": "glob",
                          "name": "glob",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "grep",
                          "name": "grep",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_allow"
                          }
                        },
                        {
                          "type": "web_fetch",
                          "name": "web_fetch",
                          "enabled": true,
                          "permission_policy": {
                            "type": "always_ask"
                          },
                          "url_sources": null
                        },
                        {
                          "type": "web_search",
                          "name": "web_search",
                          "enabled": false,
                          "permission_policy": {
                            "type": "always_ask"
                          }
                        }
                      ]
                    }
                  ],
                  "type": "agent",
                  "updated_at": "2026-10-21T02:10:44.918Z",
                  "version": 1
                }
              }
            }
          },
          "400": {
            "description": "`version` is not `1`. Omit it or send `1`.\n\n`metadata` is not empty. Omit it or send `{}`. To change an agent's workspace, use the Context app.\n\nA field breaks a rule of [Create an agent](https://docs.context.ai/build/agent-api/openapi/agents#create-an-agent), such as an unknown model or a custom tool. Fix the field as the matching row there describes.\n\nThe agent's permission mode is read-only, or its permissions are a hand-written permission block, so its tools can't be changed here. Choose another permission mode for the agent in the app first.\n\nThe tool settings you sent conflict with the agent's permission mode or with permission rules set in the app. Change those settings in the app, or send tool settings that match them.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "This key lacks `agents:write`, is not a personal key, or its **Agent scope** doesn't include this agent. Use a personal key with `agents:write` whose **Agent scope**, if any, includes this agent.\n\nYou are not allowed to edit this agent. Ask its owner for access.\n\nA custom skill isn't shared with the agent, and the API can't share it for you. Name skills you own, or move the agent to the skill's workspace in the app.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No agent in this key's organization has this ID, or a custom skill you sent doesn't exist or isn't visible to the key's owner. Check the IDs.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/agents/6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\" -H \"x-api-key: $CONTEXT_API_KEY\" \\\n  -H \"content-type: application/json\" -d '{\"system\": \"Answer in one paragraph.\"}'"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "agent = client.beta.agents.update(\"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\", system=\"Answer in one paragraph.\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const agent = await client.beta.agents.update(\"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\", { system: \"Answer in one paragraph.\" })"
          }
        ]
      }
    },
    "/v1/models": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "List models",
        "description": "Lists the models an agent can be set to run in this deployment.\n\nEach `id` is exactly what you send as `model` when you [create](https://docs.context.ai/build/agent-api/openapi/agents#create-an-agent) or\n[update](https://docs.context.ai/build/agent-api/openapi/agents#update-an-agent) an agent, so a model picker built from this list offers\nnothing those endpoints refuse. The list is the deployment's, not the key's: every key in a deployment gets the\nsame answer.\n\n`\"default\"` is also accepted as `model` on a write, and it is what an agent reads back when it leaves the choice\nto the deployment. It is not a row in this list, because it names no particular model.\n\nTwo kinds of model are deliberately missing. A model your deployment still runs but that an agent may no longer\nbe pinned to — a model route the deployment has retired — is not listed, because a write would refuse it. A\nmodel you reach only through a subscription you connected yourself is not listed either, though a write still\naccepts it for you: one key's list must not describe another person's connected accounts.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n> **Note:** Anthropic's API has no equivalent of this endpoint, and the SDKs carry no method for it. Call it with an\n> HTTP client. The model IDs here are your deployment's own (`<provider>/<model>`), not Anthropic model names.\n\n## Response\n\nReturns `200` with a page of model objects in `data` and a `next_page` value to pass as `page`. Keep requesting pages until `next_page` is `null`. A short page means the end of the list; a page is never empty while `next_page` is set.\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | Send this as `model` on an agent write. An agent read answers the same string in `model.id`. |\n| `display_name` | `string` | The model's name as the Context app shows it. |\n| `type` | `string` | Always `model`. |\n\nA model object carries no `created_at`: a model here is a row of your deployment's configured catalog, not a record with a creation time.\n\nA deployment whose every model route has been retired answers an empty `data` with `next_page` `null`: those\nmodels still run, but no agent may be set to one of them.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 100. Send a value from 1 to 100. |\n| 400 | `invalid_request_error` | `page` is not a `next_page` value from this API, or the model list changed while you were paging it. Drop `page` and walk the list again from the start. |",
        "operationId": "agents_models",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "The maximum number of models to return. Must be between 1 and 100."
            },
            "description": "The maximum number of models to return. Must be between 1 and 100."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "in": "header",
            "name": "anthropic-workspace-id",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The ID of a workspace in the key's organization that the key's owner works in. This request only checks it; the model list is the same in every workspace. The response echoes it. If the owner doesn't work there, the request returns `404`. See [Headers](https://docs.context.ai/build/agent-api/coming-from-anthropic#headers)."
            },
            "description": "The ID of a workspace in the key's organization that the key's owner works in. This request only checks it; the model list is the same in every workspace. The response echoes it. If the owner doesn't work there, the request returns `404`. See [Headers](https://docs.context.ai/build/agent-api/coming-from-anthropic#headers)."
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a page of model objects in `data` and a `next_page` value to pass as `page`. Keep requesting pages until `next_page` is `null`. A short page means the end of the list; a page is never empty while `next_page` is set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "model"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "display_name",
                          "type"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "litellm/Claude Sonnet 5.5",
                      "display_name": "Claude Sonnet 5.5",
                      "type": "model"
                    },
                    {
                      "id": "litellm/Claude Opus 5.5",
                      "display_name": "Claude Opus 5.5",
                      "type": "model"
                    }
                  ],
                  "next_page": null
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 100. Send a value from 1 to 100.\n\n`page` is not a `next_page` value from this API, or the model list changed while you were paging it. Drop `page` and walk the list again from the start.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/models?limit=20\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import os\n\nimport httpx  # the SDK carries no models namespace for this surface\n\nresponse = httpx.get(\n    f\"{os.environ['CONTEXT_BASE_URL']}/v1/models\",\n    headers={\"x-api-key\": os.environ[\"CONTEXT_API_KEY\"]},\n    params={\"limit\": 20},\n)\nresponse.raise_for_status()\nfor model in response.json()[\"data\"]:\n    print(model[\"id\"], model[\"display_name\"])"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "// the SDK carries no models namespace for this surface\nconst response = await fetch(`${process.env.CONTEXT_BASE_URL}/v1/models?limit=20`, {\n  headers: { \"x-api-key\": process.env.CONTEXT_API_KEY! },\n})\nif (!response.ok) throw new Error(await response.text())\nconst { data } = (await response.json()) as { data: Array<{ id: string; display_name: string }> }\nfor (const model of data) console.log(model.id, model.display_name)"
          }
        ]
      }
    },
    "/v1/workspaces": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "List workspaces",
        "description": "Lists the workspaces an API key can run in.\n\nEach `id` is a value you can send as the [`anthropic-workspace-id`](https://docs.context.ai/build/agent-api/coming-from-anthropic#headers) header, and the list is exactly the set that header accepts for this key: send one of these and the request runs in that workspace; send anything else and you get `404`. So a workspace picker built from this list cannot offer a workspace the next request will reject.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n> **Note:** Anthropic's Managed Agents API has no workspace listing, and the workspaces on its Admin API are the whole\n> organization's, read with an admin key. This endpoint is a Context extension and answers a narrower question: the\n> workspaces **this key's owner** may work in, read with the key itself. It is deliberately not on Anthropic's Admin\n> API path, because the same path would otherwise answer a different question for a different caller.\n\n## Response\n\nReturns `200` with a page of workspace objects in `data` and a `next_page` value to pass as `page`. Keep requesting pages until `next_page` is `null`. A short page means the end of the list; a page is never empty while `next_page` is set.\n\n| Field | Type | Description |\n|---|---|---|\n| `id` | `string` | Send this as the `anthropic-workspace-id` header. |\n| `name` | `string` | The workspace's name, as the Context app shows it. |\n| `type` | `string` | Always `workspace`. |\n\nAn empty `data` means this key's owner works in no workspace of the organization — not that the organization has none. Agents and sessions still work without a workspace; the header is what needs one.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 100. Send a value from 1 to 100. |\n| 400 | `invalid_request_error` | `page` is not a `next_page` value from this API, or the workspace list changed while you were paging it. Drop `page` and walk the list again from the start. |",
        "operationId": "agents_workspaces",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "The maximum number of workspaces to return. Must be between 1 and 100."
            },
            "description": "The maximum number of workspaces to return. Must be between 1 and 100."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "in": "header",
            "name": "anthropic-workspace-id",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The ID of a workspace in the key's organization that the key's owner works in. This request only checks it; the list is the same whichever workspace you name, and every ID it returns is one this header accepts. The response echoes it. If the owner doesn't work there, the request returns `404`. See [Headers](https://docs.context.ai/build/agent-api/coming-from-anthropic#headers)."
            },
            "description": "The ID of a workspace in the key's organization that the key's owner works in. This request only checks it; the list is the same whichever workspace you name, and every ID it returns is one this header accepts. The response echoes it. If the owner doesn't work there, the request returns `404`. See [Headers](https://docs.context.ai/build/agent-api/coming-from-anthropic#headers)."
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a page of workspace objects in `data` and a `next_page` value to pass as `page`. Keep requesting pages until `next_page` is `null`. A short page means the end of the list; a page is never empty while `next_page` is set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "workspace"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "type"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "3f8c1d02-5b47-4a19-9d6e-71c2a4f8b305",
                      "name": "Platform Engineering",
                      "type": "workspace"
                    },
                    {
                      "id": "a1d94e77-2c08-4b63-85f0-6e39b1c4d882",
                      "name": "Support",
                      "type": "workspace"
                    }
                  ],
                  "next_page": null
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 100. Send a value from 1 to 100.\n\n`page` is not a `next_page` value from this API, or the workspace list changed while you were paging it. Drop `page` and walk the list again from the start.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/workspaces?limit=20\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "import os\n\nimport httpx  # the SDK carries no workspaces namespace for this surface\n\nresponse = httpx.get(\n    f\"{os.environ['CONTEXT_BASE_URL']}/v1/workspaces\",\n    headers={\"x-api-key\": os.environ[\"CONTEXT_API_KEY\"]},\n    params={\"limit\": 20},\n)\nresponse.raise_for_status()\nfor workspace in response.json()[\"data\"]:\n    print(workspace[\"id\"], workspace[\"name\"])"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "// the SDK carries no workspaces namespace for this surface\nconst response = await fetch(`${process.env.CONTEXT_BASE_URL}/v1/workspaces?limit=20`, {\n  headers: { \"x-api-key\": process.env.CONTEXT_API_KEY! },\n})\nif (!response.ok) throw new Error(await response.text())\nconst { data } = (await response.json()) as { data: Array<{ id: string; name: string }> }\nfor (const workspace of data) console.log(workspace.id, workspace.name)"
          }
        ]
      }
    },
    "/v1/environments": {
      "get": {
        "tags": [
          "Environments"
        ],
        "summary": "List environments",
        "description": "Lists the environments a session can run in, which is the default cloud environment (`env_default`).\n\nA session can run only in an environment from this list. The API has no call to create environments.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the environments in `data`. Pass `next_page` as `page` to get the next page. `next_page` is `null` on the last page.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 100. Send a value from 1 to 100. |\n| 400 | `invalid_request_error` | `page` is not a `next_page` value from this API. Send the `next_page` value from the previous response, unchanged. |",
        "operationId": "environments_list",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "The maximum number of environments to return per page. Must be between 1 and 100."
            },
            "description": "The maximum number of environments to return per page. Must be between 1 and 100."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "in": "query",
            "name": "include_archived",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "description": "Has no effect, because environments are never archived."
            },
            "description": "Has no effect, because environments are never archived."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the environments in `data`. Pass `next_page` as `page` to get the next page. `next_page` is `null` on the last page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "enum": [
                                  "env_default"
                                ]
                              },
                              "archived_at": {
                                "type": "null"
                              },
                              "config": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "cloud"
                                    ]
                                  },
                                  "networking": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "unrestricted"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "packages": {
                                    "type": "object",
                                    "properties": {
                                      "apt": {
                                        "type": "array",
                                        "items": {},
                                        "maxItems": 0
                                      },
                                      "cargo": {
                                        "type": "array",
                                        "items": {},
                                        "maxItems": 0
                                      },
                                      "gem": {
                                        "type": "array",
                                        "items": {},
                                        "maxItems": 0
                                      },
                                      "go": {
                                        "type": "array",
                                        "items": {},
                                        "maxItems": 0
                                      },
                                      "npm": {
                                        "type": "array",
                                        "items": {},
                                        "maxItems": 0
                                      },
                                      "pip": {
                                        "type": "array",
                                        "items": {},
                                        "maxItems": 0
                                      }
                                    },
                                    "required": [
                                      "apt",
                                      "cargo",
                                      "gem",
                                      "go",
                                      "npm",
                                      "pip"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "networking",
                                  "packages"
                                ],
                                "additionalProperties": false
                              },
                              "created_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "description": {
                                "type": "string"
                              },
                              "metadata": {
                                "type": "object",
                                "properties": {},
                                "additionalProperties": false
                              },
                              "name": {
                                "type": "string",
                                "enum": [
                                  "default"
                                ]
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "environment"
                                ]
                              },
                              "updated_at": {
                                "type": "string",
                                "format": "date-time"
                              }
                            },
                            "required": [
                              "id",
                              "archived_at",
                              "config",
                              "created_at",
                              "description",
                              "metadata",
                              "name",
                              "type",
                              "updated_at"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "archived_at": {
                                "type": "null"
                              },
                              "config": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "self_hosted"
                                    ]
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              "created_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "description": {
                                "type": "string"
                              },
                              "device": {
                                "type": "object",
                                "properties": {
                                  "paired_device_id": {
                                    "type": "string"
                                  },
                                  "presence": {
                                    "type": "string",
                                    "enum": [
                                      "online",
                                      "not_answering",
                                      "closed",
                                      "never_seen",
                                      "unpaired"
                                    ]
                                  },
                                  "readiness": {
                                    "type": "string",
                                    "enum": [
                                      "native_online",
                                      "bridge_ready",
                                      "old_or_unsupported",
                                      "offline_or_unknown",
                                      "tools_only"
                                    ]
                                  },
                                  "engine_commit": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "paired_device_id",
                                  "presence",
                                  "readiness",
                                  "engine_commit"
                                ],
                                "additionalProperties": false
                              },
                              "metadata": {
                                "type": "object",
                                "properties": {},
                                "additionalProperties": false
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "environment"
                                ]
                              },
                              "updated_at": {
                                "type": "string",
                                "format": "date-time"
                              }
                            },
                            "required": [
                              "id",
                              "archived_at",
                              "config",
                              "created_at",
                              "description",
                              "device",
                              "metadata",
                              "name",
                              "type",
                              "updated_at"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "env_default",
                      "archived_at": null,
                      "config": {
                        "type": "cloud",
                        "networking": {
                          "type": "unrestricted"
                        },
                        "packages": {
                          "apt": [],
                          "cargo": [],
                          "gem": [],
                          "go": [],
                          "npm": [],
                          "pip": []
                        }
                      },
                      "created_at": "2026-10-14T00:00:00.000Z",
                      "description": "The platform's own runtime. Every session runs here.",
                      "metadata": {},
                      "name": "default",
                      "type": "environment",
                      "updated_at": "2026-10-14T00:00:00.000Z"
                    }
                  ],
                  "next_page": null
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 100. Send a value from 1 to 100.\n\n`page` is not a `next_page` value from this API. Send the `next_page` value from the previous response, unchanged.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/environments\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "for env in client.beta.environments.list():\n    print(env.id, env.name)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "for await (const env of client.beta.environments.list()) console.log(env.id, env.name)"
          }
        ]
      }
    },
    "/v1/environments/{environment_id}": {
      "get": {
        "tags": [
          "Environments"
        ],
        "summary": "Get an environment",
        "description": "Returns one environment, the default cloud environment (`env_default`).\n\nTo run a session in this environment, pass its `id` as `environment_id` when you create the session.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the environment object. For every field, see [Environments](https://docs.context.ai/build/agent-api/openapi/environments).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 404 | `not_found_error` | The ID is not `env_default`. Use `env_default`. |",
        "operationId": "environments_retrieve",
        "parameters": [
          {
            "in": "path",
            "name": "environment_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the environment to retrieve: `env_default`."
            },
            "description": "The ID of the environment to retrieve: `env_default`."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the environment object. For every field, see [Environments](https://docs.context.ai/build/agent-api/openapi/environments).",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "enum": [
                            "env_default"
                          ]
                        },
                        "archived_at": {
                          "type": "null"
                        },
                        "config": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "cloud"
                              ]
                            },
                            "networking": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "unrestricted"
                                  ]
                                }
                              },
                              "required": [
                                "type"
                              ],
                              "additionalProperties": false
                            },
                            "packages": {
                              "type": "object",
                              "properties": {
                                "apt": {
                                  "type": "array",
                                  "items": {},
                                  "maxItems": 0
                                },
                                "cargo": {
                                  "type": "array",
                                  "items": {},
                                  "maxItems": 0
                                },
                                "gem": {
                                  "type": "array",
                                  "items": {},
                                  "maxItems": 0
                                },
                                "go": {
                                  "type": "array",
                                  "items": {},
                                  "maxItems": 0
                                },
                                "npm": {
                                  "type": "array",
                                  "items": {},
                                  "maxItems": 0
                                },
                                "pip": {
                                  "type": "array",
                                  "items": {},
                                  "maxItems": 0
                                }
                              },
                              "required": [
                                "apt",
                                "cargo",
                                "gem",
                                "go",
                                "npm",
                                "pip"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "networking",
                            "packages"
                          ],
                          "additionalProperties": false
                        },
                        "created_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "description": {
                          "type": "string"
                        },
                        "metadata": {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": false
                        },
                        "name": {
                          "type": "string",
                          "enum": [
                            "default"
                          ]
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "environment"
                          ]
                        },
                        "updated_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "archived_at",
                        "config",
                        "created_at",
                        "description",
                        "metadata",
                        "name",
                        "type",
                        "updated_at"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "archived_at": {
                          "type": "null"
                        },
                        "config": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "self_hosted"
                              ]
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        "created_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "description": {
                          "type": "string"
                        },
                        "device": {
                          "type": "object",
                          "properties": {
                            "paired_device_id": {
                              "type": "string"
                            },
                            "presence": {
                              "type": "string",
                              "enum": [
                                "online",
                                "not_answering",
                                "closed",
                                "never_seen",
                                "unpaired"
                              ]
                            },
                            "readiness": {
                              "type": "string",
                              "enum": [
                                "native_online",
                                "bridge_ready",
                                "old_or_unsupported",
                                "offline_or_unknown",
                                "tools_only"
                              ]
                            },
                            "engine_commit": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "paired_device_id",
                            "presence",
                            "readiness",
                            "engine_commit"
                          ],
                          "additionalProperties": false
                        },
                        "metadata": {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": false
                        },
                        "name": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "environment"
                          ]
                        },
                        "updated_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "archived_at",
                        "config",
                        "created_at",
                        "description",
                        "device",
                        "metadata",
                        "name",
                        "type",
                        "updated_at"
                      ],
                      "additionalProperties": false
                    }
                  ]
                },
                "example": {
                  "id": "env_default",
                  "archived_at": null,
                  "config": {
                    "type": "cloud",
                    "networking": {
                      "type": "unrestricted"
                    },
                    "packages": {
                      "apt": [],
                      "cargo": [],
                      "gem": [],
                      "go": [],
                      "npm": [],
                      "pip": []
                    }
                  },
                  "created_at": "2026-10-14T00:00:00.000Z",
                  "description": "The platform's own runtime. Every session runs here.",
                  "metadata": {},
                  "name": "default",
                  "type": "environment",
                  "updated_at": "2026-10-14T00:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The ID is not `env_default`. Use `env_default`.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/environments/env_default\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "env = client.beta.environments.retrieve(\"env_default\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const env = await client.beta.environments.retrieve(\"env_default\")"
          }
        ]
      }
    },
    "/v1/sessions": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Create a session",
        "description": "Creates a session for an agent, optionally with files and a first message.\n\nWithout `initial_events` the session is `idle` until you send its first message. With one message it starts at\nonce and is `running`. If the request fails, it returns an error and no session. If the server already created\nthe session's task in the Context app, it archives it.\n\nFiles sent with a `mount_path` are copied to the agent's disk, read-only, before the first turn. If a file can't\nbe copied, the session still runs and the file stays in the session's `inputs/` folder.\n\nThe key must have the `tasks:create` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | A resource isn't a file. Send each resource as `{type: \"file\", file_id}`, with an optional `mount_path`. |\n| 400 | `invalid_request_error` | A `mount_path` is empty, relative, ends in `/`, holds `.`, `..`, a repeated `/` or a control character, or is too long. Send a normalized absolute path. |\n| 400 | `invalid_request_error` | More than 100 files have a `mount_path`, two files name the same path, a path sits below another mounted file, or a mounted file is listed twice. Give each mounted file its own path, and list it once. |\n| 400 | `invalid_request_error` | An owner header is empty, or the request sends both `x-context-owner-user-id` and `x-context-owner-user-email`. Send one header with a member's ID or email, or omit both so the key's owner owns the session. |\n| 400 | `invalid_request_error` | The named owner isn't an active member of this key's organization. Check the ID or email. |\n| 400 | `invalid_request_error` | `initial_events` holds more than one event, or one that isn't a `user.message`. Send at most one `user.message`, then send the rest with [Send events](https://docs.context.ai/build/agent-api/openapi/events#send-events). |\n| 400 | `invalid_request_error` | The title is over 280 characters. Shorten it. |\n| 400 | `invalid_request_error` | `max_step_minutes: <n> is above this deployment's maximum of <max> minutes (NATIVE_MAX_TURN_BUDGET_MINUTES)`. Send `<max>` or less, or ask your administrator to raise the maximum. A value that isn't a whole number above `0` also returns `400`. |\n| 400 | `invalid_request_error` | The body sends non-empty `metadata` or `vault_ids`, a non-null `budget`, or agent overrides (any field in the `agent` object besides `type`, `id` and `version`). Remove them. |\n| 400 | `invalid_request_error` | A `file_id` names a file a session produced, which can't be attached. Download it and upload it, then attach the upload. |\n| 400 | `invalid_request_error` | `Agent \"<name>\" (<id>) is not in a workspace this session can run in.` The agent isn't in a workspace the session's owner works in. Create the agent with `metadata.workspace_id` set to a workspace the owner works in, or pick an agent that is in one. |\n| 403 | `permission_error` | The key lacks `tasks:create`, or isn't allowed to run this agent. An unknown agent ID returns the same `403`. Check the agent ID and the key's capabilities. |\n| 403 | `permission_error` | A personal key names a member other than its owner. Use a service account key to create sessions for other members, or omit the header. |\n| 403 | `permission_error` | The named owner can't run this agent. Pick an agent the member can run, or name another member. |\n| 404 | `not_found_error` | `environment_id` isn't `env_default`. Check the ID with [List environments](https://docs.context.ai/build/agent-api/openapi/environments#list-environments). |\n| 404 | `not_found_error` | A `file_id` isn't a file this key can read. Check the ID with [List files](https://docs.context.ai/build/agent-api/openapi/files#list-files). |",
        "operationId": "sessions_create",
        "parameters": [
          {
            "in": "header",
            "name": "x-context-owner-user-id",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The ID of the member who owns the session. A service account key can name any active member of its organization. The member owns the session, sees it in the Context app, and must be able to run the agent. A service account key reads and writes only the sessions it created, including those it created for other members. A personal key can name only its own owner. Send this header or `x-context-owner-user-email`, not both. Without either, the key's owner owns the session. Only this endpoint takes the owner headers."
            },
            "description": "The ID of the member who owns the session. A service account key can name any active member of its organization. The member owns the session, sees it in the Context app, and must be able to run the agent. A service account key reads and writes only the sessions it created, including those it created for other members. A personal key can name only its own owner. Send this header or `x-context-owner-user-email`, not both. Without either, the key's owner owns the session. Only this endpoint takes the owner headers."
          },
          {
            "in": "header",
            "name": "x-context-owner-user-email",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The email of the member who owns the session. The same rules apply as for `x-context-owner-user-id`. Send this header or `x-context-owner-user-id`, not both."
            },
            "description": "The email of the member who owns the session. The same rules apply as for `x-context-owner-user-id`. Send this header or `x-context-owner-user-id`, not both."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agent": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1
                      },
                      {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "agent"
                            ]
                          },
                          "version": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "id",
                          "type"
                        ],
                        "additionalProperties": false
                      }
                    ],
                    "description": "An agent ID from [List agents](https://docs.context.ai/build/agent-api/openapi/agents#list-agents). The object form is also accepted. Each agent has one version, so `version` must be `1` or left out. Any other field in the object returns `400`. An unknown agent ID returns `403`, not `404`."
                  },
                  "environment_id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The environment to run the session in: `env_default`. Any other ID returns `404`. See [Environments](https://docs.context.ai/build/agent-api/openapi/environments)."
                  },
                  "working_directory": {
                    "type": "string",
                    "description": "Leave it out. With `env_default`, any value returns `400`."
                  },
                  "initial_events": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "user.message"
                          ]
                        },
                        "content": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "text"
                                ]
                              },
                              "text": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "text"
                            ],
                            "additionalProperties": false
                          },
                          "minItems": 1
                        }
                      },
                      "required": [
                        "type",
                        "content"
                      ],
                      "additionalProperties": false
                    },
                    "maxItems": 1,
                    "description": "The events to start the session with. The array can hold at most one event, and it must be a `user.message`. See [Send events](https://docs.context.ai/build/agent-api/openapi/events#send-events). The response can return before the first turn starts. Before you send another message, wait for `session.status_running` on the [event stream](https://docs.context.ai/build/agent-api/openapi/events#stream-events)."
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "Not supported. Omit it or send `{}`. Any other value returns `400`."
                  },
                  "resources": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "file"
                          ]
                        },
                        "file_id": {
                          "type": "string",
                          "minLength": 1
                        },
                        "mount_path": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "default": null,
                          "description": "Where to put the file on the agent's disk, read-only. A path under `/workspace/` or `/mnt/session/uploads/` is used as given. Any other absolute path is placed under `/mnt/session/uploads`, so `/data/a.csv` becomes `/mnt/session/uploads/data/a.csv`. The maximum length is 4096 characters, and 255 bytes per path segment. Without it, the file is only in the session's `inputs/` folder."
                        }
                      },
                      "required": [
                        "type",
                        "file_id"
                      ],
                      "additionalProperties": false
                    },
                    "description": "The files to give the agent. Each is a `{type: \"file\", file_id, mount_path}` object, with a `file_id` from [Upload a file](https://docs.context.ai/build/agent-api/openapi/files#upload-a-file). Up to 50 files. A request with more than 50 files returns `500` instead of a named `400`, which is a known defect."
                  },
                  "title": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The session's title. The maximum length is 280 characters. Default: The first 80 characters of the first message, or `API session`."
                  },
                  "vault_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Not supported. Omit it or send `[]`. Any other value returns `400`."
                  },
                  "budget": {
                    "type": "null",
                    "description": "Not supported. Omit it or send `null`. Any other value returns `400`."
                  },
                  "max_step_minutes": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "A Context extension. The longest one step may run, in minutes. A step is everything the agent does to answer one message. When a step runs past it, the step is stopped and the session goes back to `idle`, so you can send another message. The maximum is your deployment's limit, which is `720` (12 hours) unless your administrator changed it. A larger value returns `400` with the maximum in the message. It is never lowered for you. The value is set when the session is created and applies to every step. The session object returns it. Default: `240`, or your deployment's maximum if that is lower."
                  }
                },
                "required": [
                  "agent",
                  "environment_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "agent": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                "environment_id": "env_default",
                "title": "Quarterly city report",
                "resources": [
                  {
                    "type": "file",
                    "file_id": "329409ba-f288-4b44-9c73-14a18150edee"
                  }
                ],
                "initial_events": [
                  {
                    "type": "user.message",
                    "content": [
                      {
                        "type": "text",
                        "text": "Read the attached cities.csv and name the largest city."
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "execution_identity": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "service_account"
                              ]
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        "mcp_servers": {
                          "type": "array",
                          "items": {},
                          "maxItems": 0
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "multiagent": {
                          "type": "null"
                        },
                        "name": {
                          "type": "string"
                        },
                        "skills": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "anthropic",
                                  "custom"
                                ]
                              },
                              "skill_id": {
                                "type": "string"
                              },
                              "version": {
                                "type": "string",
                                "enum": [
                                  "latest"
                                ]
                              }
                            },
                            "required": [
                              "type",
                              "skill_id",
                              "version"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "system": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tools": {
                          "type": "array",
                          "items": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "agent_toolset_20260401"
                                    ]
                                  },
                                  "configs": {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            },
                                            "url_sources": {
                                              "type": "null"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy",
                                            "url_sources"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "default_config": {
                                    "type": "object",
                                    "properties": {
                                      "enabled": {
                                        "type": "boolean"
                                      },
                                      "permission_policy": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_allow"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_ask"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "required": [
                                      "enabled",
                                      "permission_policy"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "configs",
                                  "default_config"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "custom"
                                    ]
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64,
                                    "pattern": "^[a-z][a-z0-9_]*$"
                                  },
                                  "description": {
                                    "type": "string",
                                    "maxLength": 2048,
                                    "default": ""
                                  },
                                  "input_schema": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "object"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "name",
                                  "input_schema"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "agent"
                          ]
                        },
                        "version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "description",
                        "execution_identity",
                        "mcp_servers",
                        "model",
                        "multiagent",
                        "name",
                        "skills",
                        "system",
                        "tools",
                        "type",
                        "version"
                      ],
                      "additionalProperties": false
                    },
                    "archived_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "budget": {
                      "type": "null"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "environment_id": {
                      "type": "string"
                    },
                    "max_step_minutes": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 1
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "outcome_evaluations": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    },
                    "resources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "file_id": {
                            "type": "string"
                          },
                          "mount_path": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "file"
                            ]
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "created_at",
                          "file_id",
                          "mount_path",
                          "type",
                          "updated_at"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "stats": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running",
                        "idle",
                        "terminated"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "session"
                      ]
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "input_tokens": {
                          "type": "number"
                        },
                        "output_tokens": {
                          "type": "number"
                        },
                        "cache_read_input_tokens": {
                          "type": "number"
                        },
                        "cache_creation": {
                          "type": "object",
                          "properties": {
                            "ephemeral_5m_input_tokens": {
                              "type": "number"
                            },
                            "ephemeral_1h_input_tokens": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false
                        },
                        "active_seconds": {
                          "type": "number"
                        },
                        "list_cost": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "amount": {
                              "type": "string",
                              "pattern": "^(0|[1-9][0-9]*)$"
                            },
                            "currency": {
                              "type": "string",
                              "enum": [
                                "USD"
                              ]
                            }
                          },
                          "required": [
                            "amount",
                            "currency"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "vault_ids": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    }
                  },
                  "required": [
                    "id",
                    "agent",
                    "archived_at",
                    "budget",
                    "created_at",
                    "environment_id",
                    "max_step_minutes",
                    "metadata",
                    "outcome_evaluations",
                    "resources",
                    "stats",
                    "status",
                    "title",
                    "type",
                    "updated_at",
                    "usage",
                    "vault_ids"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "dd13d728-93e3-440a-874c-4efeb58c97e0",
                  "agent": {
                    "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                    "description": "Answers questions about the sales pipeline",
                    "execution_identity": {
                      "type": "service_account"
                    },
                    "mcp_servers": [],
                    "model": {
                      "id": "default"
                    },
                    "multiagent": null,
                    "name": "Research Assistant",
                    "skills": [],
                    "system": null,
                    "tools": [],
                    "type": "agent",
                    "version": 1
                  },
                  "archived_at": null,
                  "budget": null,
                  "created_at": "2026-10-21T01:42:16.079Z",
                  "environment_id": "env_default",
                  "max_step_minutes": 240,
                  "metadata": {},
                  "outcome_evaluations": [],
                  "resources": [
                    {
                      "id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "created_at": "2026-10-21T01:41:11.028Z",
                      "file_id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "mount_path": "inputs/cities.csv",
                      "type": "file",
                      "updated_at": "2026-10-21T01:41:11.028Z"
                    }
                  ],
                  "stats": {},
                  "status": "running",
                  "title": "Quarterly city report",
                  "type": "session",
                  "updated_at": "2026-10-21T01:42:16.079Z",
                  "usage": {
                    "input_tokens": 0,
                    "output_tokens": 0,
                    "cache_read_input_tokens": 0,
                    "cache_creation": {
                      "ephemeral_5m_input_tokens": 0,
                      "ephemeral_1h_input_tokens": 0
                    },
                    "active_seconds": 0,
                    "list_cost": null
                  },
                  "vault_ids": []
                }
              }
            }
          },
          "400": {
            "description": "A resource isn't a file. Send each resource as `{type: \"file\", file_id}`, with an optional `mount_path`.\n\nA `mount_path` is empty, relative, ends in `/`, holds `.`, `..`, a repeated `/` or a control character, or is too long. Send a normalized absolute path.\n\nMore than 100 files have a `mount_path`, two files name the same path, a path sits below another mounted file, or a mounted file is listed twice. Give each mounted file its own path, and list it once.\n\nAn owner header is empty, or the request sends both `x-context-owner-user-id` and `x-context-owner-user-email`. Send one header with a member's ID or email, or omit both so the key's owner owns the session.\n\nThe named owner isn't an active member of this key's organization. Check the ID or email.\n\n`initial_events` holds more than one event, or one that isn't a `user.message`. Send at most one `user.message`, then send the rest with [Send events](https://docs.context.ai/build/agent-api/openapi/events#send-events).\n\nThe title is over 280 characters. Shorten it.\n\n`max_step_minutes: <n> is above this deployment's maximum of <max> minutes (NATIVE_MAX_TURN_BUDGET_MINUTES)`. Send `<max>` or less, or ask your administrator to raise the maximum. A value that isn't a whole number above `0` also returns `400`.\n\nThe body sends non-empty `metadata` or `vault_ids`, a non-null `budget`, or agent overrides (any field in the `agent` object besides `type`, `id` and `version`). Remove them.\n\nA `file_id` names a file a session produced, which can't be attached. Download it and upload it, then attach the upload.\n\n`Agent \"<name>\" (<id>) is not in a workspace this session can run in.` The agent isn't in a workspace the session's owner works in. Create the agent with `metadata.workspace_id` set to a workspace the owner works in, or pick an agent that is in one.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks `tasks:create`, or isn't allowed to run this agent. An unknown agent ID returns the same `403`. Check the agent ID and the key's capabilities.\n\nA personal key names a member other than its owner. Use a service account key to create sessions for other members, or omit the header.\n\nThe named owner can't run this agent. Pick an agent the member can run, or name another member.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "`environment_id` isn't `env_default`. Check the ID with [List environments](https://docs.context.ai/build/agent-api/openapi/environments#list-environments).\n\nA `file_id` isn't a file this key can read. Check the ID with [List files](https://docs.context.ai/build/agent-api/openapi/files#list-files).\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X POST \"$CONTEXT_BASE_URL/v1/sessions\" -H \"x-api-key: $CONTEXT_API_KEY\" -H \"content-type: application/json\" \\\n  -d '{\n    \"agent\": \"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\",\n    \"environment_id\": \"env_default\",\n    \"title\": \"Quarterly city report\",\n    \"resources\": [{\"type\": \"file\", \"file_id\": \"329409ba-f288-4b44-9c73-14a18150edee\"}],\n    \"initial_events\": [{\"type\": \"user.message\", \"content\": [{\"type\": \"text\", \"text\": \"Read the attached cities.csv and name the largest city.\"}]}]\n  }'"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "session = client.beta.sessions.create(\n    agent=\"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\",\n    environment_id=\"env_default\",\n    title=\"Quarterly city report\",\n    resources=[{\"type\": \"file\", \"file_id\": \"329409ba-f288-4b44-9c73-14a18150edee\"}],\n    initial_events=[{\"type\": \"user.message\", \"content\": [{\"type\": \"text\", \"text\": \"Read the attached cities.csv and name the largest city.\"}]}],\n)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const session = await client.beta.sessions.create({\n  agent: \"6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60\",\n  environment_id: \"env_default\",\n  title: \"Quarterly city report\",\n  resources: [{ type: \"file\", file_id: \"329409ba-f288-4b44-9c73-14a18150edee\" }],\n  initial_events: [{ type: \"user.message\", content: [{ type: \"text\", text: \"Read the attached cities.csv and name the largest city.\" }] }],\n})"
          }
        ]
      },
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "List sessions",
        "description": "Lists the sessions this key can see, newest first.\n\nA personal key reads its owner's sessions, including sessions a service account key created for its owner. A\nservice account key reads only the sessions it created, whoever owns them. If the key is limited to specific agents (its **Agent scope**), it reads only those\nagents' sessions.\n\nThe `statuses` filter applies after the server reads each page.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the matching sessions in `data`, newest first. `next_page` is the value to pass as `page` for the next page. A page can hold fewer sessions than `limit`, or none, and still have a `next_page` value. Keep requesting pages until `next_page` is `null`. `prev_page` is always `null`.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `order` is any value other than `desc`. Omit `order`. |\n| 400 | `invalid_request_error` | `statuses` contains an unknown value. Send only `idle`, `running`, `terminated` or `rescheduling`. |\n| 400 | `invalid_request_error` | The request includes `agent_version`, `deployment_id` or `memory_store_id`, which this API does not take. Remove them. |",
        "operationId": "sessions_list",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "The maximum number of sessions to return. Must be between 1 and 100."
            },
            "description": "The maximum number of sessions to return. Must be between 1 and 100."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "in": "query",
            "name": "created_at[gt]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only sessions created after this RFC 3339 timestamp."
            },
            "description": "Only sessions created after this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "created_at[gte]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only sessions created at or after this RFC 3339 timestamp."
            },
            "description": "Only sessions created at or after this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "created_at[lt]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only sessions created before this RFC 3339 timestamp."
            },
            "description": "Only sessions created before this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "created_at[lte]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only sessions created at or before this RFC 3339 timestamp."
            },
            "description": "Only sessions created at or before this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "agent_id",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The ID of the agent whose sessions to return."
            },
            "description": "The ID of the agent whose sessions to return."
          },
          {
            "in": "query",
            "name": "include_archived",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "description": "Whether to include archived sessions."
            },
            "description": "Whether to include archived sessions."
          },
          {
            "in": "query",
            "name": "order",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "desc"
              ],
              "default": "desc",
              "description": "Not supported. Omit it or send `desc`. Any other value returns `400`."
            },
            "description": "Not supported. Omit it or send `desc`. Any other value returns `400`."
          },
          {
            "in": "query",
            "name": "statuses",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "rescheduling",
                  "running",
                  "idle",
                  "terminated"
                ]
              },
              "description": "The statuses to return: `idle`, `running` or `terminated`. `rescheduling` is accepted for compatibility but never matches a session. To pass more than one, repeat the parameter: `statuses=idle&statuses=running`."
            },
            "description": "The statuses to return: `idle`, `running` or `terminated`. `rescheduling` is accepted for compatibility but never matches a session. To pass more than one, repeat the parameter: `statuses=idle&statuses=running`."
          },
          {
            "in": "query",
            "name": "statuses[]",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "rescheduling",
                  "running",
                  "idle",
                  "terminated"
                ]
              },
              "description": "The same filter as `statuses`, in the bracketed form the SDKs send: `statuses[]=idle&statuses[]=running`."
            },
            "description": "The same filter as `statuses`, in the bracketed form the SDKs send: `statuses[]=idle&statuses[]=running`."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the matching sessions in `data`, newest first. `next_page` is the value to pass as `page` for the next page. A page can hold fewer sessions than `limit`, or none, and still have a `next_page` value. Keep requesting pages until `next_page` is `null`. `prev_page` is always `null`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "agent": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "description": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "execution_identity": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "service_account"
                                    ]
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              "mcp_servers": {
                                "type": "array",
                                "items": {},
                                "maxItems": 0
                              },
                              "model": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id"
                                ],
                                "additionalProperties": false
                              },
                              "multiagent": {
                                "type": "null"
                              },
                              "name": {
                                "type": "string"
                              },
                              "skills": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "anthropic",
                                        "custom"
                                      ]
                                    },
                                    "skill_id": {
                                      "type": "string"
                                    },
                                    "version": {
                                      "type": "string",
                                      "enum": [
                                        "latest"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "skill_id",
                                    "version"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "system": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "tools": {
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "agent_toolset_20260401"
                                          ]
                                        },
                                        "configs": {
                                          "type": "array",
                                          "items": {
                                            "anyOf": [
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "bash"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "bash"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy"
                                                ],
                                                "additionalProperties": false
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "edit"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "edit"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy"
                                                ],
                                                "additionalProperties": false
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "read"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "read"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy"
                                                ],
                                                "additionalProperties": false
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "write"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "write"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy"
                                                ],
                                                "additionalProperties": false
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "glob"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "glob"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy"
                                                ],
                                                "additionalProperties": false
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "grep"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "grep"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy"
                                                ],
                                                "additionalProperties": false
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "web_fetch"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "web_fetch"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  },
                                                  "url_sources": {
                                                    "type": "null"
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy",
                                                  "url_sources"
                                                ],
                                                "additionalProperties": false
                                              },
                                              {
                                                "type": "object",
                                                "properties": {
                                                  "type": {
                                                    "type": "string",
                                                    "enum": [
                                                      "web_search"
                                                    ]
                                                  },
                                                  "name": {
                                                    "type": "string",
                                                    "enum": [
                                                      "web_search"
                                                    ]
                                                  },
                                                  "enabled": {
                                                    "type": "boolean"
                                                  },
                                                  "permission_policy": {
                                                    "anyOf": [
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_allow"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      },
                                                      {
                                                        "type": "object",
                                                        "properties": {
                                                          "type": {
                                                            "type": "string",
                                                            "enum": [
                                                              "always_ask"
                                                            ]
                                                          }
                                                        },
                                                        "required": [
                                                          "type"
                                                        ],
                                                        "additionalProperties": false
                                                      }
                                                    ]
                                                  }
                                                },
                                                "required": [
                                                  "type",
                                                  "name",
                                                  "enabled",
                                                  "permission_policy"
                                                ],
                                                "additionalProperties": false
                                              }
                                            ]
                                          }
                                        },
                                        "default_config": {
                                          "type": "object",
                                          "properties": {
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "configs",
                                        "default_config"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "custom"
                                          ]
                                        },
                                        "name": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 64,
                                          "pattern": "^[a-z][a-z0-9_]*$"
                                        },
                                        "description": {
                                          "type": "string",
                                          "maxLength": 2048,
                                          "default": ""
                                        },
                                        "input_schema": {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "object"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type"
                                          ],
                                          "additionalProperties": true
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "name",
                                        "input_schema"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent"
                                ]
                              },
                              "version": {
                                "type": "number",
                                "enum": [
                                  1
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "description",
                              "execution_identity",
                              "mcp_servers",
                              "model",
                              "multiagent",
                              "name",
                              "skills",
                              "system",
                              "tools",
                              "type",
                              "version"
                            ],
                            "additionalProperties": false
                          },
                          "archived_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "budget": {
                            "type": "null"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "environment_id": {
                            "type": "string"
                          },
                          "max_step_minutes": {
                            "type": [
                              "integer",
                              "null"
                            ],
                            "minimum": 1
                          },
                          "metadata": {
                            "type": "object",
                            "properties": {},
                            "additionalProperties": false
                          },
                          "outcome_evaluations": {
                            "type": "array",
                            "items": {},
                            "maxItems": 0
                          },
                          "resources": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "created_at": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "file_id": {
                                  "type": "string"
                                },
                                "mount_path": {
                                  "type": "string"
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "file"
                                  ]
                                },
                                "updated_at": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              },
                              "required": [
                                "id",
                                "created_at",
                                "file_id",
                                "mount_path",
                                "type",
                                "updated_at"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "stats": {
                            "type": "object",
                            "properties": {},
                            "additionalProperties": false
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "running",
                              "idle",
                              "terminated"
                            ]
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "session"
                            ]
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input_tokens": {
                                "type": "number"
                              },
                              "output_tokens": {
                                "type": "number"
                              },
                              "cache_read_input_tokens": {
                                "type": "number"
                              },
                              "cache_creation": {
                                "type": "object",
                                "properties": {
                                  "ephemeral_5m_input_tokens": {
                                    "type": "number"
                                  },
                                  "ephemeral_1h_input_tokens": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false
                              },
                              "active_seconds": {
                                "type": "number"
                              },
                              "list_cost": {
                                "type": [
                                  "object",
                                  "null"
                                ],
                                "properties": {
                                  "amount": {
                                    "type": "string",
                                    "pattern": "^(0|[1-9][0-9]*)$"
                                  },
                                  "currency": {
                                    "type": "string",
                                    "enum": [
                                      "USD"
                                    ]
                                  }
                                },
                                "required": [
                                  "amount",
                                  "currency"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "additionalProperties": false
                          },
                          "vault_ids": {
                            "type": "array",
                            "items": {},
                            "maxItems": 0
                          }
                        },
                        "required": [
                          "id",
                          "agent",
                          "archived_at",
                          "budget",
                          "created_at",
                          "environment_id",
                          "max_step_minutes",
                          "metadata",
                          "outcome_evaluations",
                          "resources",
                          "stats",
                          "status",
                          "title",
                          "type",
                          "updated_at",
                          "usage",
                          "vault_ids"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "prev_page": {
                      "type": "null"
                    }
                  },
                  "required": [
                    "data",
                    "next_page",
                    "prev_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "dd13d728-93e3-440a-874c-4efeb58c97e0",
                      "agent": {
                        "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                        "description": "Answers questions about the sales pipeline",
                        "execution_identity": {
                          "type": "service_account"
                        },
                        "mcp_servers": [],
                        "model": {
                          "id": "default"
                        },
                        "multiagent": null,
                        "name": "Research Assistant",
                        "skills": [],
                        "system": null,
                        "tools": [],
                        "type": "agent",
                        "version": 1
                      },
                      "archived_at": null,
                      "budget": null,
                      "created_at": "2026-10-21T01:42:16.079Z",
                      "environment_id": "env_default",
                      "max_step_minutes": 240,
                      "metadata": {},
                      "outcome_evaluations": [],
                      "resources": [
                        {
                          "id": "329409ba-f288-4b44-9c73-14a18150edee",
                          "created_at": "2026-10-21T01:41:11.028Z",
                          "file_id": "329409ba-f288-4b44-9c73-14a18150edee",
                          "mount_path": "inputs/cities.csv",
                          "type": "file",
                          "updated_at": "2026-10-21T01:41:11.028Z"
                        }
                      ],
                      "stats": {},
                      "status": "idle",
                      "title": "Quarterly city report",
                      "type": "session",
                      "updated_at": "2026-10-21T01:42:29.719Z",
                      "usage": {
                        "input_tokens": 12,
                        "output_tokens": 318,
                        "cache_read_input_tokens": 133496,
                        "cache_creation": {
                          "ephemeral_5m_input_tokens": 2210,
                          "ephemeral_1h_input_tokens": 0
                        },
                        "active_seconds": 7.331,
                        "list_cost": {
                          "amount": "6",
                          "currency": "USD"
                        }
                      },
                      "vault_ids": []
                    }
                  ],
                  "next_page": null,
                  "prev_page": null
                }
              }
            }
          },
          "400": {
            "description": "`order` is any value other than `desc`. Omit `order`.\n\n`statuses` contains an unknown value. Send only `idle`, `running`, `terminated` or `rescheduling`.\n\nThe request includes `agent_version`, `deployment_id` or `memory_store_id`, which this API does not take. Remove them.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/sessions?limit=20&statuses[]=idle\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "for session in client.beta.sessions.list(limit=20, statuses=[\"idle\"]):  # auto-paginates\n    print(session.id, session.status, session.title)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "for await (const session of client.beta.sessions.list({ limit: 20, statuses: [\"idle\"] })) console.log(session.id, session.status)"
          }
        ]
      }
    },
    "/v1/sessions/{session_id}": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "summary": "Get a session",
        "description": "Returns a session with its status and token totals.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 404 | `not_found_error` | No session with this ID exists, or this key can't read it. Check the session ID and the key you are using. |\n| 404 | `not_found_error` | The ID is a task that isn't a session, such as one started in the app (see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions)). Read it with the Task API, `GET /api/v1/tasks/roots/{taskId}`. |\n| 503 | `api_error` | The session's history is still being indexed. Retry the request shortly. |",
        "operationId": "sessions_retrieve",
        "parameters": [
          {
            "in": "path",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the session to retrieve."
            },
            "description": "The ID of the session to retrieve."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "execution_identity": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "service_account"
                              ]
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        "mcp_servers": {
                          "type": "array",
                          "items": {},
                          "maxItems": 0
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "multiagent": {
                          "type": "null"
                        },
                        "name": {
                          "type": "string"
                        },
                        "skills": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "anthropic",
                                  "custom"
                                ]
                              },
                              "skill_id": {
                                "type": "string"
                              },
                              "version": {
                                "type": "string",
                                "enum": [
                                  "latest"
                                ]
                              }
                            },
                            "required": [
                              "type",
                              "skill_id",
                              "version"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "system": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tools": {
                          "type": "array",
                          "items": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "agent_toolset_20260401"
                                    ]
                                  },
                                  "configs": {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            },
                                            "url_sources": {
                                              "type": "null"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy",
                                            "url_sources"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "default_config": {
                                    "type": "object",
                                    "properties": {
                                      "enabled": {
                                        "type": "boolean"
                                      },
                                      "permission_policy": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_allow"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_ask"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "required": [
                                      "enabled",
                                      "permission_policy"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "configs",
                                  "default_config"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "custom"
                                    ]
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64,
                                    "pattern": "^[a-z][a-z0-9_]*$"
                                  },
                                  "description": {
                                    "type": "string",
                                    "maxLength": 2048,
                                    "default": ""
                                  },
                                  "input_schema": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "object"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "name",
                                  "input_schema"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "agent"
                          ]
                        },
                        "version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "description",
                        "execution_identity",
                        "mcp_servers",
                        "model",
                        "multiagent",
                        "name",
                        "skills",
                        "system",
                        "tools",
                        "type",
                        "version"
                      ],
                      "additionalProperties": false
                    },
                    "archived_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "budget": {
                      "type": "null"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "environment_id": {
                      "type": "string"
                    },
                    "max_step_minutes": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 1
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "outcome_evaluations": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    },
                    "resources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "file_id": {
                            "type": "string"
                          },
                          "mount_path": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "file"
                            ]
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "created_at",
                          "file_id",
                          "mount_path",
                          "type",
                          "updated_at"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "stats": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running",
                        "idle",
                        "terminated"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "session"
                      ]
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "input_tokens": {
                          "type": "number"
                        },
                        "output_tokens": {
                          "type": "number"
                        },
                        "cache_read_input_tokens": {
                          "type": "number"
                        },
                        "cache_creation": {
                          "type": "object",
                          "properties": {
                            "ephemeral_5m_input_tokens": {
                              "type": "number"
                            },
                            "ephemeral_1h_input_tokens": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false
                        },
                        "active_seconds": {
                          "type": "number"
                        },
                        "list_cost": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "amount": {
                              "type": "string",
                              "pattern": "^(0|[1-9][0-9]*)$"
                            },
                            "currency": {
                              "type": "string",
                              "enum": [
                                "USD"
                              ]
                            }
                          },
                          "required": [
                            "amount",
                            "currency"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "vault_ids": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    }
                  },
                  "required": [
                    "id",
                    "agent",
                    "archived_at",
                    "budget",
                    "created_at",
                    "environment_id",
                    "max_step_minutes",
                    "metadata",
                    "outcome_evaluations",
                    "resources",
                    "stats",
                    "status",
                    "title",
                    "type",
                    "updated_at",
                    "usage",
                    "vault_ids"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "dd13d728-93e3-440a-874c-4efeb58c97e0",
                  "agent": {
                    "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                    "description": "Answers questions about the sales pipeline",
                    "execution_identity": {
                      "type": "service_account"
                    },
                    "mcp_servers": [],
                    "model": {
                      "id": "default"
                    },
                    "multiagent": null,
                    "name": "Research Assistant",
                    "skills": [],
                    "system": null,
                    "tools": [],
                    "type": "agent",
                    "version": 1
                  },
                  "archived_at": null,
                  "budget": null,
                  "created_at": "2026-10-21T01:42:16.079Z",
                  "environment_id": "env_default",
                  "max_step_minutes": 240,
                  "metadata": {},
                  "outcome_evaluations": [],
                  "resources": [
                    {
                      "id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "created_at": "2026-10-21T01:41:11.028Z",
                      "file_id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "mount_path": "inputs/cities.csv",
                      "type": "file",
                      "updated_at": "2026-10-21T01:41:11.028Z"
                    }
                  ],
                  "stats": {},
                  "status": "idle",
                  "title": "Quarterly city report",
                  "type": "session",
                  "updated_at": "2026-10-21T01:42:29.719Z",
                  "usage": {
                    "input_tokens": 12,
                    "output_tokens": 318,
                    "cache_read_input_tokens": 133496,
                    "cache_creation": {
                      "ephemeral_5m_input_tokens": 2210,
                      "ephemeral_1h_input_tokens": 0
                    },
                    "active_seconds": 7.331,
                    "list_cost": {
                      "amount": "6",
                      "currency": "USD"
                    }
                  },
                  "vault_ids": []
                }
              }
            }
          },
          "400": {
            "description": "A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No session with this ID exists, or this key can't read it. Check the session ID and the key you are using.\n\nThe ID is a task that isn't a session, such as one started in the app (see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions)). Read it with the Task API, `GET /api/v1/tasks/roots/{taskId}`.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "503": {
            "description": "The session's history is still being indexed. Retry the request shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "The session is catching up; retry shortly"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "session = client.beta.sessions.retrieve(\"dd13d728-93e3-440a-874c-4efeb58c97e0\")\nprint(session.status, session.usage)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const session = await client.beta.sessions.retrieve(\"dd13d728-93e3-440a-874c-4efeb58c97e0\")"
          }
        ]
      },
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Rename a session",
        "description": "Changes a session's title and returns the updated session.\n\nOnly the title can change. Sending `agent`, `vault_ids`, `budget` or a non-empty `metadata` returns `400`. An empty body, or `metadata: {}`, returns `200` and changes nothing.\n\nThe key must have the `tasks:create` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The title is empty, contains only whitespace or is longer than 280 characters. Send a title of 1 to 280 characters, or `null` to clear it. |\n| 400 | `invalid_request_error` | The body includes `agent`, `vault_ids`, `budget` or a non-empty `metadata`. Send only `title`. |\n| 403 | `permission_error` | The key does not act for the session's owner, or the owner is no longer an active member. Use the owner's personal key or the service account key that created the session. |\n| 404 | `not_found_error` | No session with this ID exists, or this key can't read it. Check the session ID. |",
        "operationId": "sessions_update",
        "parameters": [
          {
            "in": "path",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the session to rename."
            },
            "description": "The ID of the session to rename."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 1,
                    "maxLength": 280,
                    "description": "The new title. Must be between 1 and 280 characters after trimming (Anthropic: 500). Send `null` to clear the title."
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "description": "Not supported. Omit it or send `{}`. Any other value returns `400`."
                  },
                  "agent": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "object",
                        "properties": {},
                        "additionalProperties": true
                      }
                    ],
                    "description": "Not supported. Any value returns `400`."
                  },
                  "vault_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Not supported. Any value returns `400`."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "title": "Q3 city report"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "execution_identity": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "service_account"
                              ]
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        "mcp_servers": {
                          "type": "array",
                          "items": {},
                          "maxItems": 0
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "multiagent": {
                          "type": "null"
                        },
                        "name": {
                          "type": "string"
                        },
                        "skills": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "anthropic",
                                  "custom"
                                ]
                              },
                              "skill_id": {
                                "type": "string"
                              },
                              "version": {
                                "type": "string",
                                "enum": [
                                  "latest"
                                ]
                              }
                            },
                            "required": [
                              "type",
                              "skill_id",
                              "version"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "system": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tools": {
                          "type": "array",
                          "items": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "agent_toolset_20260401"
                                    ]
                                  },
                                  "configs": {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            },
                                            "url_sources": {
                                              "type": "null"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy",
                                            "url_sources"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "default_config": {
                                    "type": "object",
                                    "properties": {
                                      "enabled": {
                                        "type": "boolean"
                                      },
                                      "permission_policy": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_allow"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_ask"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "required": [
                                      "enabled",
                                      "permission_policy"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "configs",
                                  "default_config"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "custom"
                                    ]
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64,
                                    "pattern": "^[a-z][a-z0-9_]*$"
                                  },
                                  "description": {
                                    "type": "string",
                                    "maxLength": 2048,
                                    "default": ""
                                  },
                                  "input_schema": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "object"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "name",
                                  "input_schema"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "agent"
                          ]
                        },
                        "version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "description",
                        "execution_identity",
                        "mcp_servers",
                        "model",
                        "multiagent",
                        "name",
                        "skills",
                        "system",
                        "tools",
                        "type",
                        "version"
                      ],
                      "additionalProperties": false
                    },
                    "archived_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "budget": {
                      "type": "null"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "environment_id": {
                      "type": "string"
                    },
                    "max_step_minutes": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 1
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "outcome_evaluations": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    },
                    "resources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "file_id": {
                            "type": "string"
                          },
                          "mount_path": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "file"
                            ]
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "created_at",
                          "file_id",
                          "mount_path",
                          "type",
                          "updated_at"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "stats": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running",
                        "idle",
                        "terminated"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "session"
                      ]
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "input_tokens": {
                          "type": "number"
                        },
                        "output_tokens": {
                          "type": "number"
                        },
                        "cache_read_input_tokens": {
                          "type": "number"
                        },
                        "cache_creation": {
                          "type": "object",
                          "properties": {
                            "ephemeral_5m_input_tokens": {
                              "type": "number"
                            },
                            "ephemeral_1h_input_tokens": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false
                        },
                        "active_seconds": {
                          "type": "number"
                        },
                        "list_cost": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "amount": {
                              "type": "string",
                              "pattern": "^(0|[1-9][0-9]*)$"
                            },
                            "currency": {
                              "type": "string",
                              "enum": [
                                "USD"
                              ]
                            }
                          },
                          "required": [
                            "amount",
                            "currency"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "vault_ids": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    }
                  },
                  "required": [
                    "id",
                    "agent",
                    "archived_at",
                    "budget",
                    "created_at",
                    "environment_id",
                    "max_step_minutes",
                    "metadata",
                    "outcome_evaluations",
                    "resources",
                    "stats",
                    "status",
                    "title",
                    "type",
                    "updated_at",
                    "usage",
                    "vault_ids"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "dd13d728-93e3-440a-874c-4efeb58c97e0",
                  "agent": {
                    "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                    "description": "Answers questions about the sales pipeline",
                    "execution_identity": {
                      "type": "service_account"
                    },
                    "mcp_servers": [],
                    "model": {
                      "id": "default"
                    },
                    "multiagent": null,
                    "name": "Research Assistant",
                    "skills": [],
                    "system": null,
                    "tools": [],
                    "type": "agent",
                    "version": 1
                  },
                  "archived_at": null,
                  "budget": null,
                  "created_at": "2026-10-21T01:42:16.079Z",
                  "environment_id": "env_default",
                  "max_step_minutes": 240,
                  "metadata": {},
                  "outcome_evaluations": [],
                  "resources": [
                    {
                      "id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "created_at": "2026-10-21T01:41:11.028Z",
                      "file_id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "mount_path": "inputs/cities.csv",
                      "type": "file",
                      "updated_at": "2026-10-21T01:41:11.028Z"
                    }
                  ],
                  "stats": {},
                  "status": "idle",
                  "title": "Q3 city report",
                  "type": "session",
                  "updated_at": "2026-10-21T01:42:29.719Z",
                  "usage": {
                    "input_tokens": 12,
                    "output_tokens": 318,
                    "cache_read_input_tokens": 133496,
                    "cache_creation": {
                      "ephemeral_5m_input_tokens": 2210,
                      "ephemeral_1h_input_tokens": 0
                    },
                    "active_seconds": 7.331,
                    "list_cost": {
                      "amount": "6",
                      "currency": "USD"
                    }
                  },
                  "vault_ids": []
                }
              }
            }
          },
          "400": {
            "description": "The title is empty, contains only whitespace or is longer than 280 characters. Send a title of 1 to 280 characters, or `null` to clear it.\n\nThe body includes `agent`, `vault_ids`, `budget` or a non-empty `metadata`. Send only `title`.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key does not act for the session's owner, or the owner is no longer an active member. Use the owner's personal key or the service account key that created the session.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No session with this ID exists, or this key can't read it. Check the session ID.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X POST \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0\" -H \"x-api-key: $CONTEXT_API_KEY\" \\\n  -H \"content-type: application/json\" -d '{\"title\": \"Q3 city report\"}'"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "session = client.beta.sessions.update(\"dd13d728-93e3-440a-874c-4efeb58c97e0\", title=\"Q3 city report\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const session = await client.beta.sessions.update(\"dd13d728-93e3-440a-874c-4efeb58c97e0\", { title: \"Q3 city report\" })"
          }
        ]
      },
      "delete": {
        "tags": [
          "Sessions"
        ],
        "summary": "Delete a session",
        "description": "Permanently deletes a session and its data.\n\nDeleting removes the session's task in the Context app and the tasks of its subagents, with their events and\ntranscripts. It also removes the session's `inputs/` copies and outputs, its sandbox and saved workspace, its\nLLM traces, and the memories its runs saved. The session no longer appears in the task history in the Context\napp, and any open stream on the session ends. [Response](https://docs.context.ai/build/agent-api/openapi/sessions#delete-a-session) lists what stays.\n\nDelete a session with the owner's personal key or with the service account key that created it. Keys don't have\n`sessions:delete` by default. The key's owner must grant it when creating the key, and an existing key can't gain\nit.\n\nNothing deletes a session for you. Your deployment keeps a session and its history until you delete it with\nthis request, and archiving a session keeps its history too.\n\nIf a turn is running, the request returns `409` and the turn keeps running. Send a `user.interrupt`, wait for\nthe session to go idle, then delete it. A session waiting for a tool approval counts as idle. If another change\nto the session is in progress, for example an event you sent, the delete can return `409`. The session still\nexists, but its traces, saved workspace and recordings may already be deleted. Retry the delete.\nFiles you uploaded with [Upload a file](https://docs.context.ai/build/agent-api/openapi/files#upload-a-file) are kept. Delete them with\n[Delete a file](https://docs.context.ai/build/agent-api/openapi/files#delete-a-file).\n\nThe key must have the `sessions:delete` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a receipt whose `type` is `session_deleted`.\n\n`removed` counts what was deleted:\n\n| Field | What it counts |\n|---|---|\n| `tasks` | The session's task and its subagents' tasks. |\n| `runs` | The runs of those tasks, with their events, transcripts and state. |\n| `sandboxes` | The sandboxes the runs still held, now shut down. |\n| `dispatch_rows_scrubbed` | Dispatch history rows whose prompt, title and output text were cleared. |\n| `approval_previews_purged` | Approval cards whose preview of the action's content was cleared. |\n| `billing_events_unlinked` | Billing usage rows whose link to the session's runs was cleared. |\n| `agent_memories_deleted` | Memories the session's runs saved. |\n| `traces` | `deleted`, or `no_trace_store` when your deployment keeps no traces. |\n\n`kept` lists each store that stays, with a `store` and a `reason`:\n\n| `store` | What stays |\n|---|---|\n| `billing_meter_events` | Billing usage and each run's billed cost, kept for invoicing. They hold counts and prices, not conversation content. |\n| `audit_log` | Audit records of who did what, when, and with what outcome. |\n| `dispatch_ledger_rows` | Dispatch history, with its prompt, title and output text cleared and its task link removed. |\n| `uploaded_files` | Files uploaded with [Upload a file](https://docs.context.ai/build/agent-api/openapi/files#upload-a-file). The session's own copy in its `inputs/` folder is deleted. |\n| `agent_memory_notes` | Notes in the agent's own `.memory` folder in Drive. They belong to the agent and aren't linked to any run. Memories the session's runs saved are deleted. |\n| `storage_residue` | Deleted data that storage keeps for a while: trace rows until the trace store's next merge, and earlier versions of removed files on storage that keeps versions, until they expire. No API returns them. |\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The request sends a query parameter. Remove it. |\n| 403 | `permission_error` | The key lacks `sessions:delete`. Create a key that has `sessions:delete`. Only the key's owner can grant it. |\n| 403 | `permission_error` | The key doesn't act for the session's owner. Use the owner's personal key or the service account key that created the session. |\n| 403 | `permission_error` | The session's owner doesn't have permission to delete it in the Context app, or is no longer an active member. No key can delete the session in that case. |\n| 404 | `not_found_error` | No session with this ID exists, it is already deleted, or this key can't read it. Check the session ID. |\n| 409 | `invalid_request_error` | A turn is running. Send a `user.interrupt`, wait until the session is idle, then delete it. |\n| 409 | `invalid_request_error` | Another change to the session was in progress. The session still exists, but its traces, saved workspace and recordings may already be deleted. Retry the delete. |\n| 500 | `api_error` | The session's traces couldn't be removed, so the session wasn't deleted. Retry the delete. |",
        "operationId": "sessions_delete",
        "parameters": [
          {
            "in": "path",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the session to delete."
            },
            "description": "The ID of the session to delete."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a receipt whose `type` is `session_deleted`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "session_deleted"
                      ]
                    },
                    "removed": {
                      "type": "object",
                      "properties": {
                        "tasks": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "runs": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "sandboxes": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "dispatch_rows_scrubbed": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "approval_previews_purged": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "billing_events_unlinked": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "agent_memories_deleted": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "traces": {
                          "type": "string",
                          "enum": [
                            "deleted",
                            "queued",
                            "no_trace_store",
                            "failed"
                          ]
                        }
                      },
                      "required": [
                        "tasks",
                        "runs",
                        "sandboxes",
                        "dispatch_rows_scrubbed",
                        "approval_previews_purged",
                        "billing_events_unlinked",
                        "agent_memories_deleted",
                        "traces"
                      ],
                      "additionalProperties": false
                    },
                    "kept": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "store": {
                            "type": "string",
                            "enum": [
                              "billing_meter_events",
                              "audit_log",
                              "dispatch_ledger_rows",
                              "uploaded_files",
                              "agent_memory_notes",
                              "storage_residue"
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "store",
                          "reason"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "removed",
                    "kept"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "dd13d728-93e3-440a-874c-4efeb58c97e0",
                  "type": "session_deleted",
                  "removed": {
                    "tasks": 1,
                    "runs": 1,
                    "sandboxes": 1,
                    "dispatch_rows_scrubbed": 1,
                    "approval_previews_purged": 0,
                    "billing_events_unlinked": 2,
                    "agent_memories_deleted": 3,
                    "traces": "deleted"
                  },
                  "kept": [
                    {
                      "store": "billing_meter_events",
                      "reason": "..."
                    },
                    {
                      "store": "audit_log",
                      "reason": "..."
                    },
                    {
                      "store": "dispatch_ledger_rows",
                      "reason": "..."
                    },
                    {
                      "store": "uploaded_files",
                      "reason": "..."
                    },
                    {
                      "store": "agent_memory_notes",
                      "reason": "..."
                    },
                    {
                      "store": "storage_residue",
                      "reason": "..."
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request sends a query parameter. Remove it.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks `sessions:delete`. Create a key that has `sessions:delete`. Only the key's owner can grant it.\n\nThe key doesn't act for the session's owner. Use the owner's personal key or the service account key that created the session.\n\nThe session's owner doesn't have permission to delete it in the Context app, or is no longer an active member. No key can delete the session in that case.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No session with this ID exists, it is already deleted, or this key can't read it. Check the session ID.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "409": {
            "description": "A turn is running. Send a `user.interrupt`, wait until the session is idle, then delete it.\n\nAnother change to the session was in progress. The session still exists, but its traces, saved workspace and recordings may already be deleted. Retry the delete.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "Ask changed before the answer"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "The session's traces couldn't be removed, so the session wasn't deleted. Retry the delete.\n\nAn unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X DELETE \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "deleted = client.beta.sessions.delete(\"dd13d728-93e3-440a-874c-4efeb58c97e0\")\nprint(deleted.type, deleted.removed)  # session_deleted {'tasks': 1, ...}"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const deleted = await client.beta.sessions.delete(\"dd13d728-93e3-440a-874c-4efeb58c97e0\")\nconsole.log(deleted.type) // \"session_deleted\"; removed and kept are not in the SDK's types"
          }
        ]
      }
    },
    "/v1/sessions/{session_id}/archive": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "summary": "Archive a session",
        "description": "Ends a session permanently. Its history stays readable.\n\nThe status becomes `terminated`. After that, sending an event to the session returns `400`, and an open stream\nends with an `invalid_request_error` frame. Archiving an archived session returns it unchanged. To remove a\nsession's data permanently, [delete it](https://docs.context.ai/build/agent-api/openapi/sessions#delete-a-session) instead. To list archived sessions, call\n[List sessions](https://docs.context.ai/build/agent-api/openapi/sessions#list-sessions) with `include_archived=true`.\n\nYou can archive a running session. Its current turn is not cut short, and the run stops once the turn is over.\nTo stop the turn at once, send a `user.interrupt` before you archive.\n\nThe key must have the `tasks:create` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 403 | `permission_error` | The key does not act for the session's owner, or the owner is no longer an active member. Use the owner's personal key or the service account key that created the session. |\n| 404 | `not_found_error` | No session with this ID exists, or this key can't read it. Check the session ID. |",
        "operationId": "sessions_archive",
        "parameters": [
          {
            "in": "path",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the session to archive."
            },
            "description": "The ID of the session to archive."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the session object. For every field, see [Sessions](https://docs.context.ai/build/agent-api/openapi/sessions).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "execution_identity": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "service_account"
                              ]
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        "mcp_servers": {
                          "type": "array",
                          "items": {},
                          "maxItems": 0
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "multiagent": {
                          "type": "null"
                        },
                        "name": {
                          "type": "string"
                        },
                        "skills": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "anthropic",
                                  "custom"
                                ]
                              },
                              "skill_id": {
                                "type": "string"
                              },
                              "version": {
                                "type": "string",
                                "enum": [
                                  "latest"
                                ]
                              }
                            },
                            "required": [
                              "type",
                              "skill_id",
                              "version"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "system": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tools": {
                          "type": "array",
                          "items": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "agent_toolset_20260401"
                                    ]
                                  },
                                  "configs": {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "bash"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "edit"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "read"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "write"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "glob"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "grep"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_fetch"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            },
                                            "url_sources": {
                                              "type": "null"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy",
                                            "url_sources"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "name": {
                                              "type": "string",
                                              "enum": [
                                                "web_search"
                                              ]
                                            },
                                            "enabled": {
                                              "type": "boolean"
                                            },
                                            "permission_policy": {
                                              "anyOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_allow"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "enum": [
                                                        "always_ask"
                                                      ]
                                                    }
                                                  },
                                                  "required": [
                                                    "type"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "name",
                                            "enabled",
                                            "permission_policy"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "default_config": {
                                    "type": "object",
                                    "properties": {
                                      "enabled": {
                                        "type": "boolean"
                                      },
                                      "permission_policy": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_allow"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "always_ask"
                                                ]
                                              }
                                            },
                                            "required": [
                                              "type"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "required": [
                                      "enabled",
                                      "permission_policy"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "configs",
                                  "default_config"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "custom"
                                    ]
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64,
                                    "pattern": "^[a-z][a-z0-9_]*$"
                                  },
                                  "description": {
                                    "type": "string",
                                    "maxLength": 2048,
                                    "default": ""
                                  },
                                  "input_schema": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "object"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "name",
                                  "input_schema"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "agent"
                          ]
                        },
                        "version": {
                          "type": "number",
                          "enum": [
                            1
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "description",
                        "execution_identity",
                        "mcp_servers",
                        "model",
                        "multiagent",
                        "name",
                        "skills",
                        "system",
                        "tools",
                        "type",
                        "version"
                      ],
                      "additionalProperties": false
                    },
                    "archived_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "budget": {
                      "type": "null"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "environment_id": {
                      "type": "string"
                    },
                    "max_step_minutes": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 1
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "outcome_evaluations": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    },
                    "resources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "file_id": {
                            "type": "string"
                          },
                          "mount_path": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "file"
                            ]
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "created_at",
                          "file_id",
                          "mount_path",
                          "type",
                          "updated_at"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "stats": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running",
                        "idle",
                        "terminated"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "session"
                      ]
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "input_tokens": {
                          "type": "number"
                        },
                        "output_tokens": {
                          "type": "number"
                        },
                        "cache_read_input_tokens": {
                          "type": "number"
                        },
                        "cache_creation": {
                          "type": "object",
                          "properties": {
                            "ephemeral_5m_input_tokens": {
                              "type": "number"
                            },
                            "ephemeral_1h_input_tokens": {
                              "type": "number"
                            }
                          },
                          "additionalProperties": false
                        },
                        "active_seconds": {
                          "type": "number"
                        },
                        "list_cost": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "amount": {
                              "type": "string",
                              "pattern": "^(0|[1-9][0-9]*)$"
                            },
                            "currency": {
                              "type": "string",
                              "enum": [
                                "USD"
                              ]
                            }
                          },
                          "required": [
                            "amount",
                            "currency"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "vault_ids": {
                      "type": "array",
                      "items": {},
                      "maxItems": 0
                    }
                  },
                  "required": [
                    "id",
                    "agent",
                    "archived_at",
                    "budget",
                    "created_at",
                    "environment_id",
                    "max_step_minutes",
                    "metadata",
                    "outcome_evaluations",
                    "resources",
                    "stats",
                    "status",
                    "title",
                    "type",
                    "updated_at",
                    "usage",
                    "vault_ids"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "dd13d728-93e3-440a-874c-4efeb58c97e0",
                  "agent": {
                    "id": "6f1c2a9e-0d4b-4c57-9a3e-2b7d8e1f4c60",
                    "description": "Answers questions about the sales pipeline",
                    "execution_identity": {
                      "type": "service_account"
                    },
                    "mcp_servers": [],
                    "model": {
                      "id": "default"
                    },
                    "multiagent": null,
                    "name": "Research Assistant",
                    "skills": [],
                    "system": null,
                    "tools": [],
                    "type": "agent",
                    "version": 1
                  },
                  "archived_at": "2026-10-21T01:47:50.964Z",
                  "budget": null,
                  "created_at": "2026-10-21T01:42:16.079Z",
                  "environment_id": "env_default",
                  "max_step_minutes": 240,
                  "metadata": {},
                  "outcome_evaluations": [],
                  "resources": [
                    {
                      "id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "created_at": "2026-10-21T01:41:11.028Z",
                      "file_id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "mount_path": "inputs/cities.csv",
                      "type": "file",
                      "updated_at": "2026-10-21T01:41:11.028Z"
                    }
                  ],
                  "stats": {},
                  "status": "terminated",
                  "title": "Quarterly city report",
                  "type": "session",
                  "updated_at": "2026-10-21T01:47:50.964Z",
                  "usage": {
                    "input_tokens": 12,
                    "output_tokens": 318,
                    "cache_read_input_tokens": 133496,
                    "cache_creation": {
                      "ephemeral_5m_input_tokens": 2210,
                      "ephemeral_1h_input_tokens": 0
                    },
                    "active_seconds": 7.331,
                    "list_cost": {
                      "amount": "6",
                      "currency": "USD"
                    }
                  },
                  "vault_ids": []
                }
              }
            }
          },
          "400": {
            "description": "A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key does not act for the session's owner, or the owner is no longer an active member. Use the owner's personal key or the service account key that created the session.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No session with this ID exists, or this key can't read it. Check the session ID.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X POST \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/archive\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "session = client.beta.sessions.archive(\"dd13d728-93e3-440a-874c-4efeb58c97e0\")  # status becomes \"terminated\""
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const session = await client.beta.sessions.archive(\"dd13d728-93e3-440a-874c-4efeb58c97e0\") // status becomes \"terminated\""
          }
        ]
      }
    },
    "/v1/sessions/{session_id}/events": {
      "get": {
        "tags": [
          "Events"
        ],
        "summary": "List events",
        "description": "Returns a session's event history, oldest first by default.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a page of events in `data`, in the order `order` sets, and a `next_page` value to pass as `page`. `next_page` is `null` when no more events match.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 1000. Send a value from 1 to 1000. |\n| 400 | `invalid_request_error` | `order` is not `asc` or `desc`. Send one of them, or omit it. |\n| 400 | `invalid_request_error` | `page` is not an event ID this API issued. Send the `next_page` value from the previous response, unchanged. |\n| 400 | `invalid_request_error` | A `created_at` bound is not an RFC 3339 timestamp. Send a timestamp such as `2026-10-21T01:42:16Z`. |\n| 404 | `not_found_error` | No session with this ID exists, or this key can't read it. Check the session ID. |\n| 503 | `api_error` | The session's history is still being indexed. Retry the request shortly. |",
        "operationId": "events_list",
        "parameters": [
          {
            "in": "path",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the session whose events to return."
            },
            "description": "The ID of the session whose events to return."
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 100,
              "description": "The maximum number of events to return on one page. Must be between 1 and 1000."
            },
            "description": "The maximum number of events to return on one page. Must be between 1 and 1000."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The ID of the event to start from. To fetch the next page, pass the `next_page` value from the previous response. With `asc`, the page starts with the first event after this one. With `desc`, it starts with the first event before it. The event itself is not included."
            },
            "description": "The ID of the event to start from. To fetch the next page, pass the `next_page` value from the previous response. With `asc`, the page starts with the first event after this one. With `desc`, it starts with the first event before it. The event itself is not included."
          },
          {
            "in": "query",
            "name": "created_at[gt]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only events whose `processed_at` is after this RFC 3339 timestamp."
            },
            "description": "Only events whose `processed_at` is after this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "created_at[gte]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only events whose `processed_at` is at or after this RFC 3339 timestamp."
            },
            "description": "Only events whose `processed_at` is at or after this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "created_at[lt]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only events whose `processed_at` is before this RFC 3339 timestamp."
            },
            "description": "Only events whose `processed_at` is before this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "created_at[lte]",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only events whose `processed_at` is at or before this RFC 3339 timestamp."
            },
            "description": "Only events whose `processed_at` is at or before this RFC 3339 timestamp."
          },
          {
            "in": "query",
            "name": "order",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc",
              "description": "The sort order. One of `asc` (oldest first) or `desc` (newest first)."
            },
            "description": "The sort order. One of `asc` (oldest first) or `desc` (newest first)."
          },
          {
            "in": "query",
            "name": "types",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "The event types to return. To pass more than one, repeat the parameter: `types=agent.message&types=session.status_idle`."
            },
            "description": "The event types to return. To pass more than one, repeat the parameter: `types=agent.message&types=session.status_idle`."
          },
          {
            "in": "query",
            "name": "types[]",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "The same filter as `types`, in the bracketed form the SDKs send: `types[]=agent.message&types[]=session.status_idle`."
            },
            "description": "The same filter as `types`, in the bracketed form the SDKs send: `types[]=agent.message&types[]=session.status_idle`."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a page of events in `data`, in the order `order` sets, and a `next_page` value to pass as `page`. `next_page` is `null` when no more events match.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.message"
                                ]
                              },
                              "content": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "content"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.interrupt"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.tool_confirmation"
                                ]
                              },
                              "result": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "deny"
                                ]
                              },
                              "tool_use_id": {
                                "type": "string"
                              },
                              "deny_message": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "result",
                              "tool_use_id"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent.message"
                                ]
                              },
                              "content": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "content"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent.thinking"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent.tool_use"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "input": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "name",
                              "input"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent.custom_tool_use"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "input": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "name",
                              "input"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.custom_tool_result"
                                ]
                              },
                              "custom_tool_use_id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "is_error": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "custom_tool_use_id",
                              "content",
                              "is_error"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "agent.tool_result"
                                ]
                              },
                              "tool_use_id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "is_error": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "tool_use_id",
                              "content",
                              "is_error"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "session.status_running"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "session.status_idle"
                                ]
                              },
                              "stop_reason": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "end_turn"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "requires_action"
                                        ]
                                      },
                                      "event_ids": {
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "event_ids"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "retries_exhausted"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "stop_details": {
                                "type": "null"
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "stop_reason",
                              "stop_details"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "session.error"
                                ]
                              },
                              "error": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "unknown_error",
                                      "model_overloaded_error",
                                      "model_rate_limited_error",
                                      "model_request_failed_error",
                                      "billing_error"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "retry_status": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "retrying",
                                          "exhausted"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "message",
                                  "retry_status"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "error"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                              },
                              "processed_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "session.usage"
                                ]
                              },
                              "usage": {
                                "type": "object",
                                "properties": {
                                  "input_tokens": {
                                    "type": "number"
                                  },
                                  "output_tokens": {
                                    "type": "number"
                                  },
                                  "cache_read_input_tokens": {
                                    "type": "number"
                                  },
                                  "cache_creation": {
                                    "type": "object",
                                    "properties": {
                                      "ephemeral_5m_input_tokens": {
                                        "type": "number"
                                      },
                                      "ephemeral_1h_input_tokens": {
                                        "type": "number"
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "active_seconds": {
                                    "type": "number"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "usage"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "type": "user.message",
                      "id": "sevt_1_0",
                      "processed_at": "2026-10-21T01:42:16.357Z",
                      "content": [
                        {
                          "type": "text",
                          "text": "Run this bash command and tell me the output: echo first"
                        }
                      ]
                    },
                    {
                      "type": "session.status_running",
                      "id": "sevt_1_1",
                      "processed_at": "2026-10-21T01:42:16.357Z"
                    },
                    {
                      "type": "agent.tool_use",
                      "id": "sevt_29_0",
                      "processed_at": "2026-10-21T01:42:21.908Z",
                      "name": "bash",
                      "input": {
                        "command": "echo first"
                      }
                    }
                  ],
                  "next_page": null
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 1000. Send a value from 1 to 1000.\n\n`order` is not `asc` or `desc`. Send one of them, or omit it.\n\n`page` is not an event ID this API issued. Send the `next_page` value from the previous response, unchanged.\n\nA `created_at` bound is not an RFC 3339 timestamp. Send a timestamp such as `2026-10-21T01:42:16Z`.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No session with this ID exists, or this key can't read it. Check the session ID.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "503": {
            "description": "The session's history is still being indexed. Retry the request shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "The session is catching up; retry shortly"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/events?limit=100\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "for event in client.beta.sessions.events.list(\"dd13d728-93e3-440a-874c-4efeb58c97e0\", limit=100):  # auto-paginates\n    print(event.id, event.type)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "for await (const event of client.beta.sessions.events.list(\"dd13d728-93e3-440a-874c-4efeb58c97e0\", { limit: 100 })) console.log(event.id, event.type)"
          }
        ]
      },
      "post": {
        "tags": [
          "Events"
        ],
        "summary": "Send events",
        "description": "Sends a message, a tool approval or an interrupt to a session.\n\nSends are not idempotent. If a send times out or its result is unknown, read the session's events before you\nsend it again.\n\nThe server checks every event against the session before any of them acts, then applies them in order. If an\nevent is refused while they are applied, because the session changed in the meantime, the earlier events stay\naccepted and the error message says how many were. Don't resend those.\n\nEach event gets a receipt with a `sevt_receipt_` ID and `processed_at: null`. The stored event, with its real\nID, then appears on the stream and in the history. The receipt ID is not the stored event's ID, so match the\nstored event on the stream rather than by ID.\n\nBefore a session starts, it accepts exactly one `user.message` per request. Send more only after the stream\nshows `session.status_running`. A `user.message` sent while a turn runs is added to that turn instead of\nstarting a new one.\n\nA `user.tool_confirmation` also needs the `tasks:approve` capability and a\n[personal key](https://docs.context.ai/build/agent-api/choosing-a-key).\n\nThe key must have the `tasks:create` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a `data` array that holds one receipt for each event you sent.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | An event is malformed, or its text is empty or over 100,000 characters in all. Fix the event the message names. |\n| 400 | `invalid_request_error` | The session is archived. Archived sessions take no events. Create a new session. |\n| 400 | `invalid_request_error` | The session has not started and the request holds more than one `user.message`, or the first turn is still starting. Send one message, then wait for `session.status_running` before you send the next. |\n| 400 | `invalid_request_error` | A `tool_use_id` is unknown, repeated or already answered. Send only IDs from the latest `stop_reason.event_ids` that you have not answered. |\n| 400 | `invalid_request_error` | An event has a type this endpoint does not accept: `user.tool_result`, `user.define_outcome` or `system.message`. Send only `user.message`, `user.tool_confirmation`, `user.custom_tool_result` or `user.interrupt`. |\n| 400 | `invalid_request_error` | A `user.custom_tool_result` names a `custom_tool_use_id` this session never showed. Send the ID of its `agent.custom_tool_use` event. |\n| 400 | `invalid_request_error` | An event carries `session_thread_id`. Sessions have one thread. Remove `session_thread_id` and retry. |\n| 400 | `invalid_request_error` | A `user.tool_confirmation` follows a `user.interrupt` in the same request. Send the confirmation before the interrupt, or in a separate request. |\n| 403 | `permission_error` | The key does not act for the session's owner, or the owner is no longer an active member. Use the owner's personal key or the service account key that created the session. |\n| 403 | `permission_error` | A `user.tool_confirmation` was sent with a key that is not personal, or that lacks `tasks:approve`. Use a personal key with `tasks:approve`. |\n| 404 | `not_found_error` | No session with this ID exists, or this key can't read it. Check the session ID. |\n| 409 | `invalid_request_error` | The session's state changed while the request was processed. The tool call was already answered, or the session is stopping or moving. Read the events, then decide whether to send again. |\n| 503 | `api_error` | The session's history is still being indexed. Retry the request shortly. |",
        "operationId": "events_send",
        "parameters": [
          {
            "in": "path",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the session to send events to."
            },
            "description": "The ID of the session to send events to."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "events": {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.message"
                              ],
                              "description": "The event type. One of `user.message`, `user.tool_confirmation`, `user.custom_tool_result` or `user.interrupt`."
                            },
                            "content": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              },
                              "minItems": 1,
                              "description": "One or more `{type: \"text\", text}` blocks, up to 100,000 characters in all. Required for `user.message`."
                            }
                          },
                          "required": [
                            "type",
                            "content"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.interrupt"
                              ],
                              "description": "The event type. One of `user.message`, `user.tool_confirmation`, `user.custom_tool_result` or `user.interrupt`."
                            },
                            "session_thread_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.tool_confirmation"
                              ],
                              "description": "The event type. One of `user.message`, `user.tool_confirmation`, `user.custom_tool_result` or `user.interrupt`."
                            },
                            "result": {
                              "type": "string",
                              "enum": [
                                "allow",
                                "deny"
                              ],
                              "description": "One of `allow` (approves this one call) or `deny`. Required for `user.tool_confirmation`."
                            },
                            "tool_use_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The ID of the `agent.tool_use` event to answer, from `stop_reason.event_ids` on the `session.status_idle` event. Required for `user.tool_confirmation`."
                            },
                            "deny_message": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "description": "Text stored with your answer. The receipt echoes it whenever you send it. The stored `user.tool_confirmation` event carries it only for a `deny`. Its length is limited only by the 10 MiB request body limit."
                            },
                            "session_thread_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "result",
                            "tool_use_id"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.custom_tool_result"
                              ],
                              "description": "The event type. One of `user.message`, `user.tool_confirmation`, `user.custom_tool_result` or `user.interrupt`."
                            },
                            "custom_tool_use_id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The ID of the `agent.custom_tool_use` event to answer. Required for `user.custom_tool_result`. An ID the session never showed returns `400`; one already answered is accepted and changes nothing."
                            },
                            "content": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              },
                              "description": "One or more `{type: \"text\", text}` blocks, up to 100,000 characters in all. Required for `user.message`."
                            },
                            "is_error": {
                              "type": [
                                "boolean",
                                "null"
                              ],
                              "description": "Whether the custom tool failed; left out, the result is not an error. Only for `user.custom_tool_result`."
                            },
                            "session_thread_id": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "custom_tool_use_id"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "minItems": 1,
                    "description": "The events to send, applied in order."
                  }
                },
                "required": [
                  "events"
                ],
                "additionalProperties": false
              },
              "examples": {
                "example-1": {
                  "summary": "A message",
                  "value": {
                    "events": [
                      {
                        "type": "user.message",
                        "content": [
                          {
                            "type": "text",
                            "text": "Now chart the top three."
                          }
                        ]
                      }
                    ]
                  }
                },
                "example-2": {
                  "summary": "Approve the waiting tool call (needs tasks:approve)",
                  "value": {
                    "events": [
                      {
                        "type": "user.tool_confirmation",
                        "result": "allow",
                        "tool_use_id": "sevt_29_0"
                      }
                    ]
                  }
                },
                "example-3": {
                  "summary": "Stop the current turn",
                  "value": {
                    "events": [
                      {
                        "type": "user.interrupt"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with a `data` array that holds one receipt for each event you sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_receipt_"
                              },
                              "processed_at": {
                                "type": "null"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.message"
                                ]
                              },
                              "content": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "content"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_receipt_"
                              },
                              "processed_at": {
                                "type": "null"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.interrupt"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_receipt_"
                              },
                              "processed_at": {
                                "type": "null"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.tool_confirmation"
                                ]
                              },
                              "result": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "deny"
                                ]
                              },
                              "tool_use_id": {
                                "type": "string"
                              },
                              "deny_message": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "result",
                              "tool_use_id"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^sevt_receipt_"
                              },
                              "processed_at": {
                                "type": "null"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "user.custom_tool_result"
                                ]
                              },
                              "custom_tool_use_id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "is_error": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "id",
                              "processed_at",
                              "type",
                              "custom_tool_use_id",
                              "content",
                              "is_error"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "type": "user.message",
                      "content": [
                        {
                          "type": "text",
                          "text": "Now chart the top three."
                        }
                      ],
                      "id": "sevt_receipt_219b3afe-157c-452d-981b-c71353fb80bc",
                      "processed_at": null
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "An event is malformed, or its text is empty or over 100,000 characters in all. Fix the event the message names.\n\nThe session is archived. Archived sessions take no events. Create a new session.\n\nThe session has not started and the request holds more than one `user.message`, or the first turn is still starting. Send one message, then wait for `session.status_running` before you send the next.\n\nA `tool_use_id` is unknown, repeated or already answered. Send only IDs from the latest `stop_reason.event_ids` that you have not answered.\n\nAn event has a type this endpoint does not accept: `user.tool_result`, `user.define_outcome` or `system.message`. Send only `user.message`, `user.tool_confirmation`, `user.custom_tool_result` or `user.interrupt`.\n\nA `user.custom_tool_result` names a `custom_tool_use_id` this session never showed. Send the ID of its `agent.custom_tool_use` event.\n\nAn event carries `session_thread_id`. Sessions have one thread. Remove `session_thread_id` and retry.\n\nA `user.tool_confirmation` follows a `user.interrupt` in the same request. Send the confirmation before the interrupt, or in a separate request.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key does not act for the session's owner, or the owner is no longer an active member. Use the owner's personal key or the service account key that created the session.\n\nA `user.tool_confirmation` was sent with a key that is not personal, or that lacks `tasks:approve`. Use a personal key with `tasks:approve`.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No session with this ID exists, or this key can't read it. Check the session ID.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "409": {
            "description": "The session's state changed while the request was processed. The tool call was already answered, or the session is stopping or moving. Read the events, then decide whether to send again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "Ask changed before the answer"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "503": {
            "description": "The session's history is still being indexed. Retry the request shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "The session is catching up; retry shortly"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "# A message\ncurl -sS -X POST \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/events\" -H \"x-api-key: $CONTEXT_API_KEY\" \\\n  -H \"content-type: application/json\" \\\n  -d '{\"events\": [{\"type\": \"user.message\", \"content\": [{\"type\": \"text\", \"text\": \"Now chart the top three.\"}]}]}'\n\n# Approve the waiting tool call (needs tasks:approve)\ncurl -sS -X POST \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/events\" -H \"x-api-key: $CONTEXT_API_KEY\" \\\n  -H \"content-type: application/json\" \\\n  -d '{\"events\": [{\"type\": \"user.tool_confirmation\", \"result\": \"allow\", \"tool_use_id\": \"sevt_29_0\"}]}'\n\n# Stop the current turn\ncurl -sS -X POST \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/events\" -H \"x-api-key: $CONTEXT_API_KEY\" \\\n  -H \"content-type: application/json\" -d '{\"events\": [{\"type\": \"user.interrupt\"}]}'"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "sid = \"dd13d728-93e3-440a-874c-4efeb58c97e0\"\nclient.beta.sessions.events.send(sid, events=[{\"type\": \"user.message\", \"content\": [{\"type\": \"text\", \"text\": \"Now chart the top three.\"}]}])\nclient.beta.sessions.events.send(sid, events=[{\"type\": \"user.tool_confirmation\", \"result\": \"allow\", \"tool_use_id\": \"sevt_29_0\"}])\nclient.beta.sessions.events.send(sid, events=[{\"type\": \"user.interrupt\"}])"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const sid = \"dd13d728-93e3-440a-874c-4efeb58c97e0\"\nawait client.beta.sessions.events.send(sid, { events: [{ type: \"user.message\", content: [{ type: \"text\", text: \"Now chart the top three.\" }] }] })\nawait client.beta.sessions.events.send(sid, { events: [{ type: \"user.tool_confirmation\", result: \"allow\", tool_use_id: \"sevt_29_0\" }] })\nawait client.beta.sessions.events.send(sid, { events: [{ type: \"user.interrupt\" }] })"
          }
        ]
      }
    },
    "/v1/sessions/{session_id}/events/stream": {
      "get": {
        "tags": [
          "Events"
        ],
        "summary": "Stream events",
        "description": "Streams a session's events as server-sent events while they happen.\n\nWithout `Last-Event-ID`, the stream sends only events that happen after it opens, so open it before you send a\nmessage.\n\nEach key can hold up to 24 open streams across all its sessions, unless your deployment sets a different limit.\nThe limit applies on each server instance, so a key whose streams land on more than one instance can hold more\nin total. A stream counts until your client disconnects.\n\nThis endpoint takes no query parameters. Anthropic's `event_deltas` parameter isn't supported, and sending it\nreturns `400`.\n\nThe key must have the `tasks:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the content type `text/event-stream`. Each event is one frame, described in [Frames](https://docs.context.ai/build/agent-api/openapi/events#stream-events). The `: open` line is a comment, sent once when the stream opens, and SSE clients ignore it.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `Last-Event-ID` is not an event ID of this session. Send an ID from this session's events, or omit the header. |\n| 400 | `invalid_request_error` | The request includes the `event_deltas` query parameter. Remove it. |\n| 404 | `not_found_error` | No session with this ID exists, or this key can't read it. Check the session ID. |\n| 429 | `rate_limit_error` | This key already holds the most open streams allowed on the server instance that answered, 24 by default. Close a stream you no longer read, then retry. |\n\n## Frames\n\nEach event is one frame with `id`, `event` and `data`, and the frame's `id` is the event ID. Events arrive\nwhole, without deltas, and `agent.message` carries the full reply. Every 20 seconds the server sends a `ping`\nframe with no `id`.\n\n## Event order in a turn\n\nStop reading when a `session.status_idle` arrives whose `stop_reason.type` is anything other than\n`requires_action`. A `session.status_idle` with `requires_action` means the agent is waiting for you. A\n`session.error` with `retry_status.type: \"retrying\"` doesn't end the turn, so keep reading. A `session.error`\nwith `retry_status.type: \"exhausted\"` is followed by a `session.status_idle` with `retries_exhausted`.\n\nA turn in which the agent asks to run a tool looks like this:\n\n1. The stream shows `user.message`, then `session.status_running`.\n2. The stream shows `agent.tool_use` for the call, then `session.status_idle` with\n   `stop_reason.type: \"requires_action\"` and the call's ID in `event_ids`.\n3. To answer, send a `user.tool_confirmation` event with [Send events](https://docs.context.ai/build/agent-api/openapi/events#send-events)\n   for each call. The stream shows it, then `session.status_running` once every waiting call is answered.\n   Until you answer every ID in `event_ids`, the session keeps waiting and the stream sends no further status\n   event.\n4. The stream shows `agent.tool_result`, then `agent.thinking` if the agent reasoned, then `agent.message`. A\n   `session.usage` event follows each model call.\n5. The stream shows `session.usage`, then `session.status_idle` with `stop_reason.type: \"end_turn\"`. The turn\n   is over.\n\n## How a stream ends\n\nThe server doesn't close the stream when a turn ends. Close it yourself when you stop reading, because an open\nstream counts against the key's limit.\n\nA stream can end with an `event: error` frame, without an `id`, whose `data` is an error body. The server\nsends nothing after it, so close the connection yourself.\n\n| `error.type` | Why | What to do |\n|---|---|---|\n| `api_error` | The connection has carried 8 MiB. | Reconnect with `Last-Event-ID`. |\n| `invalid_request_error` | The session was archived. | Stop. The history stays readable. |\n| `authentication_error` | The key was revoked or expired, or its owner left the organization. | Stop. To keep reading, open a new stream with a valid key. |\n| `permission_error`, `not_found_error` | The key lost access to the session. | Stop. To keep reading, open a new stream with a key that can read the session. |\n\nA stream can also close with no frame, for example when the server restarts. The SDKs do not reconnect for you.\n\n## Reconnecting\n\nTo resume a stream without missing events, follow these steps:\n\n1. Keep the `id` of the last event you received.\n2. Reopen the stream with a `Last-Event-ID` header set to that ID. The server replays every event after it,\n   then continues live.\n\nIf you have not received any event yet, send `sevt_0_0` to replay the whole history. To read the history first,\nlist it with [List events](https://docs.context.ai/build/agent-api/openapi/events#list-events) and stream from the last listed ID. You\ncan also open the stream first, then list the history and skip any event IDs the stream has already delivered.",
        "operationId": "events_stream",
        "parameters": [
          {
            "in": "path",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the session to stream."
            },
            "description": "The ID of the session to stream."
          },
          {
            "in": "header",
            "name": "Last-Event-ID",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The ID of the last event you received from this session. The stream replays every event after it, then continues live. `sevt_0_0` replays from the start. A send receipt's ID (`sevt_receipt_<uuid>`, returned when you [send an event](https://docs.context.ai/build/agent-api/openapi/events#send-events)) returns `400`."
            },
            "description": "The ID of the last event you received from this session. The stream replays every event after it, then continues live. `sevt_0_0` replays from the start. A send receipt's ID (`sevt_receipt_<uuid>`, returned when you [send an event](https://docs.context.ai/build/agent-api/openapi/events#send-events)) returns `400`."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the content type `text/event-stream`. Each event is one frame, described in [Frames](https://docs.context.ai/build/agent-api/openapi/events#stream-events). The `: open` line is a comment, sent once when the stream opens, and SSE clients ignore it.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "anyOf": [
                    {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.message"
                              ]
                            },
                            "content": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "content"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.interrupt"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.tool_confirmation"
                              ]
                            },
                            "result": {
                              "type": "string",
                              "enum": [
                                "allow",
                                "deny"
                              ]
                            },
                            "tool_use_id": {
                              "type": "string"
                            },
                            "deny_message": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "result",
                            "tool_use_id"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "agent.message"
                              ]
                            },
                            "content": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "content"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "agent.thinking"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "agent.tool_use"
                              ]
                            },
                            "name": {
                              "type": "string"
                            },
                            "input": {
                              "type": "object",
                              "additionalProperties": {}
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "name",
                            "input"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "agent.custom_tool_use"
                              ]
                            },
                            "name": {
                              "type": "string"
                            },
                            "input": {
                              "type": "object",
                              "additionalProperties": {}
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "name",
                            "input"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "user.custom_tool_result"
                              ]
                            },
                            "custom_tool_use_id": {
                              "type": "string"
                            },
                            "content": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "is_error": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "custom_tool_use_id",
                            "content",
                            "is_error"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "agent.tool_result"
                              ]
                            },
                            "tool_use_id": {
                              "type": "string"
                            },
                            "content": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "is_error": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "tool_use_id",
                            "content",
                            "is_error"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "session.status_running"
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "session.status_idle"
                              ]
                            },
                            "stop_reason": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "end_turn"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "requires_action"
                                      ]
                                    },
                                    "event_ids": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "event_ids"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "retries_exhausted"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "stop_details": {
                              "type": "null"
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "stop_reason",
                            "stop_details"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "session.error"
                              ]
                            },
                            "error": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "unknown_error",
                                    "model_overloaded_error",
                                    "model_rate_limited_error",
                                    "model_request_failed_error",
                                    "billing_error"
                                  ]
                                },
                                "message": {
                                  "type": "string"
                                },
                                "retry_status": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "retrying",
                                        "exhausted"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "type"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "type",
                                "message",
                                "retry_status"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "error"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^sevt_(0|[1-9][0-9]*)_(0|[1-9][0-9]*)$"
                            },
                            "processed_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "session.usage"
                              ]
                            },
                            "usage": {
                              "type": "object",
                              "properties": {
                                "input_tokens": {
                                  "type": "number"
                                },
                                "output_tokens": {
                                  "type": "number"
                                },
                                "cache_read_input_tokens": {
                                  "type": "number"
                                },
                                "cache_creation": {
                                  "type": "object",
                                  "properties": {
                                    "ephemeral_5m_input_tokens": {
                                      "type": "number"
                                    },
                                    "ephemeral_1h_input_tokens": {
                                      "type": "number"
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "active_seconds": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "id",
                            "processed_at",
                            "type",
                            "usage"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "ping"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "error"
                          ]
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "invalid_request_error",
                                "authentication_error",
                                "billing_error",
                                "permission_error",
                                "not_found_error",
                                "request_too_large",
                                "rate_limit_error",
                                "api_error"
                              ]
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        "request_id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "error",
                        "request_id"
                      ],
                      "additionalProperties": false
                    }
                  ]
                },
                "example": ": open\n\nid: sevt_40_0\nevent: agent.message\ndata: {\"type\":\"agent.message\",\"id\":\"sevt_40_0\",\"processed_at\":\"2026-10-21T01:42:24.003Z\",\"content\":[{\"type\":\"text\",\"text\":\"The output is `first`.\"}]}\n\nid: sevt_40_1\nevent: session.usage\ndata: {\"type\":\"session.usage\",\"id\":\"sevt_40_1\",\"processed_at\":\"2026-10-21T01:42:24.003Z\",\"usage\":{\"input_tokens\":6,\"output_tokens\":82,\"cache_read_input_tokens\":44428,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"active_seconds\":7.288}}\n\nid: sevt_41_0\nevent: session.usage\ndata: {\"type\":\"session.usage\",\"id\":\"sevt_41_0\",\"processed_at\":\"2026-10-21T01:42:24.043Z\",\"usage\":{\"input_tokens\":6,\"output_tokens\":82,\"cache_read_input_tokens\":44428,\"cache_creation\":{\"ephemeral_5m_input_tokens\":0,\"ephemeral_1h_input_tokens\":0},\"active_seconds\":7.331}}\n\nid: sevt_41_1\nevent: session.status_idle\ndata: {\"type\":\"session.status_idle\",\"id\":\"sevt_41_1\",\"processed_at\":\"2026-10-21T01:42:24.043Z\",\"stop_reason\":{\"type\":\"end_turn\"},\"stop_details\":null}\n\nevent: ping\ndata: {\"type\":\"ping\"}"
              }
            }
          },
          "400": {
            "description": "`Last-Event-ID` is not an event ID of this session. Send an ID from this session's events, or omit the header.\n\nThe request includes the `event_deltas` query parameter. Remove it.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No session with this ID exists, or this key can't read it. Check the session ID.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "This key already holds the most open streams allowed on the server instance that answered, 24 by default. Close a stream you no longer read, then retry.\n\nThe key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sSN \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/events/stream\" -H \"x-api-key: $CONTEXT_API_KEY\"\n\n# Resume after the last event you received\ncurl -sSN \"$CONTEXT_BASE_URL/v1/sessions/dd13d728-93e3-440a-874c-4efeb58c97e0/events/stream\" -H \"x-api-key: $CONTEXT_API_KEY\" \\\n  -H \"Last-Event-ID: sevt_29_0\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "sid = \"dd13d728-93e3-440a-874c-4efeb58c97e0\"\nwith client.beta.sessions.events.stream(sid) as stream:\n    for event in stream:\n        print(event.id, event.type)\n        if event.type == \"session.status_idle\" and event.stop_reason.type != \"requires_action\":\n            break\n\n# Resume after the last event you received\nstream = client.beta.sessions.events.stream(sid, extra_headers={\"Last-Event-ID\": \"sevt_29_0\"})"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const sid = \"dd13d728-93e3-440a-874c-4efeb58c97e0\"\nconst stream = await client.beta.sessions.events.stream(sid)\nfor await (const event of stream) {\n  if (\"id\" in event) console.log(event.id, event.type)\n  if (event.type === \"session.status_idle\" && event.stop_reason.type !== \"requires_action\") break\n}\n\n// Resume after the last event you received\nconst resumed = await client.beta.sessions.events.stream(sid, {}, { headers: { \"Last-Event-ID\": \"sevt_29_0\" } })"
          }
        ]
      }
    },
    "/v1/files": {
      "post": {
        "tags": [
          "Files"
        ],
        "summary": "Upload a file",
        "description": "Uploads one file to the Drive of the user who owns the key.\n\nSend `multipart/form-data` with one `file` field, whose part includes a filename, and optionally an\n`expires_in_seconds` field. The server accepts any file type. In a body over 10 MiB, `expires_in_seconds` must\ncome before `file`. The Python and .NET SDKs send it first. With the TypeScript SDK, write `expires_in_seconds`\nbefore `file` in the object you pass to `files.upload`.\n\nThese limits apply:\n\n- A file can be up to your deployment's upload limit, which is 5 GiB unless your administrator set it lower.\n- Send a `Content-Length` header. cURL and the SDKs send one for you. A request without one must use chunked\n  encoding and be 10 MiB or smaller.\n- Each key can have up to 4 uploads in progress on one server instance, and each instance takes up to 8 in\n  total across all keys. Keep 4 or fewer uploads in progress, and retry on `429`.\n\nIf the request fails partway, the server keeps nothing.\n\nThe key must have the `files:write` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the file object. For every field, see [Files](https://docs.context.ai/build/agent-api/openapi/files).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The form has a field other than `file` and `expires_in_seconds`. Remove the other fields. |\n| 400 | `invalid_request_error` | `expires_in_seconds` isn't a whole number between 3600 and 7776000. Send a value in that range, or omit it. |\n| 400 | `invalid_request_error` | `expires_in_seconds` comes after `file` in a body over 10 MiB. Send `expires_in_seconds` before `file`, or omit it. |\n| 400 | `invalid_request_error` | The form has no `file` field, or more than one, or the filename is empty. Send exactly one `file` field with a non-empty filename. |\n| 400 | `invalid_request_error` | The body doesn't match its `Content-Length`: bytes follow the closing boundary, or the body ends early. The server keeps nothing. Send an exact `Content-Length`. |\n| 413 | `request_too_large` | The file is over your deployment's upload limit (5 GiB unless your administrator set it lower), or a chunked request is over 10 MiB. The message gives the limit. If the file is over the upload limit, send a smaller file. If the request is chunked and over 10 MiB, send it again with a `Content-Length` header. |\n| 429 | `rate_limit_error` | This key already has 4 uploads in progress on the server instance that answered, or 8 are in progress there for all keys. Wait for the time in `Retry-After`, then retry. |",
        "operationId": "files_upload",
        "parameters": [
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The file, with a filename. If the part has no media type, the server stores the file as `application/octet-stream`."
                  },
                  "expires_in_seconds": {
                    "type": "integer",
                    "minimum": 3600,
                    "maximum": 7776000,
                    "description": "The number of seconds until the file expires on Anthropic's API. Must be a whole number between 3600 and 7776000. It isn't applied: the file is kept until you delete it, and the file object has no `expires_at`."
                  }
                },
                "required": [
                  "file"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with the file object. For every field, see [Files](https://docs.context.ai/build/agent-api/openapi/files).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "filename": {
                      "type": "string"
                    },
                    "mime_type": {
                      "type": "string"
                    },
                    "size_bytes": {
                      "type": "number"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "file"
                      ]
                    },
                    "downloadable": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "scope": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "session"
                          ]
                        },
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "id",
                    "created_at",
                    "filename",
                    "mime_type",
                    "size_bytes",
                    "type",
                    "downloadable"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "329409ba-f288-4b44-9c73-14a18150edee",
                  "created_at": "2026-10-21T01:41:11.028Z",
                  "filename": "cities.csv",
                  "mime_type": "text/csv",
                  "size_bytes": 46,
                  "type": "file",
                  "downloadable": true
                }
              }
            }
          },
          "400": {
            "description": "The form has a field other than `file` and `expires_in_seconds`. Remove the other fields.\n\n`expires_in_seconds` isn't a whole number between 3600 and 7776000. Send a value in that range, or omit it.\n\n`expires_in_seconds` comes after `file` in a body over 10 MiB. Send `expires_in_seconds` before `file`, or omit it.\n\nThe form has no `file` field, or more than one, or the filename is empty. Send exactly one `file` field with a non-empty filename.\n\nThe body doesn't match its `Content-Length`: bytes follow the closing boundary, or the body ends early. The server keeps nothing. Send an exact `Content-Length`.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "413": {
            "description": "The file is over your deployment's upload limit (5 GiB unless your administrator set it lower), or a chunked request is over 10 MiB. The message gives the limit. If the file is over the upload limit, send a smaller file. If the request is chunked and over 10 MiB, send it again with a `Content-Length` header.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "request_too_large",
                    "message": "Request bodies are capped at 10485760 bytes"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "This key already has 4 uploads in progress on the server instance that answered, or 8 are in progress there for all keys. Wait for the time in `Retry-After`, then retry.\n\nThe key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X POST \"$CONTEXT_BASE_URL/v1/files\" -H \"x-api-key: $CONTEXT_API_KEY\" -F \"file=@cities.csv;type=text/csv\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "from pathlib import Path\n\nuploaded = client.beta.files.upload(file=Path(\"cities.csv\"))\nprint(uploaded.id)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "import { readFile } from \"node:fs/promises\"\nimport { toFile } from \"@anthropic-ai/sdk\"\n\nconst uploaded = await client.beta.files.upload({ file: await toFile(await readFile(\"cities.csv\"), \"cities.csv\", { type: \"text/csv\" }) })"
          }
        ]
      },
      "get": {
        "tags": [
          "Files"
        ],
        "summary": "List files",
        "description": "Lists the files this key or its owner uploaded, or the files a session produced, newest first.\n\nWithout `scope_id`, the list holds files uploaded with a Task API key: the files this key uploaded, and the\nfiles that this key's owner owns. With `scope_id` set to a session ID, the list holds the files that session's\nagent produced, each with a `scope` field that names the session. That list leaves out the session's attached\nfiles, the files the platform stores for the session (such as its transcript), and large tool results saved\nduring the session. The list stays the same after the session is archived.\n\nSend at most one of `page`, `after_id` and `before_id`. Both SDKs paginate with `page`.\n\nThe key must have the `files:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a list of [file objects](https://docs.context.ai/build/agent-api/openapi/files), newest first.\n\n| Field | Description |\n|---|---|\n| `data` | The files on this page. |\n| `first_id` | The ID of the first file on the page. |\n| `last_id` | The ID of the last file on the page. |\n| `has_more` | `true` when more files remain in the direction you are paging: older files for `page` and `after_id`, newer files for `before_id`. |\n| `next_page` | The value to pass as `page` for the next page. It is `null` on the last page and on a `before_id` page. |\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 100. Send a value from 1 to 100. |\n| 400 | `invalid_request_error` | The request sends more than one of `page`, `after_id` and `before_id`. Send only one of them. |\n| 400 | `invalid_request_error` | The request sends `ids`, which this API doesn't take. Remove it. |\n| 404 | `not_found_error` | `after_id` or `before_id` names a file that isn't on this list. Pass `first_id` or `last_id` from a previous page of this list. |\n| 404 | `not_found_error` | `scope_id` names a session this key can't read. Pass the ID of a session this key can read. |",
        "operationId": "files_list",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "The maximum number of files to return. Must be between 1 and 100."
            },
            "description": "The maximum number of files to return. Must be between 1 and 100."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "in": "query",
            "name": "after_id",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "The ID of a file. Returns files older than that file. Pass `last_id` from the previous page."
            },
            "description": "The ID of a file. Returns files older than that file. Pass `last_id` from the previous page."
          },
          {
            "in": "query",
            "name": "before_id",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "The ID of a file. Returns files newer than that file. Pass `first_id` from the previous page."
            },
            "description": "The ID of a file. Returns files newer than that file. Pass `first_id` from the previous page."
          },
          {
            "in": "query",
            "name": "scope_id",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "A session ID. Returns the files that session's agent produced instead of the default list."
            },
            "description": "A session ID. Returns the files that session's agent produced instead of the default list."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a list of [file objects](https://docs.context.ai/build/agent-api/openapi/files), newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "filename": {
                            "type": "string"
                          },
                          "mime_type": {
                            "type": "string"
                          },
                          "size_bytes": {
                            "type": "number"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "file"
                            ]
                          },
                          "downloadable": {
                            "type": "boolean",
                            "enum": [
                              true
                            ]
                          },
                          "scope": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "session"
                                ]
                              },
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "id"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "id",
                          "created_at",
                          "filename",
                          "mime_type",
                          "size_bytes",
                          "type",
                          "downloadable"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "first_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "last_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page",
                    "has_more",
                    "first_id",
                    "last_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "329409ba-f288-4b44-9c73-14a18150edee",
                      "created_at": "2026-10-21T01:41:11.028Z",
                      "filename": "cities.csv",
                      "mime_type": "text/csv",
                      "size_bytes": 46,
                      "type": "file",
                      "downloadable": true
                    }
                  ],
                  "next_page": null,
                  "has_more": false,
                  "first_id": "329409ba-f288-4b44-9c73-14a18150edee",
                  "last_id": "329409ba-f288-4b44-9c73-14a18150edee"
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 100. Send a value from 1 to 100.\n\nThe request sends more than one of `page`, `after_id` and `before_id`. Send only one of them.\n\nThe request sends `ids`, which this API doesn't take. Remove it.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "`after_id` or `before_id` names a file that isn't on this list. Pass `first_id` or `last_id` from a previous page of this list.\n\n`scope_id` names a session this key can't read. Pass the ID of a session this key can read.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/files?limit=20\" -H \"x-api-key: $CONTEXT_API_KEY\"\n\n# The files a session produced\ncurl -sS \"$CONTEXT_BASE_URL/v1/files?scope_id=dd13d728-93e3-440a-874c-4efeb58c97e0\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "for file in client.beta.files.list(limit=20):  # auto-paginates\n    print(file.id, file.filename, file.size_bytes)\n\n# The files a session produced\nfor file in client.beta.files.list(scope_id=\"dd13d728-93e3-440a-874c-4efeb58c97e0\"):\n    print(file.id, file.filename)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "for await (const file of client.beta.files.list({ limit: 20 })) console.log(file.id, file.filename)\n\n// The files a session produced\nfor await (const file of client.beta.files.list({ scope_id: \"dd13d728-93e3-440a-874c-4efeb58c97e0\" })) console.log(file.id, file.filename)"
          }
        ]
      }
    },
    "/v1/files/{file_id}": {
      "get": {
        "tags": [
          "Files"
        ],
        "summary": "Get a file",
        "description": "Returns a file's metadata.\n\nTo get the file's content, see [Download a file](https://docs.context.ai/build/agent-api/openapi/files#download-a-file).\n\nThe key must have the `files:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the file object. For every field, see [Files](https://docs.context.ai/build/agent-api/openapi/files).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 404 | `not_found_error` | No file with this ID exists, or this key can't read it or the session that produced it. Check the ID from the upload or from the list. |",
        "operationId": "files_retrieve",
        "parameters": [
          {
            "in": "path",
            "name": "file_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the file to retrieve."
            },
            "description": "The ID of the file to retrieve."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the file object. For every field, see [Files](https://docs.context.ai/build/agent-api/openapi/files).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "filename": {
                      "type": "string"
                    },
                    "mime_type": {
                      "type": "string"
                    },
                    "size_bytes": {
                      "type": "number"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "file"
                      ]
                    },
                    "downloadable": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "scope": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "session"
                          ]
                        },
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "id",
                    "created_at",
                    "filename",
                    "mime_type",
                    "size_bytes",
                    "type",
                    "downloadable"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "329409ba-f288-4b44-9c73-14a18150edee",
                  "created_at": "2026-10-21T01:41:11.028Z",
                  "filename": "cities.csv",
                  "mime_type": "text/csv",
                  "size_bytes": 46,
                  "type": "file",
                  "downloadable": true
                }
              }
            }
          },
          "400": {
            "description": "A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No file with this ID exists, or this key can't read it or the session that produced it. Check the ID from the upload or from the list.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/files/329409ba-f288-4b44-9c73-14a18150edee\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "file = client.beta.files.retrieve_metadata(\"329409ba-f288-4b44-9c73-14a18150edee\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const file = await client.beta.files.retrieveMetadata(\"329409ba-f288-4b44-9c73-14a18150edee\")"
          }
        ]
      },
      "delete": {
        "tags": [
          "Files"
        ],
        "summary": "Delete a file",
        "description": "Permanently deletes an uploaded file.\n\nThe file doesn't go to the Drive trash, and it can't be restored through this API or the app. A later request\nfor it returns `404`. If the server can't delete the stored copy, the request returns `500` and the copy stays in\nthe owner's Drive. See the errors below.\n\nA service account key can delete only the files it uploaded. This endpoint can't delete files that a session\nproduced, or a file that a session or run still uses. See the errors below.\n\nThe key must have the `files:write` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with an object that holds the file's `id` and a `type` of `file_deleted`.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The file is attached to a session that isn't archived, or is used by a run that hasn't finished. Archive the session, or wait for the run to finish, then retry. |\n| 400 | `invalid_request_error` | The file was produced by a session. Download it with [Download a file](https://docs.context.ai/build/agent-api/openapi/files#download-a-file), or remove it from the session's folder in Drive. |\n| 403 | `permission_error` | The key lacks `files:write`. Use a key that has `files:write`. |\n| 403 | `permission_error` | The key's owner can't edit the Drive folder that holds the file. Use a key whose owner can edit that folder. |\n| 403 | `permission_error` | A service account key tried to delete a file it didn't upload. Use the personal key of the user who owns the file. |\n| 404 | `not_found_error` | No file with this ID exists, or this key can't read it. Check the ID against [List files](https://docs.context.ai/build/agent-api/openapi/files#list-files). If the ID is correct, check that the key can read the file. |\n| 500 | `api_error` | The API no longer returns the file, but its stored copy couldn't be deleted. The message says where the copy remains in the owner's Drive. Delete it there, or quote `request_id` when you contact support. |",
        "operationId": "files_delete",
        "parameters": [
          {
            "in": "path",
            "name": "file_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the file to delete."
            },
            "description": "The ID of the file to delete."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with an object that holds the file's `id` and a `type` of `file_deleted`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "file_deleted"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "type"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "329409ba-f288-4b44-9c73-14a18150edee",
                  "type": "file_deleted"
                }
              }
            }
          },
          "400": {
            "description": "The file is attached to a session that isn't archived, or is used by a run that hasn't finished. Archive the session, or wait for the run to finish, then retry.\n\nThe file was produced by a session. Download it with [Download a file](https://docs.context.ai/build/agent-api/openapi/files#download-a-file), or remove it from the session's folder in Drive.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks `files:write`. Use a key that has `files:write`.\n\nThe key's owner can't edit the Drive folder that holds the file. Use a key whose owner can edit that folder.\n\nA service account key tried to delete a file it didn't upload. Use the personal key of the user who owns the file.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No file with this ID exists, or this key can't read it. Check the ID against [List files](https://docs.context.ai/build/agent-api/openapi/files#list-files). If the ID is correct, check that the key can read the file.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "The API no longer returns the file, but its stored copy couldn't be deleted. The message says where the copy remains in the owner's Drive. Delete it there, or quote `request_id` when you contact support.\n\nAn unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X DELETE \"$CONTEXT_BASE_URL/v1/files/329409ba-f288-4b44-9c73-14a18150edee\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "client.beta.files.delete(\"329409ba-f288-4b44-9c73-14a18150edee\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "await client.beta.files.delete(\"329409ba-f288-4b44-9c73-14a18150edee\")"
          }
        ]
      }
    },
    "/v1/files/{file_id}/content": {
      "get": {
        "tags": [
          "Files"
        ],
        "summary": "Download a file",
        "description": "Returns a file's content exactly as it was uploaded or as a session wrote it.\n\nFor an uploaded file, the file's owner must be able to read it in Drive. For a file a session produced, the key\nmust be able to read that session and the file in Drive. If a check fails, the request returns `404`.\n\nThe server streams the content, so the response has no `content-length` header. To read the file's name, size\nand media type without downloading it, see [Get a file](https://docs.context.ai/build/agent-api/openapi/files#get-a-file).\n\nThe key must have the `files:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the file's bytes. The `content-type` response header is the media type stored with the file, or `application/octet-stream` if none was sent.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 402 | `billing_error` | The file is a session's output, and your deployment requires a paid plan or credits before you can download session output. Add a plan or credits in the app, then retry. |\n| 404 | `not_found_error` | No file with this ID exists, or this key can't read the file or the session that produced it. Check the ID against the upload response or [List files](https://docs.context.ai/build/agent-api/openapi/files#list-files). If the ID is correct, check the access rules on this page. |\n| 404 | `not_found_error` | The file's content is no longer stored. If you uploaded the file, upload it again. |",
        "operationId": "files_download",
        "parameters": [
          {
            "in": "path",
            "name": "file_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the file to download."
            },
            "description": "The ID of the file to download."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the file's bytes. The `content-type` response header is the media type stored with the file, or `application/octet-stream` if none was sent.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "402": {
            "description": "The file is a session's output, and your deployment requires a paid plan or credits before you can download session output. Add a plan or credits in the app, then retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "billing_error",
                    "message": "Downloading needs a paid plan or credits."
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No file with this ID exists, or this key can't read the file or the session that produced it. Check the ID against the upload response or [List files](https://docs.context.ai/build/agent-api/openapi/files#list-files). If the ID is correct, check the access rules on this page.\n\nThe file's content is no longer stored. If you uploaded the file, upload it again.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/files/329409ba-f288-4b44-9c73-14a18150edee/content\" -H \"x-api-key: $CONTEXT_API_KEY\" -o cities.csv"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "client.beta.files.download(\"329409ba-f288-4b44-9c73-14a18150edee\").write_to_file(\"cities.csv\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "import { writeFile } from \"node:fs/promises\"\n\nconst response = await client.beta.files.download(\"329409ba-f288-4b44-9c73-14a18150edee\")\nawait writeFile(\"cities.csv\", Buffer.from(await response.arrayBuffer()))"
          }
        ]
      }
    },
    "/v1/skills": {
      "post": {
        "tags": [
          "Skills"
        ],
        "summary": "Create a skill",
        "description": "Creates a skill from uploaded files. The skill belongs to the owner of the API key.\n\nSend `multipart/form-data` with the skill's files in `files[]`. To upload a zip archive instead, send it as the\nonly `files[]` part. For the rules an upload must follow, see\n[Skills](https://docs.context.ai/build/agent-api/openapi/skills). Only the key's owner can see\nthe skill until they share it in the Context app.\n\nIf the request fails partway, the server deletes the skill, so no partial skill is left. If your organization\nuses the newer permissions model, a skill uploaded with files besides `SKILL.md` is saved as two versions:\n`SKILL.md` alone, then the whole upload. `latest_version_id` always points to the version that holds the whole\nupload.\n\nThe key must be a personal key with the `skills:write` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the skill object. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The upload breaks a rule: `SKILL.md` is missing or not at the root, `name` or `description` is missing or invalid, a path is unsafe, or the files total over 30 MiB (31,457,280 bytes) uncompressed. The message names the rule. Fix the files and upload again. |\n| 400 | `invalid_request_error` | `display_name` is not the `name` in `SKILL.md`. Leave it out, or send that name. |\n| 400 | `invalid_request_error` | The form has a field other than `files[]` and `display_name`, or the request has a query parameter. Remove it. |\n| 403 | `permission_error` | The key lacks `skills:write`, is not a personal key, or its owner doesn't have permission to create skills in this organization. Use a personal key with `skills:write`. |\n| 409 | `invalid_request_error` | The key's owner already has a skill with this name. The message gives its ID. Upload a new version of that skill, or change `name` in `SKILL.md`. |\n| 413 | `request_too_large` | The request is over 32 MiB (33,554,432 bytes). Remove files until the request is under 32 MiB. |\n| 429 | `rate_limit_error` | This key already has 2 skill uploads in progress, or the server is processing too many uploads. Wait for the time in `Retry-After`, then retry. The SDKs retry it for you. |",
        "operationId": "skills_create",
        "parameters": [
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "minItems": 1,
                    "description": "The skill's files. On the wire each file is one `files[]` part, with the file's path in the skill as the filename. The SDKs send the `files` parameter this way. You can instead send one zip archive that contains all the files."
                  },
                  "display_name": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "The skill's display name. Must equal the `name` in `SKILL.md`."
                  }
                },
                "required": [
                  "files"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with the skill object. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "skill"
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "display_name": {
                      "type": "string"
                    },
                    "latest_version_id": {
                      "type": "string"
                    },
                    "source": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "custom",
                            "anthropic"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "type",
                    "id",
                    "created_at",
                    "display_name",
                    "latest_version_id",
                    "source",
                    "updated_at"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e",
                  "type": "skill",
                  "created_at": "2026-10-27T15:02:11.204Z",
                  "display_name": "pr-summary",
                  "latest_version_id": "b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
                  "source": {
                    "type": "custom"
                  },
                  "updated_at": "2026-10-27T15:02:11.204Z"
                }
              }
            }
          },
          "400": {
            "description": "The upload breaks a rule: `SKILL.md` is missing or not at the root, `name` or `description` is missing or invalid, a path is unsafe, or the files total over 30 MiB (31,457,280 bytes) uncompressed. The message names the rule. Fix the files and upload again.\n\n`display_name` is not the `name` in `SKILL.md`. Leave it out, or send that name.\n\nThe form has a field other than `files[]` and `display_name`, or the request has a query parameter. Remove it.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks `skills:write`, is not a personal key, or its owner doesn't have permission to create skills in this organization. Use a personal key with `skills:write`.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "409": {
            "description": "The key's owner already has a skill with this name. The message gives its ID. Upload a new version of that skill, or change `name` in `SKILL.md`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "Ask changed before the answer"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "413": {
            "description": "The request is over 32 MiB (33,554,432 bytes). Remove files until the request is under 32 MiB.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "request_too_large",
                    "message": "Request bodies are capped at 10485760 bytes"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "This key already has 2 skill uploads in progress, or the server is processing too many uploads. Wait for the time in `Retry-After`, then retry. The SDKs retry it for you.\n\nThe key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X POST \"$CONTEXT_BASE_URL/v1/skills\" -H \"x-api-key: $CONTEXT_API_KEY\" \\\n  -F \"files[]=@pr-summary/SKILL.md;filename=pr-summary/SKILL.md\" \\\n  -F \"files[]=@pr-summary/summarize.py;filename=pr-summary/summarize.py\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "skill = client.beta.skills.create(\n    files=[\n        (\"pr-summary/SKILL.md\", open(\"pr-summary/SKILL.md\", \"rb\")),\n        (\"pr-summary/summarize.py\", open(\"pr-summary/summarize.py\", \"rb\")),\n    ],\n)\nprint(skill.id, skill.latest_version_id)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "import { readFile } from \"node:fs/promises\"\nimport { toFile } from \"@anthropic-ai/sdk\"\n\nconst skill = await client.beta.skills.create({\n  files: [\n    await toFile(await readFile(\"pr-summary/SKILL.md\"), \"pr-summary/SKILL.md\"),\n    await toFile(await readFile(\"pr-summary/summarize.py\"), \"pr-summary/summarize.py\"),\n  ],\n})"
          }
        ]
      },
      "get": {
        "tags": [
          "Skills"
        ],
        "summary": "List skills",
        "description": "Lists the skills the key's owner can read.\n\nThe list holds your organization's skills that the key's owner can read, and the built-in skills. Skills an\nadministrator has marked as verified come first, then the rest by `updated_at`, newest first. The list leaves\nout skills shared from another organization, archived skills and skills with no version yet.\n\nThe key must have the `skills:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a page of skill objects in `data` and a `next_page` value to pass as `page`. A response can hold fewer skills than `limit`, or none, and still have a `next_page` value. Keep requesting pages until `next_page` is `null`. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 200. Send a value from 1 to 200. |\n| 400 | `invalid_request_error` | `source` is not `custom` or `anthropic`. Send one of them, or leave it out. |\n| 400 | `invalid_request_error` | The request has a query parameter other than `limit`, `page` and `source`. Remove it. |",
        "operationId": "skills_list",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20,
              "description": "The maximum number of skills to return. Must be between 1 and 200."
            },
            "description": "The maximum number of skills to return. Must be between 1 and 200."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "in": "query",
            "name": "source",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "custom",
                "anthropic"
              ],
              "description": "The set of skills to return. One of `custom` (your organization's skills) or `anthropic` (built-in skills). Leave it out to return both."
            },
            "description": "The set of skills to return. One of `custom` (your organization's skills) or `anthropic` (built-in skills). Leave it out to return both."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a page of skill objects in `data` and a `next_page` value to pass as `page`. A response can hold fewer skills than `limit`, or none, and still have a `next_page` value. Keep requesting pages until `next_page` is `null`. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "skill"
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "latest_version_id": {
                            "type": "string"
                          },
                          "source": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "custom",
                                  "anthropic"
                                ]
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "type",
                          "id",
                          "created_at",
                          "display_name",
                          "latest_version_id",
                          "source",
                          "updated_at"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e",
                      "type": "skill",
                      "created_at": "2026-10-27T15:02:11.204Z",
                      "display_name": "pr-summary",
                      "latest_version_id": "b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
                      "source": {
                        "type": "custom"
                      },
                      "updated_at": "2026-10-27T15:02:11.204Z"
                    },
                    {
                      "id": "pptx",
                      "type": "skill",
                      "created_at": "2026-10-14T00:00:00.000Z",
                      "display_name": "pptx",
                      "latest_version_id": "c7d8e9f0-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                      "source": {
                        "type": "anthropic"
                      },
                      "updated_at": "2026-10-20T00:00:00.000Z"
                    }
                  ],
                  "next_page": null
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 200. Send a value from 1 to 200.\n\n`source` is not `custom` or `anthropic`. Send one of them, or leave it out.\n\nThe request has a query parameter other than `limit`, `page` and `source`. Remove it.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "The resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/skills?limit=20&source=custom\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "for skill in client.beta.skills.list(source=\"custom\"):  # auto-paginates\n    print(skill.id, skill.display_name)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "for await (const skill of client.beta.skills.list({ source: \"custom\" })) console.log(skill.id, skill.display_name)"
          }
        ]
      }
    },
    "/v1/skills/{skill_id}": {
      "get": {
        "tags": [
          "Skills"
        ],
        "summary": "Get a skill",
        "description": "Returns a skill by its ID.\n\nTo get a built-in skill, pass its slug, such as `pptx`, as `skill_id`. Archived skills and skills with no version return `404`.\n\nThe key must have the `skills:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the skill object. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 404 | `not_found_error` | No skill with this ID exists, the key's owner can't read it, the skill is archived, or it has no version yet. Check the ID and the key. To get an archived skill, unarchive it in the Context app. To get a skill with no version, [create a version](https://docs.context.ai/build/agent-api/openapi/skills#create-a-skill-version) first. |",
        "operationId": "skills_retrieve",
        "parameters": [
          {
            "in": "path",
            "name": "skill_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the skill, or a built-in skill's slug."
            },
            "description": "The ID of the skill, or a built-in skill's slug."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the skill object. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "skill"
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "display_name": {
                      "type": "string"
                    },
                    "latest_version_id": {
                      "type": "string"
                    },
                    "source": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "custom",
                            "anthropic"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": false
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "type",
                    "id",
                    "created_at",
                    "display_name",
                    "latest_version_id",
                    "source",
                    "updated_at"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e",
                  "type": "skill",
                  "created_at": "2026-10-27T15:02:11.204Z",
                  "display_name": "pr-summary",
                  "latest_version_id": "b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
                  "source": {
                    "type": "custom"
                  },
                  "updated_at": "2026-10-27T15:02:11.204Z"
                }
              }
            }
          },
          "400": {
            "description": "A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No skill with this ID exists, the key's owner can't read it, the skill is archived, or it has no version yet. Check the ID and the key. To get an archived skill, unarchive it in the Context app. To get a skill with no version, [create a version](https://docs.context.ai/build/agent-api/openapi/skills#create-a-skill-version) first.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/skills/8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "skill = client.beta.skills.retrieve(\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const skill = await client.beta.skills.retrieve(\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\")"
          }
        ]
      },
      "delete": {
        "tags": [
          "Skills"
        ],
        "summary": "Delete a skill",
        "description": "Deletes a skill, its versions and their files.\n\nThe skill is also removed from every agent it is assigned to. A built-in skill can't be deleted. The key's owner must be able to edit the skill. The delete can't be undone. In some organizations the skill's files are kept in Drive trash until the trash is emptied.\n\nThe key must be a personal key with the `skills:write` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with an object that holds the skill's `id` and a `type` of `skill_deleted`.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The skill is a built-in skill, which is read-only. Check that the ID is a custom skill's. |\n| 403 | `permission_error` | The key lacks `skills:write`, is not a personal key, or its owner can't edit this skill. Use a personal key with `skills:write` whose owner can edit the skill. |\n| 404 | `not_found_error` | No skill with this ID exists, or the key's owner can't read it. Check the ID. |",
        "operationId": "skills_delete",
        "parameters": [
          {
            "in": "path",
            "name": "skill_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the skill to delete."
            },
            "description": "The ID of the skill to delete."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with an object that holds the skill's `id` and a `type` of `skill_deleted`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "skill_deleted"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "type"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e",
                  "type": "skill_deleted"
                }
              }
            }
          },
          "400": {
            "description": "The skill is a built-in skill, which is read-only. Check that the ID is a custom skill's.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks `skills:write`, is not a personal key, or its owner can't edit this skill. Use a personal key with `skills:write` whose owner can edit the skill.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No skill with this ID exists, or the key's owner can't read it. Check the ID.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X DELETE \"$CONTEXT_BASE_URL/v1/skills/8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "client.beta.skills.delete(\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "await client.beta.skills.delete(\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\")"
          }
        ]
      }
    },
    "/v1/skills/{skill_id}/versions": {
      "post": {
        "tags": [
          "Skills"
        ],
        "summary": "Create a skill version",
        "description": "Saves a new version of a skill from its complete set of files.\n\nSend every file of the skill, the same way as for\n[Create a skill](https://docs.context.ai/build/agent-api/openapi/skills#create-a-skill). A version is a whole snapshot: any file you\nleave out is not in the new version. The `name` in `SKILL.md` must be the skill's name. The key's owner must be\nable to edit the skill.\n\nThe upload becomes the skill's newest version at once, so agents that have the skill use this version from\ntheir next session. An upload identical to the newest version saves nothing and returns that version.\n\nThe key must be a personal key with the `skills:write` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the skill version. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The upload breaks a rule, such as `SKILL.md` missing or the files totaling over 30 MiB (31,457,280 bytes) uncompressed. The message names the rule. Fix the files and upload again. |\n| 400 | `invalid_request_error` | The `name` in `SKILL.md` is not the skill's name. Keep the skill's name, or create a separate skill. |\n| 400 | `invalid_request_error` | The skill is a built-in skill, which is read-only. Create your own skill instead. |\n| 400 | `invalid_request_error` | The form has a field other than `files[]`. Remove it. |\n| 403 | `permission_error` | The key lacks `skills:write`, is not a personal key, or its owner can't edit this skill. Use a personal key with `skills:write` whose owner can edit the skill. |\n| 404 | `not_found_error` | No skill with this ID exists, or the key's owner can't read it. Check the ID, and check that the key's owner can read the skill. |\n| 413 | `request_too_large` | The request is over 32 MiB (33,554,432 bytes). Remove files until the request is under 32 MiB. |\n| 429 | `rate_limit_error` | This key already has 2 skill uploads in progress, or the server is processing too many uploads. Wait for the time in `Retry-After`, then retry. The SDKs retry it for you. |",
        "operationId": "skills_versions-create",
        "parameters": [
          {
            "in": "path",
            "name": "skill_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the skill."
            },
            "description": "The ID of the skill."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "minItems": 1,
                    "description": "The skill's files. On the wire each file is one `files[]` part, with the file's path in the skill as the filename. The SDKs send the `files` parameter this way. You can instead send one zip archive that contains all the files."
                  }
                },
                "required": [
                  "files"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns `200` with the skill version. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "skill_version"
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "description": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "skill_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "id",
                    "created_at",
                    "description",
                    "name",
                    "skill_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
                  "type": "skill_version",
                  "created_at": "2026-10-27T15:02:11.388Z",
                  "description": "Summarize a pull request for reviewers.",
                  "name": "pr-summary",
                  "skill_id": "8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e"
                }
              }
            }
          },
          "400": {
            "description": "The upload breaks a rule, such as `SKILL.md` missing or the files totaling over 30 MiB (31,457,280 bytes) uncompressed. The message names the rule. Fix the files and upload again.\n\nThe `name` in `SKILL.md` is not the skill's name. Keep the skill's name, or create a separate skill.\n\nThe skill is a built-in skill, which is read-only. Create your own skill instead.\n\nThe form has a field other than `files[]`. Remove it.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks `skills:write`, is not a personal key, or its owner can't edit this skill. Use a personal key with `skills:write` whose owner can edit the skill.\n\nThe key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No skill with this ID exists, or the key's owner can't read it. Check the ID, and check that the key's owner can read the skill.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "413": {
            "description": "The request is over 32 MiB (33,554,432 bytes). Remove files until the request is under 32 MiB.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "request_too_large",
                    "message": "Request bodies are capped at 10485760 bytes"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "This key already has 2 skill uploads in progress, or the server is processing too many uploads. Wait for the time in `Retry-After`, then retry. The SDKs retry it for you.\n\nThe key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS -X POST \"$CONTEXT_BASE_URL/v1/skills/8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e/versions\" \\\n  -H \"x-api-key: $CONTEXT_API_KEY\" -F \"files[]=@pr-summary.zip;type=application/zip\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "version = client.beta.skills.versions.create(\n    \"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\",\n    files=[(\"pr-summary.zip\", open(\"pr-summary.zip\", \"rb\"), \"application/zip\")],\n)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "import { readFile } from \"node:fs/promises\"\nimport { toFile } from \"@anthropic-ai/sdk\"\n\nconst version = await client.beta.skills.versions.create(\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\", {\n  files: [await toFile(await readFile(\"pr-summary.zip\"), \"pr-summary.zip\", { type: \"application/zip\" })],\n})"
          }
        ]
      },
      "get": {
        "tags": [
          "Skills"
        ],
        "summary": "List skill versions",
        "description": "Lists a skill's versions, newest first.\n\nYou can't delete a single version: `DELETE /v1/skills/{skill_id}/versions/{version}` returns `400`. To replace a version, [upload a new one](https://docs.context.ai/build/agent-api/openapi/skills#create-a-skill-version). To remove every version, [delete the skill](https://docs.context.ai/build/agent-api/openapi/skills#delete-a-skill).\n\nThe key must have the `skills:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a page of skill version objects in `data`, newest first, and a `next_page` value to pass as `page`. `next_page` is `null` on the last page. A version's `id` is what `{version}` takes. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | `limit` is outside 1 to 100. Send a value from 1 to 100. |\n| 404 | `not_found_error` | No skill with this ID or slug exists, or the key's owner can't read it. Check the ID or slug, and that the key's owner can read the skill. |",
        "operationId": "skills_versions-list",
        "parameters": [
          {
            "in": "path",
            "name": "skill_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the skill, or a built-in skill's slug."
            },
            "description": "The ID of the skill, or a built-in skill's slug."
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "description": "The maximum number of versions to return. Must be between 1 and 100."
            },
            "description": "The maximum number of versions to return. Must be between 1 and 100."
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The `next_page` value from the previous response. Leave it out to get the first page."
            },
            "description": "The `next_page` value from the previous response. Leave it out to get the first page."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a page of skill version objects in `data`, newest first, and a `next_page` value to pass as `page`. `next_page` is `null` on the last page. A version's `id` is what `{version}` takes. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "skill_version"
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "description": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "skill_id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "type",
                          "id",
                          "created_at",
                          "description",
                          "name",
                          "skill_id"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "next_page": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "next_page"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "data": [
                    {
                      "id": "b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
                      "type": "skill_version",
                      "created_at": "2026-10-27T15:02:11.388Z",
                      "description": "Summarize a pull request for reviewers.",
                      "name": "pr-summary",
                      "skill_id": "8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e"
                    }
                  ],
                  "next_page": null
                }
              }
            }
          },
          "400": {
            "description": "`limit` is outside 1 to 100. Send a value from 1 to 100.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No skill with this ID or slug exists, or the key's owner can't read it. Check the ID or slug, and that the key's owner can read the skill.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/skills/8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e/versions\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "for version in client.beta.skills.versions.list(\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\"):\n    print(version.id, version.created_at)"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "for await (const version of client.beta.skills.versions.list(\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\")) console.log(version.id)"
          }
        ]
      }
    },
    "/v1/skills/{skill_id}/versions/{version}": {
      "get": {
        "tags": [
          "Skills"
        ],
        "summary": "Get a skill version",
        "description": "Returns one version of a skill, or its newest version if you pass `latest` as `version`.\n\nThe key must have the `skills:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with the skill version. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 404 | `not_found_error` | No skill with this ID or slug exists, the key's owner can't read it, or the version is not one of this skill's. Check `skill_id` and `version`, and that the key's owner can read the skill. |",
        "operationId": "skills_versions-retrieve",
        "parameters": [
          {
            "in": "path",
            "name": "skill_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the skill, or a built-in skill's slug."
            },
            "description": "The ID of the skill, or a built-in skill's slug."
          },
          {
            "in": "path",
            "name": "version",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The version's ID, or `latest`."
            },
            "description": "The version's ID, or `latest`."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with the skill version. For every field, see [Skills](https://docs.context.ai/build/agent-api/openapi/skills).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "skill_version"
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "description": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "skill_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "id",
                    "created_at",
                    "description",
                    "name",
                    "skill_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "id": "b1c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
                  "type": "skill_version",
                  "created_at": "2026-10-27T15:02:11.388Z",
                  "description": "Summarize a pull request for reviewers.",
                  "name": "pr-summary",
                  "skill_id": "8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e"
                }
              }
            }
          },
          "400": {
            "description": "A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No skill with this ID or slug exists, the key's owner can't read it, or the version is not one of this skill's. Check `skill_id` and `version`, and that the key's owner can read the skill.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/skills/8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e/versions/latest\" -H \"x-api-key: $CONTEXT_API_KEY\""
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "version = client.beta.skills.versions.retrieve(\"latest\", skill_id=\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "const version = await client.beta.skills.versions.retrieve(\"latest\", { skill_id: \"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\" })"
          }
        ]
      }
    },
    "/v1/skills/{skill_id}/versions/{version}/content": {
      "get": {
        "tags": [
          "Skills"
        ],
        "summary": "Download a skill version",
        "description": "Returns a version's files as one zip archive.\n\nThe archive holds `SKILL.md` and the supporting files under one folder named after the skill's name, the same layout that [Create a skill version](https://docs.context.ai/build/agent-api/openapi/skills#create-a-skill-version) accepts. The zip file has the same name. If a skill made in the Context app has a name with other characters than lowercase letters, digits and hyphens, the folder name is rewritten in those characters, so `Q3 / Q4 report` becomes `q3-q4-report`. If no letters or digits are left, the folder is named after the skill's ID. Pass `latest` as `version` for the newest version.\n\nThe key must have the `skills:read` capability. For what each capability allows, see [Keys](https://docs.context.ai/build/api-basics/keys#agent-api-capabilities).\n\n## Response\n\nReturns `200` with a zip archive. The `content-type` response header is `application/zip`, and `content-disposition` names the file after the skill, such as `pr-summary.zip`.\n\n## Errors\n\nThis endpoint can return these errors as well as the [common errors](https://docs.context.ai/build/api-basics/errors#agent-api-status-codes).\n\n| Status | `error.type` | Cause and fix |\n|---|---|---|\n| 400 | `invalid_request_error` | The version was saved before your deployment stored skill file contents, so the server has no files to return. Download a later version. If none exists, upload the skill's files again as a new version. |\n| 404 | `not_found_error` | No skill with this ID or slug exists, the key's owner can't read it, or the version is not one of this skill's. Check `skill_id` and `version`, and that the key's owner can read the skill. |",
        "operationId": "skills_versions-content",
        "parameters": [
          {
            "in": "path",
            "name": "skill_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The ID of the skill, or a built-in skill's slug."
            },
            "description": "The ID of the skill, or a built-in skill's slug."
          },
          {
            "in": "path",
            "name": "version",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The version's ID, or `latest`."
            },
            "description": "The version's ID, or `latest`."
          },
          {
            "$ref": "#/components/parameters/AnthropicWorkspaceId"
          }
        ],
        "responses": {
          "200": {
            "description": "Returns `200` with a zip archive. The `content-type` response header is `application/zip`, and `content-disposition` names the file after the skill, such as `pr-summary.zip`.",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "The version was saved before your deployment stored skill file contents, so the server has no files to return. Download a later version. If none exists, upload the skill's files again as a new version.\n\nA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "environment_id: Required"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "401": {
            "description": "The request has no key, or its key is unknown, revoked or expired, or the key's owner left the organization. Send a valid key, or create a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "authentication_error",
                    "message": "invalid x-api-key"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a capability, can't run the agent or doesn't act for the session's owner. A service account key also gets `403` for `user.tool_confirmation` and for deleting a file it didn't upload. Use a key that has the capability and acts for the session's owner. For `user.tool_confirmation`, use a personal key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "permission_error",
                    "message": "Task API key missing required capability: tasks:create"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "404": {
            "description": "No skill with this ID or slug exists, the key's owner can't read it, or the version is not one of this skill's. Check `skill_id` and `version`, and that the key's owner can read the skill.\n\nThe resource doesn't exist, this key can't read it, or the path isn't part of this API. Check the ID, the path and the key's **Agent scope**.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "not_found_error",
                    "message": "Session 00000000-0000-0000-0000-000000000000 not found"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "429": {
            "description": "The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in `Retry-After`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "rate_limit_error",
                    "message": "Too many requests for this key; retry after the Retry-After interval"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error occurred. Quote `request_id` when you contact support. A session delete that returns `500` deleted nothing, so retry it. A session request with more than 50 attached files also returns `500`, which is a known defect. Attach 50 or fewer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "error"
                      ]
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "invalid_request_error",
                            "authentication_error",
                            "billing_error",
                            "permission_error",
                            "not_found_error",
                            "request_too_large",
                            "rate_limit_error",
                            "api_error"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "error",
                    "request_id"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "type": "error",
                  "error": {
                    "type": "api_error",
                    "message": "Internal server error"
                  },
                  "request_id": "1-6ad81775-559de67252e7acee31a72eba"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "cURL",
            "source": "curl -sS \"$CONTEXT_BASE_URL/v1/skills/8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e/versions/latest/content\" -H \"x-api-key: $CONTEXT_API_KEY\" -o pr-summary.zip"
          },
          {
            "lang": "Python",
            "label": "Python",
            "source": "client.beta.skills.versions.download(\"latest\", skill_id=\"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\").write_to_file(\"pr-summary.zip\")"
          },
          {
            "lang": "TypeScript",
            "label": "TypeScript",
            "source": "import { writeFile } from \"node:fs/promises\"\n\nconst response = await client.beta.skills.versions.download(\"latest\", { skill_id: \"8b3f6c1e-2a4d-4f7b-9c1e-5d6a7b8c9d0e\" })\nawait writeFile(\"pr-summary.zip\", Buffer.from(await response.arrayBuffer()))"
          }
        ]
      }
    }
  }
}
