Demo: payments are simulated. No real funds move.

Developers

payment.zx API

A JSON API for invoices, static wallets, balances, payouts and conversions, with signed webhooks for every change. Create keys under API and webhooks in your dashboard.

Basics

Send requests to http://172.234.102.49:8090/v1. Bodies are JSON, and every amount is a decimal string such as "120.00": floats are refused. Times are UTC, in RFC 3339.

  • Body size. Up to 2 MiB a request. Unknown fields in a body are ignored.
  • Repeating a request. Invoices repeat safely by order_id, static wallets by reference and coin, and payouts and conversions by an Idempotency-Key header of 1 to 128 characters. Each section says what a repeat returns.

Authentication

Send your key as a bearer token, or in an X-API-Key header. Keys start with zx_live_, are shown once when you make them, and you can have up to 10 active at a time.

Authorization: Bearer $ZX_API_KEY
  • Payment keys call every route except creating payouts and conversions.
  • Payout keys also create payouts and conversions. Keep them on your server only.
  • GET /v1/currencies and GET /v1/rates need no key at all.

Rate limits

Each merchant gets 120 requests a minute, shared by all of its keys, with bursts up to that number. Past it, you get 429 with the code rate_limited: wait a moment and try again.

Errors

Errors use HTTP status codes and a JSON body with a code to match and a message you can show or log.

{"error": {"code": "invalid_request", "message": "Lifetime must be between 5 minutes and 48 hours."}}
StatusCodeWhen
400invalid_requestA field is missing or invalid; the message says which.
401unauthorizedThe key is missing, unknown or revoked.
403forbiddenThe key's scope doesn't allow it, or a payout address isn't in your address book.
404not_foundNo such object for your merchant.
409conflictThe order_id exists with a different amount.
429rate_limitedToo many requests; slow down.
503unavailableA network, price or route isn't available right now; try again.
500internalSomething went wrong on our side.

Invoices

POST/v1/invoices

Create an invoice. Returns 201, or 200 with the existing invoice if the order_id was used before for the same amount.

GET/v1/invoices/{id}

One invoice, by its id or its code.

GET/v1/invoices

Your invoices, newest first: limit (1 to 100, default 20), status and starting_after, the id of the last invoice you have. The answer has data and has_more.

Create an invoice

FieldRules
amount_usdrequiredA string such as "120.00", at most 2 decimals, from $1 to $1,000,000.
order_idrequiredYour reference, 1 to 128 characters: letters, digits and - _ . : / # @. One invoice per order.
currenciesoptionalCoin ids the customer may pay with, from GET /v1/currencies. Empty means the coins set in your dashboard, or all of them.
lifetime_secondsoptionalHow long it can be paid: 300 to 172,800 seconds. Defaults to your dashboard setting, an hour unless you change it.
descriptionoptionalShown to the customer; up to 500 characters.
success_url, return_urloptionalWhere the payment page's button takes the customer after paying, or back to you. http or https.
callback_urloptionalGets a copy of every webhook for this invoice. See Webhooks.
metadataoptionalA JSON object, sent back in this invoice's webhooks.
curl http://172.234.102.49:8090/v1/invoices \
  -H "Authorization: Bearer $ZX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount_usd": "120.00", "order_id": "order-1042",
       "currencies": ["usdt-trc20", "btc"]}'

The invoice object

id, code (10 characters, in the payment link), order_id, status, amount_usd, description, checkout_url (send your customer here), currencies, success_url, return_url, callback_url, credited, expires_at, paid_at, created_at and payment.

{
  "id": "4b1d0c6e-…",
  "code": "K7Q2MZ8RXT",
  "order_id": "order-1042",
  "status": "waiting",
  "amount_usd": "120.00",
  "checkout_url": "http://172.234.102.49:8090/i/K7Q2MZ8RXT",
  "credited": false,
  "expires_at": "…",
  "payment": null
}

status is waiting, confirming, paid, overpaid, underpaid, expired or failed. credited turns true once the money is in your balance.

