> ## 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.

# Receipt

> POST /receipt and GET /receipt/latest/:id

## Generate a Receipt

```
POST /receipt
```

Implemented in `packages/api/src/routes/receipt.ts`. Validates `businessTransactionId` (required, UUID format), then calls `application.generateReceipt(businessTransactionId)` — [`ReceiptService.generate`](/docs/packages/crypto) in `packages/runtime/src/services/receipt-service.ts`.

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

<Note>
  `ReceiptService.generate` requires the trust record's latest [`Verification`](/docs/concepts/verification) to have `status: VERIFIED` — if it hasn't been verified yet, or the last verification failed, it throws `ReceiptGenerationError` rather than generating a Receipt. See [Error Model](/docs/api/error-model) for how that surfaces over HTTP.
</Note>

**Response `200`** — the newly created [`Receipt`](/docs/concepts/receipt), signed via `ReceiptCrypto` (`packages/crypto`).

**Response `400`**

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

or

```json theme={null}
{ "error": "businessTransactionId must be a valid UUID." }
```

## Get the latest Receipt

<Warning>
  **This is not `GET /receipt/:id`.** `packages/api/src/app.ts` mounts `receipt.ts` (POST-only) at `/receipt`, and separately mounts `receipt-get.ts` (`router.get("/:id", ...)`) at `/receipt/latest`:

  ```ts theme={null}
  app.use("/receipt", receiptRoutes);               // POST / only
  app.use("/receipt/latest", receiptLatestRoutes);  // GET /:id
  ```

  The real, working endpoint is:

  ```
  GET /receipt/latest/:id
  ```

  Confirmed by `packages/api/test/receipt-get-api.test.ts`, whose test description and requests are literally `GET /receipt/latest/:id`.
</Warning>

```bash theme={null}
curl http://localhost:3000/receipt/latest/b6f1c8de-1a2b-4c3d-8e9f-0a1b2c3d4e5f
```

`receipt-get.ts` loads the trust record via `application.getTrustRecord(id)` and returns `record.receipts.at(-1)` — the most recently appended Receipt.

**Response `200`** — the latest [`Receipt`](/docs/concepts/receipt).

**Response `404`**

```json theme={null}
{ "error": "Execution Trust Record not found." }
```

or

```json theme={null}
{ "error": "Receipt not found." }
```

## SDK equivalents

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

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

<Warning>
  Neither SDK exposes a method for `GET /receipt/latest/:id`. TypeScript's `ReceiptApi` (`typescript/src/client/ReceiptApi.ts`) only implements `generate()`, which calls `POST /receipt` — its own doc comment is explicit that this API "does NOT ... verify trust records" and lists no read/get method. If you need to re-fetch a previously generated Receipt without regenerating one, you currently have to go through [`GET /trust-records/:id`](/docs/api/trust-records) and read `.receipts.at(-1)` yourself, or call `GET /receipt/latest/:id` directly over HTTP.
</Warning>

## Related

<CardGroup cols={2}>
  <Card title="Receipt" href="/docs/concepts/receipt">The concept this endpoint produces.</Card>
  <Card title="Verification" href="/docs/concepts/verification">The precondition Receipt generation enforces.</Card>
  <Card title="Trust Records" href="/docs/api/trust-records">The fallback way to read a previously generated Receipt.</Card>
  <Card title="Receipt Verification Guide" href="/docs/guides/receipt-verification">A full verify → receipt walkthrough.</Card>
</CardGroup>
