---
title: "Renew an external-machine driver lease"
method: POST
path: "/v1/machines/{machine_id}/heartbeat"
tags: ["machines"]
---

# Renew an external-machine driver lease

`POST /v1/machines/{machine_id}/heartbeat`

DEVICE TOKEN ONLY. Refreshes connection_status and last_seen_at using the current fencing_token and returns authoritative last_sequence/last_frame_id recovery state. A restarted driver can long-poll once to learn the current fence, heartbeat, then submit sequence=last_sequence+1. A revoked machine or stale lease generation is rejected; heartbeats never revive an old device token.

## Request body

- ExternalMachineHeartbeatRequest
  - `protocol_version` '1'
  - `fencing_token` integer, required

## Response `200`

Lease renewed.

- ExternalMachineHeartbeatResponse
  - `machine_id` string, required
  - `connection_status` 'connected', required
  - `last_seen_at` string, date-time, required
  - `fencing_token` integer, required
  - `last_sequence` integer, required — Authoritative last accepted observation sequence. A restarted driver submits last_sequence + 1.
  - `last_frame_id` string, uuid, nullable, required — Authoritative last accepted frame, or null before the first observation.
  - `request_id` string, required

## Other responses

- `400` — Invalid request body or parameters.
- `401` — Missing, malformed, revoked, or machine-mismatched external device token. Pass the one-time machine token as `Authorization: Bearer <device_token>`; owner API keys are not accepted on device-plane routes. Revoked tokens may return DEVICE_REVOKED.
- `403` — API key lacks the required scope or tier-feature is unavailable on the caller's plan.
- `404` — Resource not found in this key's namespace.
- `409` — The resource state conflicts with this operation.
- `413` — The request body exceeds the endpoint limit.
- `422` — The JSON shape is valid but one or more values violate the endpoint contract.
- `429` — Rate or concurrency limit exceeded.
- `500` — Unexpected server error. Retry with exponential backoff.
- `502` — An upstream dependency returned an invalid response.
- `503` — A required service is temporarily unavailable.
- `504` — An upstream dependency timed out.

---

[API](https://skmtc.net/coasty/apis/coasty-public-api.md) · [All operations](https://skmtc.net/coasty/apis/coasty-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/coasty/coasty-public-api/revisions/f50d93b0d8a1/schema)
