---
title: "Heartbeat Session Stream"
method: POST
path: "/sessions/streams/heartbeat"
tags: ["Sessions", "Sessions"]
---

# Heartbeat Session Stream

`POST /sessions/streams/heartbeat`

## Request body

- SessionHeartbeatRequest
  - `session_id` string, required
  - `replica_id` string, required
  - `turn_id` string, nullable
  - `is_running` boolean

## Response `200`

Successful Response

- SessionHeartbeatResult — A heartbeat's outcome: the reconciled stream plus the session's actual owner replica. `replica_id` is the replica that currently holds the affinity key after the claim (this caller if it won or already held it, another replica otherwise). The runner reads it to refuse serving a local sandbox session it does not own. `stream` is None when a losing replica heartbeats a session that has no row yet: it may not create or stamp one, since that row belongs to the owner. `is_current_turn` (W7.4) is False when this turn_id's alive/running lock was gone or reassigned at the moment of this beat — i.e. a cancel/steer/kill interrupted this turn since the last heartbeat. The runner's watchdog reads this to abort the in-flight run; without it a cancel that raced a heartbeat's nx=True re-acquire would silently re-arm the SAME lock under the SAME turn_id and the interruption would never surface.
  - `stream` SessionStream
    - `created_at` string, date-time, nullable
    - `updated_at` string, date-time, nullable
    - `deleted_at` string, date-time, nullable
    - `created_by_id` string, uuid, nullable
    - `updated_by_id` string, uuid, nullable
    - `deleted_by_id` string, uuid, nullable
    - `name` string, nullable
    - `description` string, nullable
    - `id` string, uuid, nullable
    - `project_id` string, uuid, required
    - `session_id` string, required
    - `flags` SessionStreamFlags — The nest as primitive bools (alive ⊇ running ⊇ attached). resumable (alive & !running) and reattachable (running & !attached) are derived client-side, never stored.
      - `is_alive` boolean
      - `is_running` boolean
      - `is_attached` boolean
    - `tags` object, nullable
    - `meta` object, nullable
    - `turn_id` string, nullable
    - `archived_at` string, date-time, nullable
  - `replica_id` string, required
  - `is_current_turn` boolean

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/agenta-ai/apis/agenta-api.md) · [All operations](https://skmtc.net/agenta-ai/apis/agenta-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/agenta-ai/agenta-api/versions/ea6421d829f1/schema)
