Claude Platform Docs

Work

Get Work Item
BetaSelfHostedWork beta().environments().work().retrieve(WorkRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
GET/v1/environments/{environment_id}/work/{work_id}
Poll for Work
BetaSelfHostedWork beta().environments().work().poll(WorkPollParamsparams = WorkPollParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/v1/environments/{environment_id}/work/poll
Acknowledge Work
BetaSelfHostedWork beta().environments().work().ack(WorkAckParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}/ack
Record Heartbeat
BetaSelfHostedWorkHeartbeatResponse beta().environments().work().heartbeat(WorkHeartbeatParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat
Stop Work
BetaSelfHostedWork beta().environments().work().stop(WorkStopParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}/stop
List Work Items
WorkListPage beta().environments().work().list(WorkListParamsparams = WorkListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/v1/environments/{environment_id}/work
Update Work Item
BetaSelfHostedWork beta().environments().work().update(WorkUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}
Get Queue Statistics
BetaSelfHostedWorkQueueStats beta().environments().work().stats(WorkStatsParamsparams = WorkStatsParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
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.

String lastHeartbeat

RFC 3339 timestamp of the actual heartbeat from DB

boolean leaseExtended

Whether the heartbeat succeeded in extending the lease

State state

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

One of the following:
QUEUED("queued")
STARTING("starting")
ACTIVE("active")
STOPPING("stopping")
STOPPED("stopped")
long ttlSeconds

Effective TTL applied to the lease

JsonValue type "work_heartbeat"constant

The type of response

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.

long depth

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

Optional<String> oldestQueuedAt

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

long pending

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

JsonValue type "work_queue_stats"constant

The type of object

Optional<Long> workersPolling

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.

Optional<Boolean> force

If true, immediately stop work without graceful shutdown

class BetaSelfHostedWorkUpdateRequest:

Request to update work item metadata.

Metadata metadata

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.

String id

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

JsonValue type "session"constant

Type of work data