---
title: "Poll for Work"
method: GET
path: "/v1/environments/{environment_id}/work/poll?beta=true"
---

# Poll for Work

`GET /v1/environments/{environment_id}/work/poll?beta=true`

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

- `environment_id` string, required

## Query parameters

- `block_ms` integer, nullable — 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).
- `reclaim_older_than_ms` integer, nullable — Reclaim unacknowledged work items older than this many milliseconds. If omitted, uses the default (5000ms).

## Headers

- `anthropic-beta` string — Optional header to specify the beta version(s) you want to use. To use multiple betas, use a comma separated list like `beta1,beta2` or specify the header multiple times for each beta.
- `anthropic-version` string — The version of the Claude API you want to use. Read more about versioning and our version history [here](https://platform.claude.com/docs/en/api/versioning).
- `Anthropic-Worker-ID` string, nullable — Unique identifier for the specific worker polling, used to track aggregated environment-level work metrics in Console
- `authorization` string, nullable

## Response `200`

Successful Response

- BetaSelfHostedWork — Work resource representing a unit of work in a self-hosted environment. Work items are queued when sessions are created or when long-dormant sessions receive new messages. The environment worker polls for work to execute in a self-hosted sandbox.
  - `acknowledged_at` string, nullable, required — RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox
  - `created_at` string, required — RFC 3339 timestamp when work was created
  - `data` BetaSessionWorkData, required — Work data for session work items. This resource type is used when work represents a session that needs to be executed in a self-hosted environment.
    - `id` string, required — Session identifier (e.g., 'session_...')
    - `type` 'session', required — Type of work data
  - `environment_id` string, required — Environment identifier this work belongs to (e.g., `env_...`)
  - `id` string, required — Work identifier (e.g., 'work_...')
  - `latest_heartbeat_at` string, nullable, required — RFC 3339 timestamp of the most recent heartbeat
  - `metadata` object, required — User-provided metadata key-value pairs associated with this work item
  - `secret` string, nullable, required — Credential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.
  - `started_at` string, nullable, required — RFC 3339 timestamp when work execution started
  - `state` 'queued' | 'starting' | 'active' | 'stopping' | 'stopped', required — Current state of the work item
  - `stop_requested_at` string, nullable, required — RFC 3339 timestamp when stop was requested
  - `stopped_at` string, nullable, required — RFC 3339 timestamp when work execution stopped
  - `type` 'work', required — The type of object (always 'work')

## Other responses

- `400` — Invalid argument - The client specified an invalid argument
- `401` — Unauthenticated - The request does not have valid authentication credentials
- `403` — Permission denied - The caller does not have permission to execute the specified operation
- `404` — Not found - Some requested entity was not found
- `408` — Deadline exceeded - The deadline expired before the operation could complete
- `409` — Aborted - The operation was aborted due to concurrency issue
- `412` — Failed precondition - Operation was rejected because the system is not in required state
- `413` — Out of range - Operation was attempted past the valid range
- `429` — Resource exhausted - Some resource has been exhausted (rate limiting)
- `431` — Request header fields too large - Request metadata was too large
- `499` — Cancelled - The operation was cancelled by the client
- `500` — Internal - Internal server error
- `501` — Unimplemented - The operation is not implemented or supported
- `503` — Unavailable - The service is currently unavailable
- `504` — Deadline exceeded - Upstream service did not respond in time
- `529` — Overloaded - The service is temporarily overloaded

## Changes

- **2026-09-02** `4789294140a2` — 16 info
  - added the non-success response with the status `400`
  - added the non-success response with the status `401`
  - added the non-success response with the status `403`
  - added the non-success response with the status `404`
  - …12 more
- **2026-07-22** `5e4a8830793b` — 1 info
  - added the required property `anyOf[subschema #1: SelfHostedWork]/secret` to the response with the `200` status
- **2026-07-01** `9c991bee394d` — 1 breaking
  - removed the required property `anyOf[subschema #1: SelfHostedWork]/secret` from the response with the `200` status
- **2026-06-30** `26335fd8487a` — 1 info
  - added the required property `anyOf[subschema #1: SelfHostedWork]/secret` to the response with the `200` status
- **2026-05-19** `40e330aba8bc` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/anthropics/apis/anthropic-api/changes/v1/environments/:environment_id/work/poll?beta=true/get.md)

---

[API](https://skmtc.dev/anthropics/apis/anthropic-api.md) · [All operations](https://skmtc.dev/anthropics/apis/anthropic-api/llms.txt) · [OpenAPI document](https://skmtc.dev/anthropics/apis/anthropic-api/revisions/1bb7c7a0a4a9?raw)
