Skip to content
Context docs
Context Agent API

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.

Pass env_default as environment_id when you create a session.

Anthropic compatibility

Anthropic's SDKs also have environments.create, update, delete and archive. Code written for Anthropic's API often creates an environment before its first session. This API handles those calls as follows:

  • POST /v1/environments (environments.create) creates nothing, so it has no page of its own here; the API reference the server serves lists it as Create an environment. It exists so that Anthropic SDK code runs unchanged. The key must have tasks:create. With no config, or a cloud config with unrestricted networking and no packages, it returns 200 with env_default. It ignores name, description and metadata. Any other config returns 400 invalid_request_error, as does any field this API doesn't accept, such as scope.
  • Updating, deleting or archiving an environment returns 404 not_found_error, because this API does not serve those paths.

The only environment is env_default. Remote sandbox support is on the roadmap.

Network access

Every environment reports networking.type as unrestricted, which is the only value the API accepts. unrestricted means the session's sandbox can reach the public internet, unless your deployment restricts it (see the note below). Model calls are separate. Context handles them, and the sandbox's network access doesn't govern them. Nothing you set through the API changes network access.

Note: Self-hosted (KOTS) deployments can restrict sandbox outbound traffic to a list of allowed domains. It's a setting in the KOTS Admin Console, not in the API. Your administrator turns on Sandbox Egress Proxy (domain allowlist) and lists the domains in Sandbox Egress Proxy Allowlist, or turns off Sandbox Internet Access. With Sandbox Workload Identity on, the same choice is Sandbox Egress Posture, set to Open internet, Domain allowlist or Workspace only. The API's networking label doesn't reflect this setting, so environments report unrestricted even when the install is tighter. To set it up, ask your Context contact.

A create with limited networking, packages or any other custom config returns 400:

JSONCode
{ "type": "error", "error": { "type": "invalid_request_error", "message": "This deployment serves one environment (cloud, unrestricted networking, no extra packages); a custom environment config is not supported" }, "request_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d" }

limited networking is on the Roadmap.

The environment object

FieldTypeDescription
idstringAlways env_default.
typestringAlways environment.
namestringAlways default.
descriptionstringA one-line description.
configobjectAn object whose type is cloud. It also holds networking, always unrestricted, and packages, always empty.
created_atstringWhen the environment was created, as an RFC 3339 timestamp.
updated_atstringWhen the environment last changed, as an RFC 3339 timestamp.

Some 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.

Example

JSONCode
{ "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" }

List environments

GET
https://api.context.ai
/v1/environments
x-api-key (header)

Lists the environments a session can run in, which is the default cloud environment (env_default).

A session can run only in an environment from this list. The API has no call to create environments.

The key must have the tasks:read capability. For what each capability allows, see Keys.

Response

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.

Errors

This endpoint can return these errors as well as the common errors.

Statuserror.typeCause and fix
400invalid_request_errorlimit is outside 1 to 100. Send a value from 1 to 100.
400invalid_request_errorpage is not a next_page value from this API. Send the next_page value from the previous response, unchanged.

List environments › query Parameters

limit
​integer · min: 1 · max: 100

The maximum number of environments to return per page. Must be between 1 and 100.

The maximum number of environments to return per page. Must be between 1 and 100.

Default: 20
page
​string

The 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_archived
​boolean

Has no effect, because environments are never archived.

Has no effect, because environments are never archived.

Default: false

List environments › Headers

anthropic-workspace-id
​string

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.

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 environments › Responses

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.

​array · required
next_page
​string | null · required

Get an environment

GET
https://api.context.ai
/v1/environments/{environment_id}
x-api-key (header)

Returns one environment, the default cloud environment (env_default).

To run a session in this environment, pass its id as environment_id when you create the session.

The key must have the tasks:read capability. For what each capability allows, see Keys.

Response

Returns 200 with the environment object. For every field, see Environments.

Errors

This endpoint can return these errors as well as the common errors.

Statuserror.typeCause and fix
404not_found_errorThe ID is not env_default. Use env_default.

Get an environment › path Parameters

environment_id
​string · required

The ID of the environment to retrieve: env_default.

The ID of the environment to retrieve: env_default.

Get an environment › Headers

anthropic-workspace-id
​string

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.

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 environment › Responses

Returns 200 with the environment object. For every field, see Environments.

anyOf
At least one variant must match. Multiple variants may match simultaneously.

Decision Table

VariantMatching Criteria
type = object · requires: id, archived_at, config +6 more
type = object · requires: id, archived_at, config +7 more
Properties for Variant 1:
id
​string · enum · required
Enum values:
env_default
archived_at
​null · required
​object · required
created_at
​string · date-time · required
description
​string · required
metadata
​object · required
name
​string · enum · required
Enum values:
default
type
​string · enum · required
Enum values:
environment
updated_at
​string · date-time · required