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 byreferenceand coin, and payouts and conversions by anIdempotency-Keyheader 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/currenciesandGET /v1/ratesneed 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."}}
| Status | Code | When |
|---|---|---|
| 400 | invalid_request | A field is missing or invalid; the message says which. |
| 401 | unauthorized | The key is missing, unknown or revoked. |
| 403 | forbidden | The key's scope doesn't allow it, or a payout address isn't in your address book. |
| 404 | not_found | No such object for your merchant. |
| 409 | conflict | The order_id exists with a different amount. |
| 429 | rate_limited | Too many requests; slow down. |
| 503 | unavailable | A network, price or route isn't available right now; try again. |
| 500 | internal | Something went wrong on our side. |
Invoices
/v1/invoicesCreate an invoice. Returns 201, or 200 with the existing invoice if the order_id was used before for the same amount.
/v1/invoices/{id}One invoice, by its id or its code.
/v1/invoicesYour 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
| Field | Rules | |
|---|---|---|
amount_usd | required | A string such as "120.00", at most 2 decimals, from $1 to $1,000,000. |
order_id | required | Your reference, 1 to 128 characters: letters, digits and - _ . : / # @. One invoice per order. |
currencies | optional | Coin ids the customer may pay with, from GET /v1/currencies. Empty means the coins set in your dashboard, or all of them. |
lifetime_seconds | optional | How long it can be paid: 300 to 172,800 seconds. Defaults to your dashboard setting, an hour unless you change it. |
description | optional | Shown to the customer; up to 500 characters. |
success_url, return_url | optional | Where the payment page's button takes the customer after paying, or back to you. http or https. |
callback_url | optional | Gets a copy of every webhook for this invoice. See Webhooks. |
metadata | optional | A 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.
/v1/static-walletsreference (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.
/v1/static-wallets/{id}One wallet: id, reference, currency, network, address, tag, callback_url, active and created_at.
Balances, coins and rates
/v1/balancesYour balance per coin and network: currency, symbol, network and amount.
/v1/currenciesEvery coin you can accept: id, symbol, name, network, chain, decimals, required_confirmations and network_fee_usd. No key needed.
/v1/ratesCurrent 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.
/v1/payoutscurrency, amount and address, with an Idempotency-Key header. Returns 201; the same key again returns 200 with the first payout.
/v1/payoutsYour latest 100 payouts.
/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.
/v1/conversionsfrom, to and amount. Returns 201. A key that was used before returns 400.
/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 nameX-Zx-Signature:sha256=and the hex HMAC-SHA256 of the raw body, keyed with your endpoint secretX-Zx-Timestamp: when it was sent
Answer with any 2xx status. Failed deliveries are retried with backoff, up to a limit.
Events
payment.confirmingpayment.paidpayment.overpaidpayment.underpaidpayment.completedpayment.expiredpayment.failedwallet.depositconversion.completedconversion.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_urlgets 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/testsends atestevent to your endpoint at once and returnsdelivered,status_codeandduration_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.