Claude Platform Docs

Work

Get Work Item
client.beta.environments.work.retrieve(stringworkID, WorkRetrieveParamsparams, RequestOptionsoptions?): BetaSelfHostedWork
GET/v1/environments/{environment_id}/work/{work_id}
Poll for Work
client.beta.environments.work.poll(stringenvironmentID, WorkPollParamsparams?, RequestOptionsoptions?): BetaSelfHostedWork | null
GET/v1/environments/{environment_id}/work/poll
Acknowledge Work
client.beta.environments.work.ack(stringworkID, WorkAckParamsparams, RequestOptionsoptions?): BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/ack
Record Heartbeat
client.beta.environments.work.heartbeat(stringworkID, WorkHeartbeatParamsparams, RequestOptionsoptions?): BetaSelfHostedWorkHeartbeatResponse
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat
Stop Work
client.beta.environments.work.stop(stringworkID, WorkStopParamsparams, RequestOptionsoptions?): BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/stop
List Work Items
client.beta.environments.work.list(stringenvironmentID, WorkListParamsparams?, RequestOptionsoptions?): PageCursor<BetaSelfHostedWork>
GET/v1/environments/{environment_id}/work
Update Work Item
client.beta.environments.work.update(stringworkID, WorkUpdateParamsparams, RequestOptionsoptions?): BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}
Get Queue Statistics
client.beta.environments.work.stats(stringenvironmentID, WorkStatsParamsparams?, RequestOptionsoptions?): BetaSelfHostedWorkQueueStats
GET/v1/environments/{environment_id}/work/stats
Models
BetaSelfHostedWork { id, acknowledged_at, created_at, 10 more }

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.

BetaSelfHostedWorkHeartbeatResponse { last_heartbeat, lease_extended, state, 2 more }

Response after recording a heartbeat for a work item.

last_heartbeat: string

RFC 3339 timestamp of the actual heartbeat from DB

lease_extended: boolean

Whether the heartbeat succeeded in extending the lease

state: "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: number

Effective TTL applied to the lease

type: "work_heartbeat"

The type of response

defaultwork_heartbeat
BetaSelfHostedWorkListResponse { data, next_page }

Response when listing work items with cursor-based pagination.

BetaSelfHostedWorkQueueStats { depth, oldest_queued_at, pending, 2 more }

Statistics about the work queue for an environment.

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

depth: number

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

oldest_queued_at: string | null

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

pending: number

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

default0
type: "work_queue_stats"

The type of object

defaultwork_queue_stats
workers_polling: number | null

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

BetaSelfHostedWorkStopRequest { force }

Request to stop a work item.

force?: boolean

If true, immediately stop work without graceful shutdown

defaultfalse
BetaSelfHostedWorkUpdateRequest { metadata }

Request to update work item metadata.

metadata: Record<string, string | null>

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

BetaSessionWorkData { id, type }

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

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

type: "session"

Type of work data