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

# Replay

> POST /replay — and a significant gap between this route and the replay package

## Replay a Business Transaction

```
POST /replay
```

Implemented in `packages/api/src/routes/replay.ts`. Validates only that `businessTransactionId` is present (unlike `execute`/`verify`/`receipt`, this route does **not** check it's a well-formed UUID), then calls `application.replay(businessTransactionId)`.

```bash theme={null}
curl -X POST http://localhost:3000/replay \
  -H "Content-Type: application/json" \
  -d '{ "businessTransactionId": "b6f1c8de-1a2b-4c3d-8e9f-0a1b2c3d4e5f" }'
```

**Response `200`**

```ts theme={null}
interface ReplayResult {
  businessTransactionId: string;
  trustRecordHash: string;
  verified: boolean;
}
```

**Response `400`**

```json theme={null}
{ "error": "businessTransactionId is required." }
```

<Warning>
  **What `POST /replay` actually does is not what the `replay` package does.** `ExecutionTrustApplication.replay` (`packages/runtime/src/ExecutionTrustApplication.ts`) is:

  ```ts theme={null}
  async replay(businessTransactionId: string) {
    const trustRecord = await this.trustRecords.findByTransactionId(businessTransactionId);
    if (!trustRecord) throw new Error("Execution Trust Record not found.");
    const verified = await this.crypto.verify(trustRecord);
    return { businessTransactionId, trustRecordHash: trustRecord.trustRecordHash, verified };
  }
  ```

  This calls `VerificationCrypto.verify` from `@parmana/crypto` — the exact same hash-integrity check used by [`POST /verify`](/docs/api/verify). It never imports or calls anything from the [`replay`](/docs/packages/replay) package.

  The `replay` package's `ReplayEngine.replay()` (`packages/replay/src/ReplayEngine.ts`) is a real, separately-implemented engine that re-evaluates the recorded [Policy](/docs/concepts/policy) against the recorded signals via `PolicyEngine.evaluate`, builds a `replayedDecision`, and compares it against the `recordedDecision` to produce a richer result:

  ```ts theme={null}
  interface ReplayEngineResult {
    recordedDecision: Decision;
    replayedDecision: Decision;
    matches: boolean;
    replayedAt: Date;
  }
  ```

  That engine — along with `ReplayBuilder`, `ReplayVerifier`, `ReplayPipeline`, `ReplayExecutor`, and `ReplayPlan` — is exported from `packages/replay/src/index.ts` but is not wired into `packages/api` at all. There is no HTTP route that exercises deterministic decision replay today; `POST /replay` only re-verifies the trust record's hash, which is functionally redundant with `POST /verify`.
</Warning>

<Note>
  [Concepts → Replay](/docs/concepts/replay) documents the `ReplayResult` shape that `POST /replay` actually returns (`{ businessTransactionId, trustRecordHash, verified }`), so the concept and this route are consistent with each other. The gap is specifically between both of those and the unused `replay` package engine described above.
</Note>

## SDK equivalents

<CodeGroup>
  ```ts TypeScript theme={null}
  const replay = await client.replay(businessTransactionId);
  ```

  ```python Python theme={null}
  replay = client.replay.replay(business_transaction_id)
  ```
</CodeGroup>

Both SDKs' `replay()` call `POST /replay` and type their return as `ReplayResult` matching the flat `{ businessTransactionId, trustRecordHash, verified }` shape above — they mirror the route as implemented, not the `replay` package's richer decision-comparison result.

## Related

<CardGroup cols={2}>
  <Card title="Replay (concept)" href="/docs/concepts/replay">What replay is meant to guarantee.</Card>
  <Card title="replay package" href="/docs/packages/replay">The unused deterministic decision-replay engine.</Card>
  <Card title="Verify" href="/docs/api/verify">The endpoint this route's logic actually duplicates.</Card>
  <Card title="Deterministic Replay Guide" href="/docs/guides/deterministic-replay">Working with replay today, and what it doesn't yet check.</Card>
</CardGroup>
