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
| Header | Required | Description |
|---|---|---|
X-Api-Key | Yes | Your PacSpace API key |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
customerId | string | Yes | Unique 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
| Field | Type | Description |
|---|---|---|
customerId | string | The customer account the receipt was generated for |
generatedAt | string | ISO 8601 timestamp of when the receipt was created |
deltasCount | number | Total number of verified deltas included in the receipt |
finalBalance | number | The computed balance after all verified deltas |
itemsRoot | string | Proof root covering all deltas in the receipt |
receiptId | string | Unique receipt identifier (same as itemsRoot) |
latestCheckpoint | string | null | Latest checkpoint included in the receipt |
deltas | array | Complete list of verified delta records |
windowSummaries | array | Aggregated summaries grouped by time window |
verification | object | Proof that the receipt data has not been tampered with |
Delta Object
| Field | Type | Description |
|---|---|---|
anchorId | string | Unique identifier for this delta |
itemHash | string | Content hash of this individual delta |
itemsRoot | string | Proof root covering this delta |
receiptId | string | Receipt identifier (same as itemsRoot) |
delta | number | The adjustment amount |
reason | string | Human-readable reason for the adjustment |
referenceId | string | Your internal reference ID, or null if not provided |
window | string | Time window label (e.g., 2026-02) |
declaredTimestamp | string | ISO 8601 timestamp you declared when submitting |
blockTimestamp | string | ISO 8601 timestamp of when verification completed |
dataPurged | boolean | Whether the raw business data has been purged per retention policy |
verified | boolean | Whether the delta has been verified |
Window Summary Object
| Field | Type | Description |
|---|---|---|
window | string | Time window label (e.g., 2026-01) |
deltasCount | number | Number of deltas in the window |
netDelta | number | Net balance change for the window |
firstBlockTimestamp | string | ISO 8601 timestamp of the first delta in the window |
lastBlockTimestamp | string | ISO 8601 timestamp of the last delta in the window |
Verification Object
| Field | Type | Description |
|---|---|---|
message | string | Human-readable description of the verification |
itemHashes | string[] | 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.