Skip to content

Advanced API

Write Operations

Submit write operations to record data in PacSpace's verification layer.

Write operations let you submit data to PacSpace for verification. Each write records one or more items — key-value pairs with optional metadata — that are batched and verified automatically.

Requires an API key in the X-Api-Key header:

bash
-H "X-Api-Key: pk_live_PUBLIC.SECRET"

Base URL: https://balance-api.pacspace.io


Submit a Write

Send one or more data items to be recorded and verified.

bash
curl -X POST https://balance-api.pacspace.io/api/v1/writes \
  -H "X-Api-Key: pk_live_PUBLIC.SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {
        "key": "order-12345",
        "accountId": "customer-001",
        "bits": 1,
        "metadata": {
          "amount": 250.00,
          "currency": "USD",
          "description": "Monthly subscription"
        }
      },
      {
        "key": "order-12346",
        "accountId": "customer-002",
        "bits": 3,
        "metadata": {
          "amount": 750.00,
          "currency": "USD",
          "description": "Enterprise license"
        }
      }
    ]
  }'

Response 202 Accepted

json
{
  "statusCode": 202,
  "data": {
    "batchId": "batch_abc123",
    "itemCount": 2,
    "status": "queued",
    "message": "Write accepted. Items are queued for verification."
  }
}

Request Fields

FieldTypeRequiredDescription
itemsarrayYesOne or more items to record
items[].keystringYesUnique record identifier (e.g., order ID, transaction ID)
items[].accountIdstringYesThe account or entity this record belongs to
items[].bitsnumberYesInteger value representing the data delta (e.g., quantity, amount)
items[].metadataobjectNoArbitrary key-value data to store alongside the record

How Writes Work

  1. Submit — Your request is accepted and queued for processing
  2. Batch — PacSpace groups items for efficient verification
  3. Verify — Items are verified and committed to the verification layer
  4. Confirm — A webhook notification is sent when verification completes
POST /api/v1/writes → 202 Accepted (queued)
                    → Batched & verified
                    → Webhook: verification.completed

Batch Behavior

  • Items in a single request are processed together as a batch
  • Each batch receives a unique batchId for tracking
  • Large submissions are automatically split into optimal batch sizes
  • Processing typically completes within seconds

Best Practices

  • Use meaningful keys — Record keys should be deterministic and unique (e.g., invoice-2025-001, session-abc-usage)
  • Keep metadata lean — Store essential context only; metadata is included in the verification record
  • Batch when possible — Sending multiple items per request is more efficient than individual calls
  • Set up webhooks — Don't poll for status; use webhooks for real-time confirmation

Error Responses

StatusMeaning
400Invalid request body — check required fields
401Invalid or missing API key
402Insufficient credits
429Rate limit exceeded — back off and retry
500Server error — retry with exponential backoff

See Error Handling for full details.

Was this page helpful?

Last updated February 11, 2026