Skip to content
Context docs
Build

Coming from Anthropic's API

Code that follows Anthropic’s Managed Agents quickstart runs on your Context deployment with these changes:

  1. Point the SDK at your deployment’s host and authenticate with a Context task API key, either a personal key or a service account key. Choose a key explains which one to use.
  2. Don’t create an environment. Pass env_default as the session’s environment.
  3. Create the agent with a personal key that has the agents:write capability, or pick an existing agent with List agents.
  4. Stop reading the stream only when session.status_idle has a stop_reason.type of end_turn or retries_exhausted. Answer requires_action with user.tool_confirmation.
  5. Turn off SDK retries, because sending events isn’t idempotent (see SDKs).

You can’t configure an environment through the API, so there are no per-environment packages or network allowlists. On a self-hosted (KOTS) deployment, the network allowlist is one setting for the whole deployment, in the KOTS Admin Console (see Network access).

Other calls differ. See What’s stubbed or ignored, Not supported and Behavior that differs. Where the Roadmap has an item that closes a difference, the line links to it.

To find these changes in an existing codebase, install the context-managed-agents skill in your AI coding agent, such as Claude Code. It flags every call Context refuses and rewrites what it can. See Build with an AI coding agent.

Anthropic’s quickstart on Context

Anthropic’s stepOn Context
Create an agentWorks with a personal key that has the agents:write capability. Set model to default or to a model your deployment runs. In tools, include only the built-in toolset. To use an agent built in the app, call List agents instead.
Create an environmentReturns 400 for the body Anthropic’s quickstart sends, which sets limited networking and package managers. For network access on Context, see Network access. Use env_default (see Environments).
Create a sessionWorks unchanged. Pass the agent ID from the first step and env_default.
Stream, then send a messageWorks, with one change to your loop. Stop on a session.status_idle whose stop_reason.type is end_turn or retries_exhausted, not on any idle. An agent with a tool that needs approval (the Ask setting in the Context app) goes idle with requires_action first. Answer it with user.tool_confirmation, as shown in Send events.

Headers

anthropic-workspace-id is served: it names the Context workspace the request runs in, and the key’s owner must work there. For the headers Context ignores or refuses, see What’s stubbed or ignored.

Where a session runs

RequestThe session runs in
With anthropic-workspace-idThat workspace. It returns 404 if the key’s owner doesn’t work there, 403 if the agent isn’t in it, and 400 if a member named with x-context-owner-user-id or x-context-owner-user-email doesn’t work there.
Without itThe workspace the agent is installed in, if the session’s owner works there. Otherwise the owner’s private workspace.

Either way, the agent must be in the workspace the session would run in. If it isn’t, Create a session returns 400 with Agent "<name>" (<id>) is not in a workspace this session can run in. Send anthropic-workspace-id naming a workspace that both the agent and the session’s owner are in, or create the agent with metadata.workspace_id set to such a workspace.

The session object has no workspace field. To see where a session ran, read its task with the Task API: the session’s ID is the task’s ID, the same key works with Authorization: Bearer, and the response’s workspaceId and workspaceName name the workspace (null for a task in no workspace).

TerminalCode
curl -sS "$CONTEXT_BASE_URL/api/v1/tasks/roots/SESSION_ID" \ -H "Authorization: Bearer $CONTEXT_API_KEY"

Agent API or Task API

Both APIs start the same kind of task with the same key, so using both on one session is expected.

Use the Agent API toUse the Task API (/api/v1/tasks) to
Run code written for Anthropic’s SDKs.Choose the workspace in the body (workspaceId).
Stream a turn over server-sent events and resume with Last-Event-ID.Get a webhook when the task finishes (delivery).
Answer tool confirmations from your code (user.tool_confirmation, personal keys only).Have the server check the result against an outputSchema.
Page through a session’s events in Anthropic’s shape.Load skills on a new task (input.skills), or, with a service account key, start it for another member (ownerUserId, ownerUserEmail).

POST /api/v1/tasks/prompt also takes a workspace by its slug (workspaceSlug) and a share setting (shareMode).

What’s stubbed or ignored

Some calls and inputs that Anthropic’s SDKs send get a normal response from Context, but Context doesn’t do what Anthropic’s API does with them. This table lists each one, along with the related calls that return an error.

