Agents
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.
Note: To create or update an agent, you must use a personal key with the
agents:writecapability.
The agent object
| Field | Type | Description |
|---|---|---|
id | string | The agent's ID. Pass it as agent when you create a session. |
type | string | Always agent. |
name | string | The agent's name, as shown in the app. |
description | string | null | The agent's purpose. null when the agent has no description. |
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 lists the IDs you can set. |
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. |
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 "". |
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. |
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. |
created_at | string | When the agent was created, as an RFC 3339 timestamp. |
updated_at | string | When the agent was last changed, as an RFC 3339 timestamp. |
Each built-in tool maps to its approval setting in the app. always_allow is Allow, always_ask is Ask
(each call waits for a person to approve it), and enabled: false is Deny. edit and write share one
setting in the app, so they always read the same. web_search is always off, because agents search the web with
your deployment's own search tool. A tool that is off reads always_ask.
model and effective_model answer two different questions, and both are needed. model is the stored choice,
which a write round-trips; effective_model is the resolution, which no write accepts. They differ whenever model
does not name the model that will run: an agent set to default, and an agent whose stored model your deployment no
longer serves.
effective_model is resolved the way a session resolves it, by taking the first of these your deployment can serve:
- the agent's own model, when it is still in the catalog;
- a model you connected through your own subscription, if you have one;
- your deployment's default model.
Two consequences worth knowing. Because of rung 2, effective_model.id is usually one of the IDs
GET /v1/models lists but need not be — that list is your
deployment's and leaves out models reached through a person's own connected account. And it is the answer for a
session created through this API, which runs in your deployment's cloud; a session on a paired computer chooses from
that computer's own models.
null means a session would be refused a model rather than "no model configured": either the catalog serves nothing,
or the deployment's configured default is not in it.
Note:
effective_modelcannot be sent on a create or update. Posting a whole agent object back is refused with400naming it, along with the other read-only fields — so a client that round-trips an agent can never turn one that was following your deployment's default into a pinned one by accident.
Some 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"}.
Example
Code
Differences from Anthropic's API
This API follows Anthropic's Managed Agents API, with these differences:
- The agent version and archive endpoints return
404. Every agent has one version,1, and an update changes it in place, so a later update overwrites an earlier one without an error. In an update,versionmust be1. - The
modelobject has only anidfield.effort,inference_geoandspeedreturn400. systemisnullunless the key is a personal key withagents:writewhose owner created the agent and still owns it.toolstakes the built-in toolset and custom tools; a custom tool is answered by your client or by a paired computer that advertises it, whichever is first. MCP servers, theautopermission policy and the domain and location options of the web tools return400.web_searchis always off. To give an agent MCP servers or connected accounts, set them up in the Context app.- Skills take
latestas their only version. multiagentand anyexecution_identityother than{type: "service_account"}return400.- To create an agent in a workspace, send
metadata.workspace_idor theanthropic-workspace-idheader. If you send both, they must name the same workspace, or the request returns400.
For every difference in one place, see Coming from Anthropic's API.
List agents
Lists the agents an API key can run, one page at a time.
A personal key lists the agents its owner can run, sorted by updated_at, newest first. This is the same list
the agent picker in the Context app shows. A service account key lists every agent in the organization, sorted
by created_at, newest first. If the key is limited to specific agents (its Agent scope), the result
includes only those. The list never includes archived agents.
The system field is null unless the key is a personal key with agents:write whose owner created the agent.
A service account key always gets null.
The key must have the tasks:read capability. For what each capability allows, see Keys.
Response
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.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | limit is outside 1 to 100. Send a value from 1 to 100. |
| 400 | invalid_request_error | page is not a next_page value from this API. Send the next_page value from the previous response, unchanged. |
| 400 | invalid_request_error | include_archived is any value other than false. Omit it. |
| 400 | invalid_request_error | The request sends a created_at[*] filter (created_at[gte] or created_at[lte]). Remove it. |
query Parameters
limitThe 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.
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.
pageThe next_page value from the previous response. Leave it out to get the first page.
The next_page value from the previous response. Leave it out to get the first page.
include_archivedNot supported. Omit it or send false. Any other value returns 400.
Not supported. Omit it or send false. Any other value returns 400.
Headers
anthropic-workspace-idThe 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.
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.
List agents › Responses
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.
next_pageCreate an agent
Creates an agent that the key's owner owns.
The API applies the same checks and defaults as creating an agent in the Context app. You need permission to create agents in the organization, and the key must have no Agent scope (no list of specific agents). If the request fails, no agent is created.
The agent goes in the workspace named by metadata.workspace_id. Without it, the agent goes in your oldest
shared (not private) workspace that you can work in, or in no workspace if there is none.
The key must be a personal key with the agents:write capability. For what each capability allows, see Keys.
Response
Returns 200 with the agent object. For every field, see Agents.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 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. |
| 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. |
| 400 | invalid_request_error | metadata has a key other than workspace_id. Remove the other keys. |
| 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. |
| 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. |
| 400 | invalid_request_error | A permission_policy is auto. Use always_allow or always_ask. |
| 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. |
| 400 | invalid_request_error | web_search is enabled, or named without enabled: false. Leave it out or send enabled: false. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
Headers
anthropic-workspace-idThe 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.
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.
Create an agent › Request Body
A model ID your deployment runs (GET /v1/models lists them), or default for your deployment's default model. The object form {id} takes only id.
nameThe agent's name. Must be between 1 and 100 characters after leading and trailing spaces are trimmed.
descriptionThe agent's purpose.
execution_identityOmit it, or send null or {type: "service_account"}, which changes nothing. Any other value returns 400.
mcp_serversNot 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.
multiagentNot supported. Omit it or send null. Any other value returns 400.
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. version is optional and must be latest.
systemThe agent's instructions.
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.
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.
Create an agent › Responses
Returns 200 with the agent object. For every field, see Agents.
idarchived_atcreated_atdescriptionmetadataeffective_modelmultiagentnamesystemtypeupdated_atversionGet an agent
Returns an agent that the calling API key can run.
A 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.
The key must have the tasks:read capability. For what each capability allows, see Keys.
Response
Returns 200 with the agent object. For every field, see Agents.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | version is not 1. Omit version or send 1. |
| 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. |
path Parameters
agent_idThe ID of the agent to return.
The ID of the agent to return.
query Parameters
versionNot supported. Omit it or send 1. Any other value returns 400. Every agent has exactly one version.
Not supported. Omit it or send 1. Any other value returns 400. Every agent has exactly one version.
Headers
anthropic-workspace-idThe 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.
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.
Get an agent › Responses
Returns 200 with the agent object. For every field, see Agents.
idarchived_atcreated_atdescriptionmetadataeffective_modelmultiagentnamesystemtypeupdated_atversionUpdate an agent
Updates an agent. Fields you leave out keep their values.
The API applies the same checks as an edit in the Context app. You must be allowed to edit the agent, and the
key's Agent scope, if it has one, must include the agent. tools and skills replace the whole list when
you send them. Every agent has one version, 1: an update changes the agent in place and does not check for
edits made since you read it, so the last update wins.
If part of an update is saved and a later part is refused, the error message names the saved fields. Get the agent before you retry.
The key must be a personal key with the agents:write capability. For what each capability allows, see Keys.
Response
Returns 200 with the agent object. For every field, see Agents.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | version is not 1. Omit it or send 1. |
| 400 | invalid_request_error | metadata is not empty. Omit it or send {}. To change an agent's workspace, use the Context app. |
| 400 | invalid_request_error | A field breaks a rule of Create an agent, such as an unknown model or a custom tool. Fix the field as the matching row there describes. |
| 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. |
| 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. |
| 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. |
| 403 | permission_error | You are not allowed to edit this agent. Ask its owner for access. |
| 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. |
| 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. |
path Parameters
agent_idThe ID of the agent to update.
The ID of the agent to update.
Headers
anthropic-workspace-idThe 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.
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.
Update an agent › Request Body
descriptionThe agent's purpose. null clears it.
execution_identityOmit it, or send null or {type: "service_account"}, which changes nothing. Any other value returns 400.
mcp_serversNot 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.
A model ID your deployment runs (GET /v1/models lists them), or the object form {id}. default removes the agent's own model, so it uses your deployment's default.
multiagentNot supported. Omit it or send null. Any other value returns 400.
The agent's skills, in the same shape as on Create an agent. Replaces the whole list. null or [] removes them.
systemThe agent's instructions. null clears them.
The agent's built-in tool settings, in the same shape as on Create an agent. Replaces the whole list. null or [] turns every built-in tool off.
nameThe agent's name. Must be between 1 and 100 characters after leading and trailing spaces are trimmed.
metadataNot supported. Omit it, or send null or {}. Any other value returns 400.
versionThe agent's version. Must be 1. Any other value returns 400.
Update an agent › Responses
Returns 200 with the agent object. For every field, see Agents.
idarchived_atcreated_atdescriptionmetadataeffective_modelmultiagentnamesystemtypeupdated_atversionList models
Lists the models an agent can be set to run in this deployment.
Each id is exactly what you send as model when you create or
update an agent, so a model picker built from this list offers
nothing those endpoints refuse. The list is the deployment's, not the key's: every key in a deployment gets the
same answer.
"default" is also accepted as model on a write, and it is what an agent reads back when it leaves the choice
to the deployment. It is not a row in this list, because it names no particular model.
Two kinds of model are deliberately missing. A model your deployment still runs but that an agent may no longer be pinned to — a model route the deployment has retired — is not listed, because a write would refuse it. A model you reach only through a subscription you connected yourself is not listed either, though a write still accepts it for you: one key's list must not describe another person's connected accounts.
The key must have the tasks:read capability. For what each capability allows, see Keys.
Note: Anthropic's API has no equivalent of this endpoint, and the SDKs carry no method for it. Call it with an HTTP client. The model IDs here are your deployment's own (
<provider>/<model>), not Anthropic model names.
Response
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.
| Field | Type | Description |
|---|---|---|
id | string | Send this as model on an agent write. An agent read answers the same string in model.id. |
display_name | string | The model's name as the Context app shows it. |
type | string | Always model. |
A 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.
A deployment whose every model route has been retired answers an empty data with next_page null: those
models still run, but no agent may be set to one of them.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | limit is outside 1 to 100. Send a value from 1 to 100. |
| 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. |
query Parameters
limitThe maximum number of models to return. Must be between 1 and 100.
The maximum number of models to return. Must be between 1 and 100.
pageThe next_page value from the previous response. Leave it out to get the first page.
The next_page value from the previous response. Leave it out to get the first page.
Headers
anthropic-workspace-idThe 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.
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.
List models › Responses
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.
next_pageList workspaces
Lists the workspaces an API key can run in.
Each id is a value you can send as the anthropic-workspace-id 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.
The key must have the tasks:read capability. For what each capability allows, see Keys.
Note: Anthropic's Managed Agents API has no workspace listing, and the workspaces on its Admin API are the whole organization's, read with an admin key. This endpoint is a Context extension and answers a narrower question: the workspaces this key's owner may work in, read with the key itself. It is deliberately not on Anthropic's Admin API path, because the same path would otherwise answer a different question for a different caller.
Response
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.
| Field | Type | Description |
|---|---|---|
id | string | Send this as the anthropic-workspace-id header. |
name | string | The workspace's name, as the Context app shows it. |
type | string | Always workspace. |
An 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.
Errors
This endpoint can return these errors as well as the common errors.
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | limit is outside 1 to 100. Send a value from 1 to 100. |
| 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. |
query Parameters
limitThe maximum number of workspaces to return. Must be between 1 and 100.
The maximum number of workspaces to return. Must be between 1 and 100.
pageThe next_page value from the previous response. Leave it out to get the first page.
The next_page value from the previous response. Leave it out to get the first page.
Headers
anthropic-workspace-idThe 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.
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.
List workspaces › Responses
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.
next_page