Claude Platform Docs

Travail

Obtenir un élément de travail
BetaSelfHostedWork beta().environments().work().retrieve(params, requestOptions = RequestOptions.none())
GET/v1/environments/{environment_id}/work/{work_id}

Récupérer des informations détaillées sur un élément de travail spécifique.

Interroger pour obtenir du travail
BetaSelfHostedWork beta().environments().work().poll(params = WorkPollParams.none(), requestOptions = RequestOptions.none())
GET/v1/environments/{environment_id}/work/poll

Remarque : ces points de terminaison sont appelés automatiquement par le worker d'environnement préconstruit fourni dans les SDK et la CLI, afin d'orchestrer les sessions avec des environnements sandbox auto-hébergés. Ils sont inclus ici à titre de référence ; vous n'avez pas besoin de les invoquer directement.

Accuser réception d'un travail
BetaSelfHostedWork beta().environments().work().ack(params, requestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}/ack

Remarque : ces points de terminaison sont appelés automatiquement par le worker d'environnement préconstruit fourni dans les SDK et la CLI, afin d'orchestrer les sessions avec des environnements sandbox auto-hébergés. Ils sont inclus ici à titre de référence ; vous n'avez pas besoin de les invoquer directement.

Enregistrer un signal de présence
BetaSelfHostedWorkHeartbeatResponse beta().environments().work().heartbeat(params, requestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat

Remarque : ces points de terminaison sont appelés automatiquement par le worker d'environnement préconstruit fourni dans les SDK et la CLI, afin d'orchestrer les sessions avec des environnements sandbox auto-hébergés. Ils sont inclus ici à titre de référence ; vous n'avez pas besoin de les invoquer directement.

Arrêter un travail
BetaSelfHostedWork beta().environments().work().stop(params, requestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}/stop

Arrêter un élément de travail, en lançant un arrêt progressif ou forcé.

Lister les éléments de travail
WorkListPage beta().environments().work().list(params = WorkListParams.none(), requestOptions = RequestOptions.none())
GET/v1/environments/{environment_id}/work

Lister les éléments de travail d'un environnement.

Mettre à jour un élément de travail
BetaSelfHostedWork beta().environments().work().update(params, requestOptions = RequestOptions.none())
POST/v1/environments/{environment_id}/work/{work_id}

Mettre à jour les métadonnées d'un élément de travail avec une sémantique de fusion.

Obtenir les statistiques de la file d'attente
BetaSelfHostedWorkQueueStats beta().environments().work().stats(params = WorkStatsParams.none(), requestOptions = RequestOptions.none())
GET/v1/environments/{environment_id}/work/stats

Obtenir des statistiques sur la file d'attente de travail d'un environnement.

Models
class BetaHeartbeatPreconditionFailedErrorDetails { currentState; errorCode; }
BetaWorkLeaseState currentState

The lease as the server holds it.

Optional<String> lastHeartbeat

RFC 3339 timestamp of the stored heartbeat, or null if there has been none

boolean leaseExtended

Always false: a refused heartbeat does not extend the lease

State state

Current state of the work item

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

TTL of the lease

JsonValue errorCode = "heartbeat_precondition_failed"
class BetaSelfHostedWork { type = "work"; id; acknowledgedAt; /* 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.

class BetaSelfHostedWorkHeartbeatResponse { type = "work_heartbeat"; lastHeartbeat; leaseExtended; /* 2 more */ }

Response after recording a heartbeat for a work item.

JsonValue type = "work_heartbeat"

The type of response

String lastHeartbeat

RFC 3339 timestamp of the most recent heartbeat recorded for this work item, or an empty string if none has been recorded

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

class BetaSelfHostedWorkListResponse { data; nextPage; }

Response when listing work items with cursor-based pagination.

class BetaSelfHostedWorkQueueStats { type = "work_queue_stats"; depth; oldestQueuedAt; /* 2 more */ }

Statistics about the work queue for an environment.

JsonValue type = "work_queue_stats"

The type of object

long depth

Number of work items waiting to be picked up

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)

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 { force; }

Request to stop a work item.

Optional<Boolean> force

If true, immediately stop work without graceful shutdown

class BetaSelfHostedWorkUpdateRequest { metadata; }

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 { type = "session"; id; }

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.

JsonValue type = "session"

Type of work data

String id

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

class BetaWorkLeaseState { lastHeartbeat; leaseExtended; state; ttlSeconds; }

A work item's lease as the server holds it.

Optional<String> lastHeartbeat

RFC 3339 timestamp of the stored heartbeat, or null if there has been none

boolean leaseExtended

Always false: a refused heartbeat does not extend the lease

State state

Current state of the work item

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

TTL of the lease

Errors
class BetaHeartbeatPreconditionFailedException extends PreconditionFailedException { details; }⁠HTTP status 412

expected_last_heartbeat does not match the stored heartbeat, so another worker may hold the lease.

BetaWorkLeaseState currentState

The lease as the server holds it.

Optional<String> lastHeartbeat

RFC 3339 timestamp of the stored heartbeat, or null if there has been none

boolean leaseExtended

Always false: a refused heartbeat does not extend the lease

State state

Current state of the work item

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

TTL of the lease

JsonValue errorCode = "heartbeat_precondition_failed"