payment fills in once the customer picks a coin: id, asset_id, network, status, pay_amount, received_amount, address, tag, confirmations, required_confirmations and txids.

Static wallets

A permanent deposit address for one customer and one coin. Every deposit to it is credited to your balance and reported by webhook.

POST/v1/static-wallets

reference (your customer id, same rules as order_id), currency and an optional callback_url. Returns 201; the same reference and coin again return the same wallet with 200.

GET/v1/static-wallets/{id}

One wallet: id, reference, currency, network, address, tag, callback_url, active and created_at.

Balances, coins and rates

GET/v1/balances

Your balance per coin and network: currency, symbol, network and amount.

GET/v1/currencies

Every coin you can accept: id, symbol, name, network, chain, decimals, required_confirmations and network_fee_usd. No key needed.

GET/v1/rates

Current USD rates per coin, with as_of. No key needed.

Payouts

Payouts go only to addresses saved in your dashboard's address book, confirmed by email and past their 24-hour wait. Creating one needs a payout key.

POST/v1/payouts

currency, amount and address, with an Idempotency-Key header. Returns 201; the same key again returns 200 with the first payout.

GET/v1/payouts

Your latest 100 payouts.

GET/v1/payouts/{id}

One payout.

The coin's payout fee comes out of amount, so the address receives net_amount. A payout has id, currency, amount, fee, net_amount, address, tag, status (requested, processing, sent, confirmed or failed), txid, created_at and completed_at.

Conversions

Exchange coins in your balance. Creating one needs a payout key and an Idempotency-Key header.

POST/v1/conversions

from, to and amount. Returns 201. A key that was used before returns 400.

GET/v1/conversions/{id}

One conversion: from, from_amount, to, to_amount, rate, route, status and times.

Conversions worth up to $5,000 are filled from payment.zx's own reserves when they cover the amount, at the market rate less 0.4%, and complete at once. Others go through a partner route at its rate less the same spread, start as pending and finish on their own, moving through sending and exchanging to completed or failed.

Webhooks

Set one endpoint, and the events it gets, under API and webhooks in the dashboard. payment.zx sends each event as a JSON POST with these headers:

  • X-Zx-Event: the event name
  • X-Zx-Signature: sha256= and the hex HMAC-SHA256 of the raw body, keyed with your endpoint secret
  • X-Zx-Timestamp: when it was sent

Answer with any 2xx status. Failed deliveries are retried with backoff, up to a limit.

Events

  • payment.confirming
  • payment.paid
  • payment.overpaid
  • payment.underpaid
  • payment.completed
  • payment.expired
  • payment.failed
  • wallet.deposit
  • conversion.completed
  • conversion.failed

Check the signature

Compute the HMAC over the body exactly as received, before parsing it.

// Node.js
import { createHmac, timingSafeEqual } from "node:crypto";

function isFromZx(rawBody, signature, secret) {
  const expected = "sha256=" + createHmac("sha256", secret).update(rawBody).digest("hex");
  return signature.length === expected.length &&
    timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}
# Python
import hashlib, hmac

def is_from_zx(raw_body: bytes, signature: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature, expected)

Delivery

  • Answer with any 2xx within 10 seconds. Redirects aren't followed.
  • A failed delivery is tried again after 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours: six attempts in all.
  • Webhooks go only to public addresses, never to private or internal networks.
  • An invoice's or static wallet's callback_url gets a copy of each of its events, whatever your endpoint subscribes to. It's signed with your endpoint's secret, so it needs an endpoint set.
  • POST /v1/webhooks/test sends a test event to your endpoint at once and returns delivered, status_code and duration_ms.

What an event carries

payment.* events carry invoice_id, invoice_code, order_id, payment_id, status, amount_usd, pay_asset_id, pay_amount, received_amount, credited_amount, credited_asset_id, address, txids, metadata and timestamp. wallet.deposit carries the wallet's reference and the deposit. conversion.* carries the conversion.