API reference

The settlement API.

A small REST API over the velapay rail. Open and close channels, submit signed per-action receipts, request Receipt Aggregate Vouchers, and settle on-chain at threshold. Every write request is signed with your channel key; responses are JSON. Base URL https://api.velapay.xyz.

Channels

Open a stateless one-way payment channel to a counterparty, inspect its state, and close it to release escrow.

POST  /v1/channels

Open a new one-way channel from the payer to a named counterparty and lock escrow.

GET  /v1/channels/:id

Fetch a channel's state: escrow, unpaid balance, receipt count, and settlement count.

POST  /v1/channels/:id/close

Begin closing a channel; remaining escrow thaws and is returned after the delay.

POST /v1/channels · open a channel
POST /v1/channels
{
  "to":        "agent:search-tool.v2",
  "escrow":    "500.00",
  "threshold": "250.00"
}

// 201 Created
{
  "id":      "chn_9f3a21",
  "status":  "open",
  "unpaid":  "0.00",
  "receipts": 0
}

Receipts

Submit signed per-action receipts against an open channel and list the receipts a channel has tallied.

POST  /v1/receipts

Submit a signed receipt for one metered action; the receiver verifies and tallies it.

GET  /v1/receipts?channel=:id

List receipts for a channel, paginated by nonce, with the running unpaid balance.

POST /v1/receipts · submit a signed receipt
POST /v1/receipts
{
  "channel": "chn_9f3a21",
  "action":  "tools/web.search",
  "units":   1,
  "nonce":   812441,
  "sig":     "0x7c…e10"
}

// 202 Accepted
{
  "accepted": true,
  "unpaid":   "324.97",
  "tallied":  812441
}

RAV redemption

Request a Receipt Aggregate Voucher that collapses a channel's tallied receipts into a single redeemable claim.

POST  /v1/rav

Request a RAV for a channel once its unpaid balance has crossed the threshold.

GET  /v1/rav/:id

Fetch a RAV's amount, the receipts it aggregates, and whether it has been settled.

POST /v1/rav · request a Receipt Aggregate Voucher
POST /v1/rav
{
  "channel": "chn_9f3a21"
}

// 200 OK
{
  "id":       "rav_18c44e",
  "amount":   "324.97",
  "receipts": 812441,
  "status":   "redeemable"
}

Settlement

Settle one or more RAVs on-chain in a single transaction once balances cross their thresholds, and track the result.

POST  /v1/settlements

Settle redeemable RAVs on-chain at threshold, batching many receipts into one tx.

GET  /v1/settlements/:id

Fetch a settlement's transaction hash, block, redeemed amount, and confirmation state.

POST /v1/settlements · settle on-chain at threshold
POST /v1/settlements
{
  "ravs": ["rav_18c44e", "rav_18c451"]
}

// 200 OK
{
  "id":       "stl_4421a0",
  "tx":       "0x3d…91f",
  "block":    19442071,
  "redeemed": "2215.37",
  "status":   "confirmed"
}

Authentication

Authenticate with an API key in the Authorization header. Every write request must also be signed with your channel key, and the receiver verifies that signature before tallying, so a leaked API key alone cannot mint receipts. New to the rail? Start with the quickstart.

Read the quickstart