Claude Platform Docs

记录心跳

$ ant beta:environments:work heartbeat
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

为工作项记录心跳以维持租约。

Parameters
--environment-id: string

Path param

--work-id: string

Path param

--desired-ttl-seconds: optional number

Query param: Desired TTL in seconds

--expected-last-heartbeat: optional string

Query param: 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.

--beta: optional array of AnthropicBeta

Header param: Optional header to specify the beta version(s) you want to use.

Returns
beta_self_hosted_work_heartbeat_response: object{ last_heartbeat, lease_extended, state, 2 more }

Response after recording a heartbeat for a work item.

last_heartbeat: string

RFC 3339 timestamp of the actual heartbeat from DB

lease_extended: boolean

Whether the heartbeat succeeded in extending the lease

state: "queued" or "starting" or "active" or 2 more

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

One of the following:
"queued"
"starting"
"active"
"stopping"
"stopped"
ttl_seconds: number

Effective TTL applied to the lease

type: "work_heartbeat"

The type of response

记录心跳
ant beta:environments:work heartbeat \
  --api-key my-anthropic-api-key \
  --environment-id env_011CZkZ9X2dpNyB7HsEFoRfW \
  --work-id work_id
Returns Examples
Response 200
{
  "last_heartbeat": "last_heartbeat",
  "lease_extended": true,
  "state": "queued",
  "ttl_seconds": 0,
  "type": "work_heartbeat"
}