Skip to content

Receipt — Generate a Receipt

Generate a human-readable receipt of all verified deltas for a customer.

Use this endpoint to generate a complete, human-readable receipt of all verified deltas for a customer. Receipts are useful for invoicing, audits, and sharing a tamper-evident transaction history.


Endpoint

GET https://balance-api.pacspace.io/api/v1/balance/receipt/:customerId

Headers

HeaderRequiredDescription
X-Api-KeyYesYour PacSpace API key

Path Parameters

ParameterTypeRequiredDescription
customerIdstringYesUnique identifier for the customer account

Example

SDK (TypeScript)

typescript
import { PacSpace } from '@pacspace-io/sdk';

const pac = new PacSpace({ apiKey: process.env.PACSPACE_API_KEY });

const receipt = await pac.balance.receipt('cust_12345');
console.log(receipt.finalBalance);
console.log(receipt.deltasCount);
console.log(receipt.verification.itemHashes);

cURL

bash
curl -X GET "https://balance-api.pacspace.io/api/v1/balance/receipt/cust_12345" \
  -H "X-Api-Key: YOUR_API_KEY"

JavaScript (Node.js)

javascript
const response = await fetch(
  "https://balance-api.pacspace.io/api/v1/balance/receipt/cust_12345",
  {
    headers: {
      "X-Api-Key": "YOUR_API_KEY",
    },
  }
);

const result = await response.json();
console.log(result);

Python

python
import requests

response = requests.get(
    "https://balance-api.pacspace.io/api/v1/balance/receipt/cust_12345",
    headers={"X-Api-Key": "YOUR_API_KEY"},
)

result = response.json()
print(result)

Response

json
{
  "success": true,
  "data": {
    "customerId": "cust_12345",
    "generatedAt": "2026-02-11T12:00:00Z",
    "deltasCount": 127,
    "finalBalance": 48500,
    "itemsRoot": "0xabc789...",
    "receiptId": "0xabc789...",
    "latestCheckpoint": "0xabc789...",
    "deltas": [
      {
        "anchorId": "a_1234567890",
        "itemHash": "0x2d4e7f1a...",
        "itemsRoot": "0x8f3a9b2c...",
        "receiptId": "0x8f3a9b2c...",
        "delta": -1000,
        "reason": "Monthly subscription charge",
        "referenceId": "inv_98765",
        "window": "2026-02",
        "declaredTimestamp": "2026-02-10T14:30:00Z",
        "blockTimestamp": "2026-02-10T14:30:12Z",
        "dataPurged": false,
        "verified": true
      }
    ],
    "windowSummaries": [
      {
        "window": "2026-01",
        "deltasCount": 42,
        "netDelta": 1500,
        "firstBlockTimestamp": "2026-01-03T10:15:00Z",
        "lastBlockTimestamp": "2026-01-31T22:45:00Z"
      }
    ],
    "verification": {
      "message": "Receipt generated from verified deltas.",
      "itemHashes": [
        "0x2d4e7f1a...",
        "0x9f1a3c5e..."
      ]
    }
  }
}

Response Fields

FieldTypeDescription
customerIdstringThe customer account the receipt was generated for
generatedAtstringISO 8601 timestamp of when the receipt was created
deltasCountnumberTotal number of verified deltas included in the receipt
finalBalancenumberThe computed balance after all verified deltas
itemsRootstringProof root covering all deltas in the receipt
receiptIdstringUnique receipt identifier (same as itemsRoot)
latestCheckpointstring | nullLatest checkpoint included in the receipt
deltasarrayComplete list of verified delta records
windowSummariesarrayAggregated summaries grouped by time window
verificationobjectProof that the receipt data has not been tampered with

Delta Object

FieldTypeDescription
anchorIdstringUnique identifier for this delta
itemHashstringContent hash of this individual delta
itemsRootstringProof root covering this delta
receiptIdstringReceipt identifier (same as itemsRoot)
deltanumberThe adjustment amount
reasonstringHuman-readable reason for the adjustment
referenceIdstringYour internal reference ID, or null if not provided
windowstringTime window label (e.g., 2026-02)
declaredTimestampstringISO 8601 timestamp you declared when submitting
blockTimestampstringISO 8601 timestamp of when verification completed
dataPurgedbooleanWhether the raw business data has been purged per retention policy
verifiedbooleanWhether the delta has been verified

Window Summary Object

FieldTypeDescription
windowstringTime window label (e.g., 2026-01)
deltasCountnumberNumber of deltas in the window
netDeltanumberNet balance change for the window
firstBlockTimestampstringISO 8601 timestamp of the first delta in the window
lastBlockTimestampstringISO 8601 timestamp of the last delta in the window

Verification Object

FieldTypeDescription
messagestringHuman-readable description of the verification
itemHashesstring[]Content hashes of all individual deltas in the receipt

Use Cases

  • Invoicing — Attach a receipt to customer invoices as a verified record of all charges and credits in a period.
  • Audits — Provide auditors with a complete, tamper-evident history of balance changes.
  • Dispute resolution — Share a receipt with a counterparty to establish a common set of facts when balances disagree.
  • Record keeping — Archive receipts for compliance or internal bookkeeping purposes.

Tip: Combine receipts with the Checkpoint endpoint to generate period-specific receipts that align with your periods.