Claude Platform Docs

Work

Get Work Item
beta.environments.work.retrieve(strwork_id, WorkRetrieveParams**kwargs) -> BetaSelfHostedWork
GET/v1/environments/{environment_id}/work/{work_id}
Poll for Work
beta.environments.work.poll(strenvironment_id, WorkPollParams**kwargs) -> BetaSelfHostedWork
GET/v1/environments/{environment_id}/work/poll
Acknowledge Work
beta.environments.work.ack(strwork_id, WorkAckParams**kwargs) -> BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/ack
Record Heartbeat
beta.environments.work.heartbeat(strwork_id, WorkHeartbeatParams**kwargs) -> BetaSelfHostedWorkHeartbeatResponse
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat
Stop Work
beta.environments.work.stop(strwork_id, WorkStopParams**kwargs) -> BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/stop
List Work Items
beta.environments.work.list(strenvironment_id, WorkListParams**kwargs) -> SyncPageCursor[BetaSelfHostedWork]
GET/v1/environments/{environment_id}/work
Update Work Item
beta.environments.work.update(strwork_id, WorkUpdateParams**kwargs) -> BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}
Get Queue Statistics
beta.environments.work.stats(strenvironment_id, WorkStatsParams**kwargs) -> BetaSelfHostedWorkQueueStats
GET/v1/environments/{environment_id}/work/stats
Models
class 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.

class BetaSelfHostedWorkHeartbeatResponse:

Response after recording a heartbeat for a work item.

last_heartbeat: str

RFC 3339 timestamp of the actual heartbeat from DB

lease_extended: bool

Whether the heartbeat succeeded in extending the lease

state: Literal["queued", "starting", "active", 2 more]

Current state of the work item (active/stopping/stopped)

One of the following:
"queued"
"starting"
"active"
"stopping"
"stopped"
ttl_seconds: int

Effective TTL applied to the lease

type: Literal["work_heartbeat"]

The type of response

defaultwork_heartbeat
class BetaSelfHostedWorkListResponse:

Response when listing work items with cursor-based pagination.

class BetaSelfHostedWorkQueueStats:

Statistics about the work queue for an environment.

Uses Redis Stream consumer group metrics for O(1) queries.

depth: int

Number of work items waiting to be picked up (lag from consumer group)

oldest_queued_at: Optional[str]

RFC 3339 timestamp of oldest item in the work stream (includes both queued and pending items), null if stream empty

pending: int

Number of work items being processed (polled but not acknowledged)

default0
type: Literal["work_queue_stats"]

The type of object

defaultwork_queue_stats
workers_polling: Optional[int]

Number of workers that have polled for work in the last 30 seconds. Requires worker_id to be sent with poll requests.

class BetaSelfHostedWorkStopRequest:

Request to stop a work item.

force: Optional[bool]

If true, immediately stop work without graceful shutdown

defaultfalse
class BetaSelfHostedWorkUpdateRequest:

Request to update work item metadata.

metadata: Dict[str, Optional[str]]

Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve existing metadata.

class BetaSessionWorkData:

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: str

Session identifier (e.g., 'session_...')

type: Literal["session"]

Type of work data