하트비트 기록
참고: 이러한 엔드포인트는 자체 호스팅 샌드박스 환경과의 세션을 오케스트레이션하기 위해 SDK 및 CLI에서 제공되는 사전 빌드된 환경 워커에 의해 자동으로 호출됩니다. 참조용으로 여기에 포함되어 있으며, 직접 호출할 필요는 없습니다.
리스를 유지하기 위해 작업 항목에 대한 하트비트를 기록합니다.
Parameters
params BetaEnvironmentWorkHeartbeatParams
Desired TTL in seconds
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. The server does not compare the value when the work item is 'stopping' or 'stopped'.
Betas []AnthropicBeta OptionalHeader parameterOptional header to specify the beta version(s) you want to use.
Optional header to specify the beta version(s) you want to use.
const AnthropicBetaMessageBatches2024_09_24 AnthropicBeta = "message-batches-2024-09-24"Deprecated
const AnthropicBetaPromptCaching2024_07_31 AnthropicBeta = "prompt-caching-2024-07-31"Deprecated
const AnthropicBetaPDFs2024_09_25 AnthropicBeta = "pdfs-2024-09-25"Deprecated
const AnthropicBetaTokenCounting2024_11_01 AnthropicBeta = "token-counting-2024-11-01"Deprecated
const AnthropicBetaTokenEfficientTools2025_02_19 AnthropicBeta = "token-efficient-tools-2025-02-19"Deprecated
const AnthropicBetaFilesAPI2025_04_14 AnthropicBeta = "files-api-2025-04-14"Deprecated
const AnthropicBetaExtendedCacheTTL2025_04_11 AnthropicBeta = "extended-cache-ttl-2025-04-11"Deprecated
const AnthropicBetaSkills2025_10_02 AnthropicBeta = "skills-2025-10-02"Deprecated
const AnthropicBetaCacheDiagnosis2026_04_07 AnthropicBeta = "cache-diagnosis-2026-04-07"Deprecated
const AnthropicBetaCEUserManagement2026_07_13 AnthropicBeta = "ce-user-management-2026-07-13"Deprecated
Returns
type BetaSelfHostedWorkHeartbeatResponse struct { Type: "work_heartbeat"; LastHeartbeat; LeaseExtended; /* 2 more */ }Response after recording a heartbeat for a work item.
Response after recording a heartbeat for a work item.
Type WorkHeartbeatThe type of response
The type of response
RFC 3339 timestamp of the most recent heartbeat recorded for this work item, or an empty string if none has been recorded
Whether the heartbeat succeeded in extending the lease
State BetaSelfHostedWorkHeartbeatResponseStateCurrent state of the work item (active/stopping/stopped)
Current state of the work item (active/stopping/stopped)
Effective TTL applied to the lease
Errors
Any method can also return the general HTTP errors.
expected_last_heartbeat does not match the stored heartbeat, so another worker may hold the lease.
package main
import (
"context"
"fmt"
"github.com/anthropics/anthropic-sdk-go/v2"
"github.com/anthropics/anthropic-sdk-go/v2/option"
)
func main() {
client := anthropic.NewClient(
option.WithAPIKey("my-anthropic-api-key"),
)
betaSelfHostedWorkHeartbeatResponse, err := client.Beta.Environments.Work.Heartbeat(
context.TODO(),
"work_id",
anthropic.BetaEnvironmentWorkHeartbeatParams{
EnvironmentID: "env_011CZkZ9X2dpNyB7HsEFoRfW",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", betaSelfHostedWorkHeartbeatResponse.LastHeartbeat)
}{
"last_heartbeat": "last_heartbeat",
"lease_extended": true,
"state": "queued",
"ttl_seconds": 0,
"type": "work_heartbeat"
}Returns Examples
{
"last_heartbeat": "last_heartbeat",
"lease_extended": true,
"state": "queued",
"ttl_seconds": 0,
"type": "work_heartbeat"
}