Skip to main content

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 in packages/runtime/src/services/receipt-service.ts.
curl -X POST http://localhost:3000/receipt \
  -H "Content-Type: application/json" \
  -d '{ "businessTransactionId": "b6f1c8de-1a2b-4c3d-8e9f-0a1b2c3d4e5f" }'
ReceiptService.generate requires the trust record’s latest 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 for how that surfaces over HTTP.
Response 200 — the newly created Receipt, signed via ReceiptCrypto (packages/crypto). Response 400
{ "error": "businessTransactionId is required." }
or
{ "error": "businessTransactionId must be a valid UUID." }

Get the latest Receipt

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:
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.
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. Response 404
{ "error": "Execution Trust Record not found." }
or
{ "error": "Receipt not found." }

SDK equivalents

const receipt = await client.receipt(businessTransactionId);
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 and read .receipts.at(-1) yourself, or call GET /receipt/latest/:id directly over HTTP.

Receipt

The concept this endpoint produces.

Verification

The precondition Receipt generation enforces.

Trust Records

The fallback way to read a previously generated Receipt.

Receipt Verification Guide

A full verify → receipt walkthrough.