Anthropic call or inputWhat Context returns or does
environments.create with no config, or a cloud config with unrestricted networking and no packagesReturns env_default. It creates nothing, and every call returns the same environment. name, description and metadata are ignored.
environments.create with packages, limited networking, self_hosted, scope or any other configReturns 400. Roadmap: Locked-down environments.
environments.update, environments.delete and environments.archiveReturn 404, because Context doesn’t serve these paths.
env_default’s config and timestampsconfig always reports unrestricted networking and empty packages, even when a self-hosted deployment restricts sandbox network access. The environment’s description, created_at and updated_at never change.
include_archived on environments.listContext ignores it. No environment is ever archived.
The anthropic-version and anthropic-beta headers, and the beta=true query parameter the SDKs addContext ignores them, so the headers can hold any value.
The Idempotency-Key headerThe SDKs send this header only when you pass an idempotency key as a request option. Requests with Idempotency-Key return 400, so don’t pass one. Context doesn’t deduplicate requests, so a retried request runs again. Roadmap: Safe retries.
anthropic-workspace-id on files, environments and skills requestsContext checks that the key’s owner works in that workspace, then ignores the header. If the owner doesn’t work there, the request returns 404. Files and skills belong to the key’s owner, not to a workspace.
web_search in an agent’s toolsIn the built-in toolset, web_search always reads back with enabled: false, and it never runs. Agents search the web with Context’s own search tool. You can leave it out or send it with enabled: false. Naming it without enabled: false, or with enabled: true, returns 400.
execution_identity on an agentOnly {type: "service_account"} is accepted, and it changes nothing. Every agent reads back that value. Any other value returns 400.
Agent fields Context doesn’t useEvery agent reads back version: 1, archived_at: null, metadata: {}, mcp_servers: [] and multiagent: null.
expires_in_seconds on files.uploadContext checks the value against Anthropic’s range of 3,600 to 7,776,000 seconds (1 hour to 90 days), then ignores it. A value outside the range returns 400. Files never expire and have no expires_at.
metadata, vault_ids and budget on sessions.createAn empty metadata, an empty vault_ids and a null budget are ignored. Any other value returns 400.
Session fields Context doesn’t useEvery session reads back metadata: {}, vault_ids: [], budget: null, outcome_evaluations: [] and stats: {}.
The rescheduling status in the statuses filter on sessions.listContext accepts it, but it matches nothing, because no session is ever rescheduling.
Usage on session.usage events and on the sessionsession.usage events have no list_cost. On the session, list_cost is null until billing settles. Every cache write counts as a 5-minute write, so ephemeral_1h_input_tokens is always 0. server_tool_use is never sent.

Not supported

  • Agents:
    • Versioning and archiving an agent return 404. Every agent has one version, 1, and an update has no conflict check. Roadmap: Agent versions.
    • tools takes the built-in toolset and custom tools. MCP servers, the auto permission policy and the web tools’ domain and location options return 400. You can’t turn on web_search (see What’s stubbed or ignored). Because mcp_servers returns 400, so does GitHub’s MCP server. A custom tool is answered with user.custom_tool_result as in Anthropic’s API; a computer you paired with the Context app whose mcp.json servers advertise a tool of exactly its name can answer it too, and the first answer counts. A call nobody answers ends after 12 minutes with an error result. Which computers may answer follows the key that created the session: a personal key’s sessions are answered by the key owner’s own paired computers; a service account key’s sessions are answered only by machines registered with that key (context login --api-key, the key carrying machines:serve), never by a person’s computer, not even the computer of a member the session was created for.
    • multiagent and a model’s effort, inference_geo or speed return 400. Without multiagent there are no workflow runs, so workflow_run.* events are never sent.
    • On list, include_archived=true and the created_at filters return 400.
    • On create, metadata takes only workspace_id. Any metadata on an update returns 400.
  • Environments: You can’t create a custom environment or use limited networking. For what each environment call returns, see What’s stubbed or ignored. Roadmap: Locked-down environments.
    • The environment work endpoints, which Anthropic’s self-hosted environment worker polls, aren’t served. Their paths return 404. Roadmap: Run agents on your own machines.
  • Sessions:
    • Agent overrides, a non-empty metadata, vault_ids and budget return 400. For the values Context accepts, see What’s stubbed or ignored. If the agent object includes a version, it must be 1. Roadmap: Session labels and per-session settings, and Saved credentials for vault_ids.
    • initial_events takes at most one user.message. More than one returns 400. Roadmap: Start a session with more than one message.
    • Only file resources work. The session resources endpoints aren’t served. Their paths return 404. A github_repository resource returns 400.
    • An update takes only title. agent, vault_ids, budget and a non-empty metadata return 400.
    • The session threads endpoints aren’t served. Their paths return 404.
    • On list, order=asc and the agent_version, deployment_id and memory_store_id filters return 400.
  • Events:
    • event_deltas and session_thread_id return 400, because event deltas and threads aren’t supported. The stream sends each message whole. Roadmap: Replies that stream as they’re written.
    • Sending user.tool_result, user.define_outcome or system.message returns 400.
    • A user.message takes only text blocks. Any other block, such as an image, returns 400, and so does cache_control on a text block. To give the agent an image or a PDF, upload it as a file and attach it to the session. Roadmap: Images and PDFs in a message.
    • Only 13 event types are sent. For the list, see Events.
    • session.error uses five error types. MCP, credential and repository error types are never sent, and retry_status.type is never terminal.
  • Files: On List files, ids and a limit over 100 return 400. You can’t delete a session’s output files on their own, or attach them to another session. Deleting the session removes them.
  • Skills: A skill on an agent takes only latest as a version. Deleting a skill version returns 400. The built-in skills include no pdf skill. Writing to a built-in skill returns 400.
  • Other resources: Vaults, memory stores, MCP configuration, webhooks, outcomes, budgets, deployments, deployment runs, dreams, tunnels and user profiles aren’t served. Their paths return 404.
  • CLI: Anthropic’s ant CLI isn’t supported.
  • In the Context app instead: MCP servers, webhooks, schedules and subagents are features of the Context app, not this API. To give an agent MCP servers or connected accounts, set them up in the Context app. If you need one of these in the API, tell us.

