The whole hunk
from line 16, old and new numbered
/
lines
from line 16
1616
1717<CodeGroup defaultLanguage="CLI">
1818 ```bash cURL
19 environment=$(curl -fsS https://api.anthropic.com/v1/environments \
19 curl -fsS https://api.anthropic.com/v1/environments \
2020 -H "x-api-key: $ANTHROPIC_API_KEY" \
2121 -H "anthropic-version: 2023-06-01" \
2222 -H "anthropic-beta: managed-agents-2026-04-01" \
from line 30
3030 }
3131 }
3232 EOF
33 )
34 environment_id=$(jq -r '.id' <<< "$environment")
35
36 echo "Environment ID: $environment_id"
3733 ```
3834
3935 <MultiFileExample language="cli" label="CLI">
from line 140
144140
145141Pass the environment ID as a string when [creating a session](https://platform.claude.com/docs/en/managed-agents/sessions).
146142
147<CodeGroup defaultLanguage="CLI">
143<CodeGroup>
148144 ```bash cURL
149 session=$(curl -fsS https://api.anthropic.com/v1/sessions \
145 curl -fsS https://api.anthropic.com/v1/sessions \
150146 -H "x-api-key: $ANTHROPIC_API_KEY" \
151147 -H "anthropic-version: 2023-06-01" \
152148 -H "anthropic-beta: managed-agents-2026-04-01" \
from line 149
153149 -H "content-type: application/json" \
154150 --data @- <<EOF
155151 {
156 "agent": "$agent_id",
157 "environment_id": "$environment_id"
152 "agent": "$AGENT_ID",
153 "environment_id": "$ENVIRONMENT_ID"
158154 }
159155 EOF
160 )
161156 ```
162157
163158 ```bash CLI
from line 223
228223
229224<CodeGroup defaultLanguage="CLI">
230225 ```bash cURL
231 environment=$(curl -fsS https://api.anthropic.com/v1/environments \
226 curl -fsS https://api.anthropic.com/v1/environments \
232227 -H "x-api-key: $ANTHROPIC_API_KEY" \
233228 -H "anthropic-version: 2023-06-01" \
234229 -H "anthropic-beta: managed-agents-2026-04-01" \
from line 241
246241 }
247242 }
248243 EOF
249 )
250244 ```
251245
252246 <MultiFileExample language="cli" label="CLI">
from line 575
581575
582576## Manage environments
583577
584<CodeGroup defaultLanguage="CLI">
578<CodeGroup>
585579 ```bash cURL
586580 # List environments
587 environments=$(curl -fsS https://api.anthropic.com/v1/environments \
581 curl -fsS https://api.anthropic.com/v1/environments \
588582 -H "x-api-key: $ANTHROPIC_API_KEY" \
589583 -H "anthropic-version: 2023-06-01" \
590 -H "anthropic-beta: managed-agents-2026-04-01")
584 -H "anthropic-beta: managed-agents-2026-04-01"
591585
592586 # Retrieve a specific environment
593 env=$(curl -fsS "https://api.anthropic.com/v1/environments/$environment_id" \
587 curl -fsS "https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID" \
594588 -H "x-api-key: $ANTHROPIC_API_KEY" \
595589 -H "anthropic-version: 2023-06-01" \
596 -H "anthropic-beta: managed-agents-2026-04-01")
590 -H "anthropic-beta: managed-agents-2026-04-01"
597591
598592 # Archive an environment (read-only, existing sessions continue)
599 curl -fsS -X POST "https://api.anthropic.com/v1/environments/$environment_id/archive" \
593 curl -fsS -X POST "https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/archive" \
600594 -H "x-api-key: $ANTHROPIC_API_KEY" \
601595 -H "anthropic-version: 2023-06-01" \
602596 -H "anthropic-beta: managed-agents-2026-04-01"
603597
604598 # Delete an environment (only if no sessions reference it)
605 curl -fsS -X DELETE "https://api.anthropic.com/v1/environments/$environment_id" \
599 curl -fsS -X DELETE "https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID" \
606600 -H "x-api-key: $ANTHROPIC_API_KEY" \
607601 -H "anthropic-version: 2023-06-01" \
608602 -H "anthropic-beta: managed-agents-2026-04-01"