Payments

Auto-topup rule and quiver state

GET/v1/balance/auto-topup

Responses

200Current rule

  • threshold_usd string (required)
  • max_per_month integer (required)
  • suspended boolean (required)
  • consecutive_failures integer (required)
  • quiver object (required)
  • ready_value_usd string (required)
  • used_this_month integer (required)
  • arrows object[] (required)

404No auto-topup rule configured

Example

curl -X GET https://api.cofferline.com/v1/balance/auto-topup \
  -H "authorization: Bearer $TOKEN"

Configure auto-topup: a threshold plus pre-signed authorizations

PUT/v1/balance/auto-topup

Each authorization is a fixed-value EIP-3009 transferWithAuthorization to the treasury with a unique nonce — signed by the payer wallet, settleable exactly once, cancellable on-chain by the payer at any time. When a fee debit drops the balance below the threshold, the platform settles the oldest ready authorization and credits the balance. PUT replaces the rule (and re-arms a suspended one) and ADDS the given authorizations to the quiver; already-known nonces are skipped.

Request body

  • threshold_usd string (required)
  • max_per_month integer
  • authorizations object[] (required)

Responses

200Rule stored; quiver extended
400An authorization failed verification
403Beneficiary unbound (#284): arrows are self-funded or signed over a 402 challenge nonce
422Quiver cap exceeded (#351): more than 20 live arrows would be stored
503Treasury signer unconfigured

Example

curl -X PUT https://api.cofferline.com/v1/balance/auto-topup \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  -d '{"threshold_usd":"…","authorizations":[{"from":"…","to":"…","value":"…","valid_after":"…","valid_before":"…","nonce":"…","signature":"…"}]}'

Remove the auto-topup rule and its unsettled authorizations

DELETE/v1/balance/auto-topup

Deletes the rule and every stored authorization. Settled credits stay on the ledger. Deleting here does not revoke the signatures cryptographically — the response's cancellation block carries everything the payer needs to void each outstanding nonce on-chain (sign CancelAuthorization over the given domain; anyone may submit).

Responses

200Removed; cancellation instructions for outstanding nonces

  • removed_authorizations integer (required)
  • note string (required)
  • cancellation object (required)

404No auto-topup rule configured

Example

curl -X DELETE https://api.cofferline.com/v1/balance/auto-topup \
  -H "authorization: Bearer $TOKEN"

Prepaid balance (Σ settled credits − Σ fee debits)

GET/v1/balance

Responses

200Current balance

  • balance_usd string (required)
  • currency "USD" (required)

Example

curl -X GET https://api.cofferline.com/v1/balance \
  -H "authorization: Bearer $TOKEN"

Top up the prepaid balance via x402 (USDC, EIP-3009)

POST/v1/balance/topup

Without an X-PAYMENT header this answers 402 with exact-scheme payment requirements for the requested amount. Retry with the signed transferWithAuthorization: it settles on-chain first (real USDC to the treasury), then credits — the authorization nonce guarantees a retry can never double-credit. A durable pending-settlement record exists before anything is broadcast, so an interrupted request converges on exactly one credit (202 = outcome pending, reconciled from chain truth).

Request body

  • amount_usd string (required)

Responses

200Settled and credited
202Settlement outcome unknown — being reconciled from chain truth; do not re-sign

  • settlement_status "pending" (required)
  • nonce string (required)
  • value_usd string (required)
  • remediation string (required)

400Invalid or insufficient payment authorization
402Payment required — standard x402 requirements
403Beneficiary unbound (#284): a third-party payer must sign the 402's extra.thirdPartyNonce
422Prepaid cap exceeded (#349): the top-up would push this account's balance past the per-tenant cap, or the platform's aggregate float past the global cap
429Too many concurrent unsettled top-ups for this account (#336): let the in-flight ones settle
503Treasury signer unconfigured, or the payer's balance was unreadable

Example

curl -X POST https://api.cofferline.com/v1/balance/topup \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  -d '{"amount_usd":"…"}'