SPB Git

Repository Public

heartbeat.md 4.0 KB 191 lines markdown

1---2title: Record Heartbeat3url: https://platform.claude.com/docs/en/api/beta/environments/work/heartbeat4---56# Record Heartbeat78**POST** `/v1/environments/{environment_id}/work/{work_id}/heartbeat`910Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.1112Record a heartbeat for a work item to maintain the lease.1314## Path parameters1516- `environment_id: string`1718- `work_id: string`1920## Query parameters2122- `desired_ttl_seconds: optional number`2324  Desired TTL in seconds2526- `expected_last_heartbeat: optional string`2728  Expected last_heartbeat for conditional update (optimistic concurrency). Use literal 'NO_HEARTBEAT' to claim an unclaimed lease (first heartbeat). For subsequent heartbeats, echo the server's previous last_heartbeat value exactly. Returns 412 Precondition Failed if the actual value doesn't match.2930## Headers3132- `"anthropic-beta": optional array of AnthropicBeta`3334  Optional header to specify the beta version(s) you want to use.3536  - `string`3738  - `"message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 43 more`3940    - `"message-batches-2024-09-24"`4142    - `"prompt-caching-2024-07-31"`4344    - `"computer-use-2024-10-22"`4546    - `"computer-use-2025-01-24"`4748    - `"pdfs-2024-09-25"`4950    - `"token-counting-2024-11-01"`5152    - `"token-efficient-tools-2025-02-19"`5354    - `"output-128k-2025-02-19"`5556    - `"files-api-2025-04-14"`5758    - `"mcp-client-2025-04-04"`5960    - `"mcp-client-2025-11-20"`6162    - `"dev-full-thinking-2025-05-14"`6364    - `"interleaved-thinking-2025-05-14"`6566    - `"code-execution-2025-05-22"`6768    - `"extended-cache-ttl-2025-04-11"`6970    - `"context-1m-2025-08-07"`7172    - `"context-management-2025-06-27"`7374    - `"model-context-window-exceeded-2025-08-26"`7576    - `"skills-2025-10-02"`7778    - `"fast-mode-2026-02-01"`7980    - `"output-300k-2026-03-24"`8182    - `"user-profiles-2026-03-24"`8384    - `"user-profiles-2026-08-18"`8586    - `"user-profiles-2026-09-04"`8788    - `"advisor-tool-2026-03-01"`8990    - `"managed-agents-2026-04-01"`9192    - `"cache-diagnosis-2026-04-07"`9394    - `"dreaming-2026-04-21"`9596    - `"thinking-token-count-2026-05-13"`9798    - `"server-side-fallback-2026-06-01"`99100    - `"server-side-fallback-2026-07-01"`101102    - `"fallback-credit-2026-06-01"`103104    - `"fallback-credit-2026-07-01"`105106    - `"agent-memory-2026-07-22"`107108    - `"mid-conversation-tool-changes-2026-07-01"`109110    - `"compact-2026-01-12"`111112    - `"computer-use-2025-11-24"`113114    - `"mcp-tunnels-2026-06-22"`115116    - `"structured-outputs-2025-11-13"`117118    - `"task-budgets-2026-03-13"`119120    - `"thinking-display-updates-2026-08-18"`121122    - `"ce-user-management-2026-07-13"`123124    - `"mid-conversation-output-config-2026-07-01"`125126    - `"thinking-binding-controls-2026-08-01"`127128    - `"mid-conversation-system-clear-at-2026-08-21"`129130    - `"compact-2026-09-04"`131132## Returns133134- `BetaSelfHostedWorkHeartbeatResponse object`135136  Response after recording a heartbeat for a work item.137138  - `type: "work_heartbeat"`139140    The type of response141142    default: work_heartbeat143144  - `last_heartbeat: string`145146    RFC 3339 timestamp of the actual heartbeat from DB147148  - `lease_extended: boolean`149150    Whether the heartbeat succeeded in extending the lease151152  - `state: "queued" or "starting" or "active" or 2 more`153154    Current state of the work item (active/stopping/stopped)155156    - `"queued"`157158    - `"starting"`159160    - `"active"`161162    - `"stopping"`163164    - `"stopped"`165166  - `ttl_seconds: number`167168    Effective TTL applied to the lease169170## Example171172```bash173curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID/heartbeat \174    -X POST \175    -H 'anthropic-version: 2023-06-01' \176    -H 'anthropic-beta: managed-agents-2026-04-01' \177    -H "X-Api-Key: $ANTHROPIC_API_KEY"178```179180### Response (200)181182```json183{184  "last_heartbeat": "last_heartbeat",185  "lease_extended": true,186  "state": "queued",187  "ttl_seconds": 0,188  "type": "work_heartbeat"189}190```191
Files main
Menu

Theme