Skip to content

Querying Ledgers

List all customer ledgers, get individual ledger details, and inspect recent activity.

Use these endpoints to list all customer ledgers for your account, get detail for a specific customer, and paginate through recent activity.


List Customer Ledgers

GET https://balance-api.pacspace.io/api/v1/balance/customers

Headers

HeaderRequiredDescription
X-Api-KeyYesYour PacSpace API key

Query Parameters

ParameterTypeRequiredDefaultDescription
pagenumberNo1Page number (1-indexed)
limitnumberNo25Results per page (1-100)
searchstringNoFilter by customer ID (case-insensitive)

Response

json
{
  "success": true,
  "data": {
    "customers": [
      {
        "customerId": "cust_001",
        "ledgerIdentifier": "0xA1b2C3d4E5f6789012345678901234567890Ef34",
        "totalDeltas": 42,
        "firstDeltaAt": "2026-01-15T10:30:00.000Z",
        "lastDeltaAt": "2026-02-14T14:22:00.000Z"
      },
      {
        "customerId": "cust_002",
        "ledgerIdentifier": "0xC3d4E5f67890123456789012345678901234Abcd",
        "totalDeltas": 128,
        "firstDeltaAt": "2026-01-20T08:15:00.000Z",
        "lastDeltaAt": "2026-02-14T16:45:00.000Z"
      }
    ],
    "pagination": {
      "total": 47,
      "page": 1,
      "limit": 25,
      "totalPages": 2
    }
  }
}

Examples

List all customers:

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

Search by customer ID:

bash
curl "https://balance-api.pacspace.io/api/v1/balance/customers?search=partner_" \
  -H "X-Api-Key: YOUR_API_KEY"

SDK:

typescript
const { customers, pagination } = await pac.balance.customers({
  search: 'partner_',
  limit: 10,
});

Get Customer Ledger Detail

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

Headers

HeaderRequiredDescription
X-Api-KeyYesYour PacSpace API key

Path Parameters

ParameterTypeRequiredDescription
customerIdstringYesThe customer ID to look up

Query Parameters

ParameterTypeRequiredDefaultDescription
deltaPagenumberNo1Page of recent activity
deltaLimitnumberNo20Activity items per page

Response

json
{
  "success": true,
  "data": {
    "customerId": "cust_001",
    "ledgerIdentifier": "0xA1b2C3d4E5f6789012345678901234567890Ef34",
    "ledgerSlot": "1234567890",
    "totalDeltas": 42,
    "computedBalance": 4500.00,
    "firstDeltaAt": "2026-01-15T10:30:00.000Z",
    "lastDeltaAt": "2026-02-14T14:22:00.000Z",
    "latestCheckpoint": "chk_abc123",
    "privacyNote": "PacSpace stores only the derived ledger identifier for this customer. Store the mapping between this ID and your internal records in your own system.",
    "recentActivity": {
      "items": [
        {
          "amount": 100.00,
          "reason": "deposit",
          "referenceId": "txn_01",
          "status": "verified",
          "time": "2026-02-14T14:22:00.000Z"
        },
        {
          "amount": -30.00,
          "reason": "usage_charge",
          "referenceId": "txn_02",
          "status": "verified",
          "time": "2026-02-13T11:00:00.000Z"
        }
      ],
      "pagination": {
        "total": 42,
        "page": 1,
        "limit": 20,
        "totalPages": 3
      }
    }
  }
}

Response Fields

FieldTypeDescription
customerIdstringThe customer ID you passed
ledgerIdentifierstringDeterministic derived identifier for this customer
ledgerSlotstringThe derived slot used for verification
totalDeltasnumberTotal number of deltas recorded
computedBalancenumberSum of all delta amounts
firstDeltaAtstring | nullWhen the first delta was recorded
lastDeltaAtstring | nullWhen the most recent delta was recorded
latestCheckpointstring | nullMost recent checkpoint receipt ID
privacyNotestringReminder about the privacy boundary
recentActivityobjectPaginated list of recent deltas

Activity Item Fields

FieldTypeDescription
amountnumberThe delta amount (positive or negative)
reasonstring | nullThe reason provided when the delta was emitted
referenceIdstring | nullYour reference ID for the transaction
statusstring"verified" or "pending"
timestringWhen the delta was recorded

Examples

Get customer detail:

bash
curl https://balance-api.pacspace.io/api/v1/balance/customers/cust_001 \
  -H "X-Api-Key: YOUR_API_KEY"

SDK:

typescript
const ledger = await pac.balance.customer('cust_001');

console.log(ledger.ledgerIdentifier); // 0xA1b2...Ef34
console.log(ledger.computedBalance);  // 4500.00
console.log(ledger.totalDeltas);      // 42

Error Responses

StatusCodeDescription
404CUSTOMER_NOT_FOUNDNo ledger exists for this customer ID
429RATE_LIMIT_EXCEEDEDToo many requests (limit: 200/minute)
500LIST_CUSTOMERS_FAILEDInternal error listing customer ledgers
500GET_CUSTOMER_FAILEDInternal error fetching customer detail

Cross-Tenant Isolation

Customer ledgers are scoped to your tenant. You cannot see another tenant's customers, and they cannot see yours. This is enforced at the API key level -- your API key determines which tenant's data you can access.