Work
api/beta/environments/work
Nearest release: v2.1.245, published an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
api/beta/environments/work Changed · +87 / -96 lines
### Path parameters ### Headers #### Response (200) ### Path parameters ### Query parameters ### Headers #### Response (200) ### Path parameters ### Headers #### Response (200) ### Path parameters ### Query parameters ### Headers #### Response (200) ### Path parameters ### Headers ### Body parameters #### Response (200) ### Path parameters ### Query parameters ### Headers #### Response (200) ### Path parameters ### Headers ### Body parameters #### Response (200) ### Path parameters ### Headers #### Response (200) ## Domain types ### Path Parameters ### Header Parameters #### Response ### Path Parameters ### Query Parameters ### Header Parameters #### Response ### Path Parameters ### Header Parameters #### Response ### Path Parameters ### Query Parameters ### Header Parameters #### Response ### Path Parameters ### Header Parameters ### Body Parameters #### Response ### Path Parameters ### Query Parameters ### Header Parameters #### Response ### Path Parameters ### Header Parameters ### Body Parameters #### Response ### Path Parameters ### Header Parameters #### Response ## Domain Types
---- -title: Work -url: https://platform.claude.com/docs/en/api/beta/environments/work ---- - # Work ## Get Work Item -**get** `/v1/environments/{environment_id}/work/{work_id}` +**GET** `/v1/environments/{environment_id}/work/{work_id}` Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. Retrieve detailed information about a specific work item. -### Path Parameters +### Path parameters - `environment_id: string` - `work_id: string` -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
### Returns -- `BetaSelfHostedWork object { id, acknowledged_at, created_at, 10 more }` +- `BetaSelfHostedWork object` Work resource representing a unit of work in a self-hosted environment.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work ### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID \ -H 'anthropic-version: 2023-06-01' \ -H 'anthropic-beta: managed-agents-2026-04-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" ``` -#### Response +#### Response (200) ```json {
## Poll for Work -**get** `/v1/environments/{environment_id}/work/poll` +**GET** `/v1/environments/{environment_id}/work/poll` Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. Long poll for work items in the queue. -### Path Parameters +### Path parameters - `environment_id: string` -### Query Parameters +### Query parameters - `block_ms: optional number` How long to wait for work to arrive before returning. Must be 1-999 in milliseconds. Defaults to non-blocking (returns immediately if no work is available). + minimum: 1 + - `reclaim_older_than_ms: optional number` Reclaim unacknowledged work items older than this many milliseconds. If omitted, uses the default (5000ms). -### Header Parameters + minimum: 1 +### Headers + - `"anthropic-beta": optional array of AnthropicBeta` Optional header to specify the beta version(s) you want to use.
### Returns -- `BetaSelfHostedWork object { id, acknowledged_at, created_at, 10 more }` +- `BetaSelfHostedWork object` Work resource representing a unit of work in a self-hosted environment.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work ### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/poll \ -H 'anthropic-version: 2023-06-01' \ -H 'anthropic-beta: managed-agents-2026-04-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" ``` -#### Response +#### Response (200) ```json {
## Acknowledge Work -**post** `/v1/environments/{environment_id}/work/{work_id}/ack` +**POST** `/v1/environments/{environment_id}/work/{work_id}/ack` Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. Acknowledge receipt of a work item, transitioning it from 'queued' to 'starting' and removing it from the queue. -### Path Parameters +### Path parameters - `environment_id: string` - `work_id: string` -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
### Returns -- `BetaSelfHostedWork object { id, acknowledged_at, created_at, 10 more }` +- `BetaSelfHostedWork object` Work resource representing a unit of work in a self-hosted environment.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work ### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID/ack \ -X POST \ -H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" ``` -#### Response +#### Response (200) ```json {
## Record Heartbeat -**post** `/v1/environments/{environment_id}/work/{work_id}/heartbeat` +**POST** `/v1/environments/{environment_id}/work/{work_id}/heartbeat` Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. Record a heartbeat for a work item to maintain the lease. -### Path Parameters +### Path parameters - `environment_id: string` - `work_id: string` -### Query Parameters +### Query parameters - `desired_ttl_seconds: optional number`
Expected last_heartbeat for conditional update (optimistic concurrency). Use literal 'NO_HEARTBEAT' to claim an unclaimed lease (first heartbeat). For subsequent heartbeats, echo the server's previous last_heartbeat value exactly. Returns 412 Precondition Failed if the actual value doesn't match. -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
### Returns -- `BetaSelfHostedWorkHeartbeatResponse object { last_heartbeat, lease_extended, state, 2 more }` +- `BetaSelfHostedWorkHeartbeatResponse object` Response after recording a heartbeat for a work item.
The type of response - - `"work_heartbeat"` + default: work_heartbeat ### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID/heartbeat \ -X POST \ -H 'anthropic-version: 2023-06-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" ``` -#### Response +#### Response (200) ```json {
## Stop Work -**post** `/v1/environments/{environment_id}/work/{work_id}/stop` +**POST** `/v1/environments/{environment_id}/work/{work_id}/stop` Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. Stop a work item, initiating graceful or forced shutdown. -### Path Parameters +### Path parameters - `environment_id: string` - `work_id: string` -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
- `"mid-conversation-tool-changes-2026-07-01"` -### Body Parameters +### Body parameters - `force: optional boolean` If true, immediately stop work without graceful shutdown + default: false + ### Returns -- `BetaSelfHostedWork object { id, acknowledged_at, created_at, 10 more }` +- `BetaSelfHostedWork object` Work resource representing a unit of work in a self-hosted environment.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work ### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID/stop \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \
-d '{}' ``` -#### Response +#### Response (200) ```json {
## List Work Items -**get** `/v1/environments/{environment_id}/work` +**GET** `/v1/environments/{environment_id}/work` Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. List work items in an environment. -### Path Parameters +### Path parameters - `environment_id: string` -### Query Parameters +### Query parameters - `limit: optional number` Maximum number of work items to return + default: 20, maximum: 1000, minimum: 1 + - `page: optional string` Opaque cursor from previous response for pagination -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
### Returns -- `BetaSelfHostedWorkListResponse object { data, next_page }` +- `BetaSelfHostedWorkListResponse object` Response when listing work items with cursor-based pagination.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work - `next_page: string or null`
### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work \ -H 'anthropic-version: 2023-06-01' \ -H 'anthropic-beta: managed-agents-2026-04-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" ``` -#### Response +#### Response (200) ```json {
## Update Work Item -**post** `/v1/environments/{environment_id}/work/{work_id}` +**POST** `/v1/environments/{environment_id}/work/{work_id}` Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly. Update work item metadata with merge semantics. -### Path Parameters +### Path parameters - `environment_id: string` - `work_id: string` -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
- `"mid-conversation-tool-changes-2026-07-01"` -### Body Parameters +### Body parameters - `metadata: map[string]`
### Returns -- `BetaSelfHostedWork object { id, acknowledged_at, created_at, 10 more }` +- `BetaSelfHostedWork object` Work resource representing a unit of work in a self-hosted environment.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work ### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID \ -H 'Content-Type: application/json' \ -H 'anthropic-version: 2023-06-01' \
}' ``` -#### Response +#### Response (200) ```json {
## Get Queue Statistics -**get** `/v1/environments/{environment_id}/work/stats` +**GET** `/v1/environments/{environment_id}/work/stats` Get statistics about the work queue for an environment. -### Path Parameters +### Path parameters - `environment_id: string` -### Header Parameters +### Headers - `"anthropic-beta": optional array of AnthropicBeta`
### Returns -- `BetaSelfHostedWorkQueueStats object { depth, oldest_queued_at, pending, 2 more }` +- `BetaSelfHostedWorkQueueStats object` Statistics about the work queue for an environment.
Number of work items being processed (polled but not acknowledged) + default: 0 + - `type: "work_queue_stats"` The type of object - - `"work_queue_stats"` + default: work_queue_stats - `workers_polling: number or null`
### Example -```http +```bash curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/stats \ -H 'anthropic-version: 2023-06-01' \ -H 'anthropic-beta: managed-agents-2026-04-01' \
-H "X-Api-Key: $ANTHROPIC_API_KEY" ``` -#### Response +#### Response (200) ```json {
} ``` -## Domain Types +## Domain types ### Beta Self Hosted Work -- `BetaSelfHostedWork object { id, acknowledged_at, created_at, 10 more }` +- `BetaSelfHostedWork object` Work resource representing a unit of work in a self-hosted environment.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work ### Beta Self Hosted Work Heartbeat Response -- `BetaSelfHostedWorkHeartbeatResponse object { last_heartbeat, lease_extended, state, 2 more }` +- `BetaSelfHostedWorkHeartbeatResponse object` Response after recording a heartbeat for a work item.
The type of response - - `"work_heartbeat"` + default: work_heartbeat ### Beta Self Hosted Work List Response -- `BetaSelfHostedWorkListResponse object { data, next_page }` +- `BetaSelfHostedWorkListResponse object` Response when listing work items with cursor-based pagination.
Type of work data - - `"session"` - - `environment_id: string` Environment identifier this work belongs to (e.g., `env_...`)
The type of object (always 'work') - - `"work"` + default: work - `next_page: string or null`
### Beta Self Hosted Work Queue Stats -- `BetaSelfHostedWorkQueueStats object { depth, oldest_queued_at, pending, 2 more }` +- `BetaSelfHostedWorkQueueStats object` Statistics about the work queue for an environment.
Number of work items being processed (polled but not acknowledged) + default: 0 + - `type: "work_queue_stats"` The type of object - - `"work_queue_stats"` + default: work_queue_stats - `workers_polling: number or null`
### Beta Self Hosted Work Stop Request -- `BetaSelfHostedWorkStopRequest object { force }` +- `BetaSelfHostedWorkStopRequest object` Request to stop a work item.
If true, immediately stop work without graceful shutdown + default: false + ### Beta Self Hosted Work Update Request -- `BetaSelfHostedWorkUpdateRequest object { metadata }` +- `BetaSelfHostedWorkUpdateRequest object` Request to update work item metadata.
### Beta Session Work Data -- `BetaSessionWorkData object { id, type }` +- `BetaSessionWorkData object` Work data for session work items.
- `type: "session"` Type of work data - - - `"session"`