Skip to content

Balance API

Emit — Record a Delta

Record a credit or debit delta for a customer. PacSpace queues the delta, verifies it independently, and sends a webhook when complete.

Use this endpoint to record a balance change (delta) for a customer account. Each delta represents a credit or debit that PacSpace queues, independently verifies, and confirms via webhook.


Endpoint

POST https://balance-api.pacspace.io/api/v1/balance/delta

Headers

HeaderRequiredDescription
X-Api-KeyYesYour PacSpace API key
Content-TypeYesMust be application/json

Request Body

ParameterTypeRequiredDescription
customerIdstringYesUnique identifier for the customer account
deltanumberYesAmount to adjust. Positive = credit, negative = debit
reasonstringYesHuman-readable reason for the adjustment (audit trail)
referenceIdstringNoYour internal reference ID for correlation
metadataobjectNoArbitrary key-value metadata to store with the delta

Examples

cURL

bash
curl -X POST https://balance-api.pacspace.io/api/v1/balance/delta \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "cust_12345",
    "delta": -1000,
    "reason": "Monthly subscription charge",
    "referenceId": "inv_98765",
    "metadata": {
      "invoiceId": "inv_98765",
      "plan": "growth"
    }
  }'

JavaScript (Node.js)

javascript
const response = await fetch(
  "https://balance-api.pacspace.io/api/v1/balance/delta",
  {
    method: "POST",
    headers: {
      "X-Api-Key": "YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      customerId: "cust_12345",
      delta: -1000,
      reason: "Monthly subscription charge",
      referenceId: "inv_98765",
      metadata: {
        invoiceId: "inv_98765",
        plan: "growth",
      },
    }),
  }
);

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

Python

python
import requests

response = requests.post(
    "https://balance-api.pacspace.io/api/v1/balance/delta",
    headers={
        "X-Api-Key": "YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "customerId": "cust_12345",
        "delta": -1000,
        "reason": "Monthly subscription charge",
        "referenceId": "inv_98765",
        "metadata": {
            "invoiceId": "inv_98765",
            "plan": "growth",
        },
    },
)

result = response.json()
print(result)

Response

json
{
  "success": true,
  "data": {
    "anchorId": "a_1234567890",
    "customerId": "cust_12345",
    "delta": -1000,
    "status": "QUEUED",
    "receiptId": "0xabc123...",
    "itemsRoot": "0xabc123...",
    "message": "Delta queued for verification"
  }
}

Response Fields

FieldTypeDescription
anchorIdstringUnique identifier for this delta record
customerIdstringThe customer account this delta belongs to
deltanumberThe recorded adjustment amount
statusstringCurrent processing status (starts as QUEUED)
receiptIdstringIdentifier for the verification receipt
itemsRootstringRoot hash of the data included in this batch
messagestringHuman-readable status message

Status Lifecycle

Every delta moves through three stages:

  1. QUEUED — The delta has been accepted and is waiting to be processed. This is the status returned immediately after a successful request.

  2. PROCESSING — PacSpace is actively verifying the delta. The system batches deltas for efficiency, so this stage may take a few seconds.

  3. VERIFIED — Verification is complete. The delta is now part of the customer's verified balance history and can be used in balance derivations.

Webhook Notification

When a delta reaches the VERIFIED status, PacSpace sends a delta.verified webhook to your configured endpoint. The webhook payload includes the full delta record with its final receiptId and itemsRoot, so you can update your own systems accordingly.

Tip: You don't need to poll for status. Configure a webhook endpoint in your PacSpace dashboard to receive real-time notifications when deltas are verified.

Was this page helpful?

Last updated February 11, 2026