SPB Git

Repository Public

create.md 10.0 KB 450 lines markdown

1---2title: Create Environment3url: https://platform.claude.com/docs/en/api/beta/environments/create4---56# Create Environment78**POST** `/v1/environments`910Create a new environment with the specified configuration.1112## Headers1314- `"anthropic-beta": optional array of AnthropicBeta`1516  Optional header to specify the beta version(s) you want to use.1718  - `string`1920  - `"message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 43 more`2122    - `"message-batches-2024-09-24"`2324    - `"prompt-caching-2024-07-31"`2526    - `"computer-use-2024-10-22"`2728    - `"computer-use-2025-01-24"`2930    - `"pdfs-2024-09-25"`3132    - `"token-counting-2024-11-01"`3334    - `"token-efficient-tools-2025-02-19"`3536    - `"output-128k-2025-02-19"`3738    - `"files-api-2025-04-14"`3940    - `"mcp-client-2025-04-04"`4142    - `"mcp-client-2025-11-20"`4344    - `"dev-full-thinking-2025-05-14"`4546    - `"interleaved-thinking-2025-05-14"`4748    - `"code-execution-2025-05-22"`4950    - `"extended-cache-ttl-2025-04-11"`5152    - `"context-1m-2025-08-07"`5354    - `"context-management-2025-06-27"`5556    - `"model-context-window-exceeded-2025-08-26"`5758    - `"skills-2025-10-02"`5960    - `"fast-mode-2026-02-01"`6162    - `"output-300k-2026-03-24"`6364    - `"user-profiles-2026-03-24"`6566    - `"user-profiles-2026-08-18"`6768    - `"user-profiles-2026-09-04"`6970    - `"advisor-tool-2026-03-01"`7172    - `"managed-agents-2026-04-01"`7374    - `"cache-diagnosis-2026-04-07"`7576    - `"dreaming-2026-04-21"`7778    - `"thinking-token-count-2026-05-13"`7980    - `"server-side-fallback-2026-06-01"`8182    - `"server-side-fallback-2026-07-01"`8384    - `"fallback-credit-2026-06-01"`8586    - `"fallback-credit-2026-07-01"`8788    - `"agent-memory-2026-07-22"`8990    - `"mid-conversation-tool-changes-2026-07-01"`9192    - `"compact-2026-01-12"`9394    - `"computer-use-2025-11-24"`9596    - `"mcp-tunnels-2026-06-22"`9798    - `"structured-outputs-2025-11-13"`99100    - `"task-budgets-2026-03-13"`101102    - `"thinking-display-updates-2026-08-18"`103104    - `"ce-user-management-2026-07-13"`105106    - `"mid-conversation-output-config-2026-07-01"`107108    - `"thinking-binding-controls-2026-08-01"`109110    - `"mid-conversation-system-clear-at-2026-08-21"`111112    - `"compact-2026-09-04"`113114- `"anthropic-workspace-id": optional string`115116## Body parameters117118- `name: string`119120  Human-readable name for the environment121122  maxLength: 256, minLength: 1123124- `config: optional BetaCloudConfigParams or BetaSelfHostedConfigParams or null`125126  Environment configuration127128  - `BetaCloudConfigParams object`129130    Request params for `cloud` environment configuration.131132    Fields default to null; on update, omitted fields preserve the133    existing value.134135    - `type: "cloud"`136137      Environment type138139    - `networking: optional BetaUnrestrictedNetwork or BetaLimitedNetworkParams or null`140141      Network configuration policy. Omit on update to preserve the existing value.142143      - `BetaUnrestrictedNetwork object`144145        Unrestricted network access.146147        - `type: "unrestricted"`148149          Network policy type150151      - `BetaLimitedNetworkParams object`152153        Limited network request params.154155        Fields default to null; on update, omitted fields preserve the156        existing value.157158        - `type: "limited"`159160          Network policy type161162        - `allow_mcp_servers: optional boolean or null`163164          Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array. Defaults to `false`.165166        - `allow_package_managers: optional boolean or null`167168          Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array. Defaults to `false` on creation. Must be `true` when `packages` are specified.169170        - `allowed_hosts: optional array of string or null`171172          Specifies domains the container can reach.173174    - `packages: optional BetaPackagesParams or null`175176      Specify packages (and optionally their versions) available in this environment.177178      When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest.179180      Under `limited` networking, requires `networking.allow_package_managers` to be `true`.181182      - `type: optional "packages"`183184        Package configuration type185186        default: packages187188      - `apt: optional array of string or null`189190        Ubuntu/Debian packages to install191192      - `cargo: optional array of string or null`193194        Rust packages to install195196      - `gem: optional array of string or null`197198        Ruby packages to install199200      - `go: optional array of string or null`201202        Go packages to install203204      - `npm: optional array of string or null`205206        Node.js packages to install207208      - `pip: optional array of string or null`209210        Python packages to install211212  - `BetaSelfHostedConfigParams object`213214    Request params for `self_hosted` environment configuration.215216    - `type: "self_hosted"`217218      Environment type219220- `description: optional string or null`221222  Optional description of the environment223224  maxLength: 1024225226- `metadata: optional map[string]`227228  User-provided metadata key-value pairs229230- `scope: optional "organization" or "account" or null`231232  The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only. API organizations support only 'organization'; 'account' is rejected. If not specified, defaults based on organization type.233234  - `"organization"`235236  - `"account"`237238## Returns239240- `BetaEnvironment object`241242  Unified Environment resource for both cloud and self-hosted environments.243244  - `type: "environment"`245246    The type of object (always 'environment')247248    default: environment249250  - `id: string`251252    Environment identifier (e.g., 'env_...')253254  - `archived_at: string or null`255256    RFC 3339 timestamp when environment was archived, or null if not archived257258  - `config: BetaCloudConfig or BetaSelfHostedConfig`259260    Environment configuration (either Anthropic Cloud or self-hosted)261262    - `BetaCloudConfig object`263264      `cloud` environment configuration.265266      - `type: "cloud"`267268        Environment type269270      - `networking: BetaUnrestrictedNetwork or BetaLimitedNetwork`271272        Network configuration policy.273274        - `BetaUnrestrictedNetwork object`275276          Unrestricted network access.277278          - `type: "unrestricted"`279280            Network policy type281282        - `BetaLimitedNetwork object`283284          Limited network access.285286          - `type: "limited"`287288            Network policy type289290          - `allow_mcp_servers: boolean`291292            Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.293294          - `allow_package_managers: boolean`295296            Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.297298          - `allowed_hosts: array of string`299300            Specifies domains the container can reach.301302      - `packages: BetaPackages`303304        Package manager configuration.305306        - `type: optional "packages"`307308          Package configuration type309310          default: packages311312        - `apt: array of string`313314          Ubuntu/Debian packages to install315316        - `cargo: array of string`317318          Rust packages to install319320        - `gem: array of string`321322          Ruby packages to install323324        - `go: array of string`325326          Go packages to install327328        - `npm: array of string`329330          Node.js packages to install331332        - `pip: array of string`333334          Python packages to install335336    - `BetaSelfHostedConfig object`337338      Configuration for self-hosted environments.339340      - `type: "self_hosted"`341342        Environment type343344  - `created_at: string`345346    RFC 3339 timestamp when environment was created347348  - `description: string or null`349350    User-provided description for the environment; null when unset351352  - `metadata: map[string]`353354    User-provided metadata key-value pairs355356  - `name: string`357358    Human-readable name for the environment359360  - `updated_at: string`361362    RFC 3339 timestamp when environment was last updated363364  - `scope: optional "organization" or "account"`365366    The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.367368    - `"organization"`369370    - `"account"`371372## Example373374```bash375curl https://api.anthropic.com/v1/environments \376    -H 'Content-Type: application/json' \377    -H 'anthropic-version: 2023-06-01' \378    -H 'anthropic-beta: managed-agents-2026-04-01' \379    -H "X-Api-Key: $ANTHROPIC_API_KEY" \380    -d '{381          "name": "python-data-analysis",382          "config": {383            "type": "cloud",384            "networking": {385              "type": "limited",386              "allow_package_managers": true,387              "allowed_hosts": [388                "api.example.com"389              ]390            },391            "packages": {392              "pip": [393                "pandas",394                "numpy"395              ]396            }397          },398          "description": "Python environment with data-analysis packages."399        }'400```401402### Response (200)403404```json405{406  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",407  "archived_at": null,408  "config": {409    "networking": {410      "allow_mcp_servers": false,411      "allow_package_managers": true,412      "allowed_hosts": [413        "api.example.com"414      ],415      "type": "limited"416    },417    "packages": {418      "apt": [419        "string"420      ],421      "cargo": [422        "string"423      ],424      "gem": [425        "string"426      ],427      "go": [428        "string"429      ],430      "npm": [431        "string"432      ],433      "pip": [434        "pandas",435        "numpy"436      ],437      "type": "packages"438    },439    "type": "cloud"440  },441  "created_at": "2026-03-15T10:00:00Z",442  "description": "Python environment with data-analysis packages.",443  "metadata": {},444  "name": "python-data-analysis",445  "type": "environment",446  "updated_at": "2026-03-15T10:00:00Z",447  "scope": "organization"448}449```450
Files main
Menu

Theme