Claude Platform Docs

Work

Get Work Item
client.Beta.Environments.Work.Get(ctx, workID, params) (*BetaSelfHostedWork, error)
GET/v1/environments/{environment_id}/work/{work_id}
Poll for Work
client.Beta.Environments.Work.Poll(ctx, environmentID, params) (*BetaSelfHostedWork, error)
GET/v1/environments/{environment_id}/work/poll
Acknowledge Work
client.Beta.Environments.Work.Ack(ctx, workID, params) (*BetaSelfHostedWork, error)
POST/v1/environments/{environment_id}/work/{work_id}/ack
Record Heartbeat
client.Beta.Environments.Work.Heartbeat(ctx, workID, params) (*BetaSelfHostedWorkHeartbeatResponse, error)
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat
Stop Work
client.Beta.Environments.Work.Stop(ctx, workID, params) (*BetaSelfHostedWork, error)
POST/v1/environments/{environment_id}/work/{work_id}/stop
List Work Items
client.Beta.Environments.Work.List(ctx, environmentID, params) (*PageCursor[BetaSelfHostedWork], error)
GET/v1/environments/{environment_id}/work
Update Work Item
client.Beta.Environments.Work.Update(ctx, workID, params) (*BetaSelfHostedWork, error)
POST/v1/environments/{environment_id}/work/{work_id}
Get Queue Statistics
client.Beta.Environments.Work.Stats(ctx, environmentID, query) (*BetaSelfHostedWorkQueueStats, error)
GET/v1/environments/{environment_id}/work/stats
Models
type BetaSelfHostedWork struct{…}

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.

type BetaSelfHostedWorkHeartbeatResponse struct{…}

Response after recording a heartbeat for a work item.

LastHeartbeat string

RFC 3339 timestamp of the actual heartbeat from DB

LeaseExtended bool

Whether the heartbeat succeeded in extending the lease

State BetaSelfHostedWorkHeartbeatResponseState

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

One of the following:
const BetaSelfHostedWorkHeartbeatResponseStateQueued BetaSelfHostedWorkHeartbeatResponseState = "queued"
const BetaSelfHostedWorkHeartbeatResponseStateStarting BetaSelfHostedWorkHeartbeatResponseState = "starting"
const BetaSelfHostedWorkHeartbeatResponseStateActive BetaSelfHostedWorkHeartbeatResponseState = "active"
const BetaSelfHostedWorkHeartbeatResponseStateStopping BetaSelfHostedWorkHeartbeatResponseState = "stopping"
const BetaSelfHostedWorkHeartbeatResponseStateStopped BetaSelfHostedWorkHeartbeatResponseState = "stopped"
TTLSeconds int64

Effective TTL applied to the lease

Type WorkHeartbeat

The type of response

defaultwork_heartbeat
type BetaSelfHostedWorkListResponse struct{…}

Response when listing work items with cursor-based pagination.

type BetaSelfHostedWorkQueueStats struct{…}

Statistics about the work queue for an environment.

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

Depth int64

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

OldestQueuedAt string

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

Pending int64

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

default0
Type WorkQueueStats

The type of object

defaultwork_queue_stats
WorkersPolling int64

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

type BetaSelfHostedWorkStopRequest struct{…}

Request to stop a work item.

Force bool Optional

If true, immediately stop work without graceful shutdown

defaultfalse
type BetaSelfHostedWorkUpdateRequest struct{…}

Request to update work item metadata.

Metadata map[string, string]

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

type BetaSessionWorkData struct{…}

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