> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sovseal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GET /replay: Stream Replication Log for Crash Recovery

> Fetch replication log chunks chronologically from a given sequence number to catch up after a crash, device switch, or cold start.

<style>
  {`
      main, article, .prose {
        margin-left: 2.5cm !important;
        margin-right: 2.5cm !important;
      }
      `}
</style>

The `GET /replay` endpoint is your primary tool for state catch-up and crash recovery. When an agent restarts with a stale local state, you call this endpoint with the last sequence number it successfully processed — the server responds with all subsequent replication chunks in chronological order, up to a maximum of 1,000 rows. You apply those chunks locally to bring the agent back to the current confirmed head without re-downloading full snapshots.

## Request

```http theme={null}
GET /replay
Authorization: Bearer <TOKEN>
```

## Query Parameters

<ParamField query="since" type="integer" required>
  Retrieve all replication log entries with sequence numbers strictly greater than this value. Pass the last sequence number your agent successfully applied. Use `since=0` to replay from the very beginning.
</ParamField>

<Note>
  The `since` parameter is required. Omitting it returns a `400 missing_since_param` error. The response is capped at 1,000 chunks per call — if the gap is larger, paginate by using the highest `sequence_number` in the response as the next `since` value.
</Note>

## Response

### 200 OK

<ResponseField name="chunks" type="array">
  Ordered list of replication chunks with sequence numbers greater than `since`.
</ResponseField>

<ResponseField name="chunks[].sequence_number" type="integer">
  Monotonic sequence number of this chunk.
</ResponseField>

<ResponseField name="chunks[].block_hash" type="string">
  SHA-256 hash of the packed chunk block, for local integrity verification.
</ResponseField>

<ResponseField name="chunks[].ciphertext_b64" type="string">
  Base64-encoded ciphertext of the chunk in `IV || ciphertext` form.
</ResponseField>

<ResponseField name="chunks[].merkle_root" type="string">
  Merkle root recorded when this chunk was originally submitted.
</ResponseField>

<ResponseField name="chunks[].created_at" type="string">
  ISO-8601 timestamp of when this chunk was persisted.
</ResponseField>

<ResponseField name="count" type="integer">
  Total number of chunks returned in this response.
</ResponseField>

### Example Response

```json theme={null}
{
  "chunks": [
    {
      "sequence_number": 11,
      "block_hash": "f5a2b3c4d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3",
      "ciphertext_b64": "SGVsbG8gV29ybGQ=",
      "merkle_root": "84c8a8d11d95e0cce8da70c1a96c14b7454f738f65429384f9b4f3b7d1597f8c",
      "created_at": "2026-06-09T16:45:30.123Z"
    }
  ],
  "count": 1
}
```

## curl Example

```bash theme={null}
# Replay all chunks after sequence number 10
curl -G https://ksrlmubaxzwufziwarps.supabase.co/functions/v1/v2-agent-state/replay \
  -H "Authorization: Bearer sov_live_YOUR_KEY" \
  --data-urlencode "since=10"
```
