from line 1
1---
2title: Record Heartbeat
3url: https://platform.claude.com/docs/en/api/beta/environments/work/heartbeat
4---
1# Record Heartbeat
52
6## Record Heartbeat
3**POST** `/v1/environments/{environment_id}/work/{work_id}/heartbeat`
74
8**post** `/v1/environments/{environment_id}/work/{work_id}/heartbeat`
9
105Note: 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.
116
127Record a heartbeat for a work item to maintain the lease.
138
14### Path Parameters
9## Path parameters
1510
1611- `environment_id: string`
1712
1813- `work_id: string`
1914
20### Query Parameters
15## Query parameters
2116
2217- `desired_ttl_seconds: optional number`
2318
from line 22
2722
2823 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.
2924
30### Header Parameters
25## Headers
3126
3227- `"anthropic-beta": optional array of AnthropicBeta`
3328
from line 100
105100
106101 - `"mid-conversation-tool-changes-2026-07-01"`
107102
108### Returns
103## Returns
109104
110- `BetaSelfHostedWorkHeartbeatResponse object { last_heartbeat, lease_extended, state, 2 more }`
105- `BetaSelfHostedWorkHeartbeatResponse object`
111106
112107 Response after recording a heartbeat for a work item.
113108
from line 136
141136
142137 The type of response
143138
144 - `"work_heartbeat"`
139 default: work_heartbeat
145140
146### Example
141## Example
147142
148```http
143```bash
149144curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID/heartbeat \
150145 -X POST \
151146 -H 'anthropic-version: 2023-06-01' \
from line 148
153148 -H "X-Api-Key: $ANTHROPIC_API_KEY"
154149```
155150
156#### Response
151### Response (200)
157152
158153```json
159154{
No line in this hunk matches that.