Behavior that differs

  • Deleting a session: The key needs the sessions:delete capability, which is off by default. You can turn it on only when you create the key (see Agent API capabilities). While a turn is running, the request returns 409. Send user.interrupt, then delete the session once it’s idle. The response lists what was removed and what is kept.
  • Archiving a session: You can archive a running session, which Anthropic’s API refuses. The current turn isn’t cut short, so send user.interrupt first to stop it.
  • Keeping data: Nothing expires or is deleted on a schedule. Your deployment keeps sessions, files and skills until you delete them. See How long data is kept.
  • Mounting files: mount_path takes a path under /workspace/ or /mnt/session/uploads/. Any other absolute path is placed under /mnt/session/uploads/, so /data.csv becomes /mnt/session/uploads/data.csv. A file sent without mount_path isn’t copied to the agent’s disk. It stays in the session’s inputs/ folder. On Anthropic’s API, such a file is mounted at /mnt/session/uploads/<file_id>.
  • Session outputs: The agent writes them to /mnt/session/outputs/, as on Anthropic’s API. List them by setting scope_id to the session ID on List files. They stay listed after the session is archived.
  • Agent instructions: The system field reads null unless the calling key’s owner created the agent.
  • Custom tool names: A custom tool’s name must be lowercase letters, digits and underscores, starting with a letter, at most 64 characters (^[a-z][a-z0-9_]*$). Anthropic’s API accepts ^[a-zA-Z0-9_-]{1,128}$, so a name like getWeather returns 400 here; write it get_weather. The name becomes a tool the agent’s runtime calls by that spelling and the name a paired computer advertises, which is why it isn’t rewritten for you.
  • Skills: A skill belongs to the key’s owner, not to a workspace. Skill requests ignore the workspace anthropic-workspace-id names (see What’s stubbed or ignored). Creating a skill needs the skills:write capability, which only a personal key can have. display_name must match the name in SKILL.md. Each deployment has its own built-in skills. List skills returns them, and each one is identified by its slug.

Limits and values that differ

WhatContextAnthropic
Session titleUp to 280 charactersUp to 500 characters
Files per session50500
Where the agent runsYour deployment, with its modelsAnthropic’s servers, with Claude models
File sizeUp to 5 GiB by default, set per deploymentUp to 500 MB
One turnStopped after 4 hours by default. Set up to 12 hours (your deployment’s maximum) with max_step_minutes on POST /v1/sessionsNo limit stated, and no session field to set one
List limitUp to 100 (events: 1,000, skills: 200)Up to 1,000
Rate limitsPer key, where your deployment enforces them. See LimitsPer organization: 300 creates and 1,200 reads a minute
error.type on 409invalid_request_error, so check the status code insteadconflict_error
ID returned when you send an eventsevt_receipt_<uuid>The event’s ID
Custom tool name^[a-z][a-z0-9_]*$, up to 64 characters^[a-zA-Z0-9_-]{1,128}$

A session request with more than 50 files returns 500 instead of a named 400. This is a known defect.

A turn is the agent’s work on one message (also called a step). A turn that runs past the session’s max_step_minutes (4 hours if you set none) is stopped, and the session goes idle with retries_exhausted. Time spent waiting for your approval doesn’t count. Send the message again to retry.

On Anthropic’s API, a self-hosted sandbox runs the agent’s tools on your machines, while the agent itself still runs on Anthropic’s servers. On Context, the whole agent runs on your deployment, with the models your deployment is set up to run.

Sending an event returns a receipt ID, not the event’s ID. The stored event gets its own ID, which appears on the stream and in the session’s history.

Context extensions

Anthropic’s API has none of these:

  • The stream takes a Last-Event-ID header to resume after a disconnect.
  • List files takes after_id and before_id and returns has_more, first_id and last_id.
  • On POST /v1/sessions only, a service account key can send x-context-owner-user-id or x-context-owner-user-email (one, not both) with a member’s user ID or email, to create a session that member owns.
  • To create an agent in a workspace, send metadata.workspace_id.
  • POST /v1/sessions takes max_step_minutes, the longest one step may run. The session object returns it.