SpotEx Pay for developers

Merchant API

Take crypto payments on your own site, in your own design, and pay out from your merchant wallet. JSON over HTTPS, with SDKs for Node.js, Python and PHP.

Base URLhttps://spotex.trade/api/merchant/v1

No code at all?

You don't need the API to take payments: make a payment link or a "Pay with SpotEx" button in the Merchant Center and paste it into your site. The API is for shops that want the checkout inside their own pages, and for payouts.

Quickstart

Three steps from nothing to a paid test order.

  1. 01

    Get keys

    Apply at Merchant, then make a test key (sk_test_) under Developers.

  2. 02

    Create a checkout

    One call with the price and your order number. Send the buyer to its url.

  3. 03

    Hear it was paid

    Set a webhook address. Check its signature, then fulfil the order on checkout.paid.

curl -X POST https://spotex.trade/api/merchant/v1/checkout-sessions \
  -H "Authorization: Bearer $SPOTEX_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1043" \
  -d '{ "price": "25.00", "currency": "USD",
        "item": "Gift box", "order_id": "1043",
        "return_url": "https://yourshop.com/thanks" }'

With a test key that is all real except the money: open the session's url, press Pay in full, and your webhook gets checkout.paid with "livemode": false.

SDKs

Official, open source and dependency-free. Each verifies webhooks and handles idempotency keys for you. Or call the API directly: it is plain JSON over HTTPS.

  • Node.js

    TypeScript types, no dependencies

    npm install github:SpotEx-trade/spotex-pay-nodeREADME and examples on GitHub
  • Python

    Standard library only, 3.8+

    pip install git+https://github.com/SpotEx-trade/spotex-pay-pythonREADME and examples on GitHub
  • PHP

    PHP 7.4+, curl

    composer config repositories.spotex vcs https://github.com/SpotEx-trade/spotex-pay-php && composer require spotex/payREADME and examples on GitHub
  • WooCommerce

    A payment method for WordPress shops, classic and block checkout

    Plugins → Add New → Upload Plugin: the repository's zipREADME and examples on GitHub
  • WHMCS

    A payment gateway for WHMCS invoices

    Copy the repository's modules folder into WHMCS, then activate SpotEx Pay under Payment GatewaysREADME and examples on GitHub

Keys and permissions

Every request carries your secret key as a bearer token: Authorization: Bearer sk_live_….

  • Every key can create and read checkouts and read your balance. Nothing more unless you choose it.
  • Transfer and withdraw are separate permissions, off unless you tick them. A key with either must have an IP allowlist: requests from any other address are refused.
  • A withdraw key can be whitelist-only: it then sends only to addresses on your withdrawal whitelist, which you add in the Merchant Center with the identity check.
  • A test key (sk_test_…) works in test mode. It can never pay out.
  • Revoke a key and it stops working at once. Keys see only your own merchant account. Keep them on your server, never in a web page or an app.
  • 300 requests a minute per key; past that, 429 with a Retry-After header.

Endpoints

All under the base URL. Amounts are decimal strings, never numbers, so nothing is lost to floating point.

RequestKey needsDoes
POST/checkout-sessionsany keyOne order paid on SpotEx's own page: send the buyer to its url; they choose the coin and how to pay
GET/checkout-sessions/:idany keyA session: open, paid (with its checkout id) or expired
GET/coinsany keyThe coins you accept, their USD rate, and the networks each can be sent on from any wallet
POST/checkoutsany keyAn on-chain checkout with its own address and exact amount, to show in your design
GET/checkouts/:idany keyOne checkout: status, what arrived, what is still confirming, what is left
GET/checkoutsany keyYour checkouts, newest first. ?status=paid|released|pending, ?limit (max 100), ?before=<id>
POST/checkouts/:id/simulatetest keyTest mode only: { "outcome": "paid" | "partial" | "expired" }
POST/invoiceslive keyAn invoice with its own page to send your customer: lines, currency, due date, note
GET/invoices/:idlive keyOne invoice: open, overdue, paid (with its checkout) or void
GET/invoiceslive keyYour invoices, newest first. ?limit (max 100), ?before=<id>
POST/invoices/:id/voidlive keyCancel an unpaid invoice: its page stops taking payments
POST/planslive keyA plan to subscribe to: { name, price, currency, interval: "week" | "month" | "year" }
GET/planslive keyYour plans, with each one's subscribe url
GET/subscriptionslive keyYour subscribers, newest first. ?status=active|past_due|canceled, ?limit, ?before=<id>
GET/subscriptions/:idlive keyOne subscription: status, periods paid, next charge
POST/subscriptions/:id/cancellive keyEnd a subscription: no more charges
GET/balancelive keyWhat is in your merchant wallet, which payouts are paid from
POST/payouts/transferstransferPay a SpotEx user from the merchant wallet, by username or email. Instant
GET/payouts/transfers/:idlive keyOne transfer you sent
POST/payouts/withdrawalswithdrawSend from the merchant wallet to an address on-chain
GET/payouts/withdrawals/:idlive keyOne withdrawal: status and txid once broadcast

Checkout sessions

The quickest integration: no checkout screen of your own. One call, then send the buyer to its url.

curl -X POST https://spotex.trade/api/merchant/v1/checkout-sessions \
  -H "Authorization: Bearer $SPOTEX_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1043" \
  -d '{ "price": "25.00", "currency": "USD",
        "item": "Gift box", "order_id": "1043",
        "return_url": "https://yourshop.com/thanks" }'
  • The buyer chooses a coin and pays from their SpotEx balance or any wallet, then gets a button back to return_url, which must be on your website.
  • A session takes one payment and closes once paid, or after expires_in_minutes (default 60, up to 1440). The webhook's checkout carries session_id and your order_id.
  • Price it in your own currency: price with any currency under Currencies. amount_usd alone still works, for a price in dollars.
  • Payments start at $1 from a SpotEx balance and $5 from a wallet ($10 for USDT and other tokens on an EVM chain, $50 on Ethereum itself, more on a chain whose own deposit minimum is higher), up to $5,000, or their worth in your currency.

Checkouts in your own design

Create a checkout, show its address and amount in your page, and wait for the webhook.

curl -X POST https://spotex.trade/api/merchant/v1/checkouts \
  -H "Authorization: Bearer $SPOTEX_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1043" \
  -d '{ "price": "25.00", "currency": "USD", "coin": "DOGE",
        "item": "Gift box", "order_id": "1043" }'
{
  "id": "cm...",
  "object": "checkout",
  "livemode": true,
  "status": "pending",
  "method": "onchain",
  "item": "Gift box",
  "order_id": "1043",
  "price": "25.00",
  "currency": "USD",
  "currency_rate_usd": "1",
  "amount_usd": "25.00",
  "coin": "DOGE",
  "amount": "138.88888889",
  "rate_usd": "0.18",
  "address": "D8x...",
  "received": "0",
  "confirming": "0",
  "remaining": "138.88888889",
  "expires_at": "2026-10-27T10:30:00.000Z",
  "hosted_url": "https://spotex.trade/checkout/cm...",
  ...
}
  • Show address and amount (a QR code of the address helps), or send the buyer to hosted_url, SpotEx's own page for it.
  • The price is held for 30 minutes. Coins that can be sent from any wallet are marked onchain: true in GET /coins.
  • A token on several chains, like USDT, takes network too: one of its networks in GET /coins, each with its own min_usd. The address is watched on that chain alone, so show the network beside it. Sent on another, it does not arrive.
  • Paid in parts? SpotEx holds what arrived until the rest does (remaining says how much), or until you accept it as paid in the Merchant Center. Set a shortfall to accept (Settings, up to 5%) and a payment that short or less is paid on arrival.
  • When paid, the amount less the 0.5% fee is in your merchant wallet: fee and net say what each was.
  • Chose to receive payments as one coin (Settings)? Each payment in another coin is sold on the spot market as it lands, within 2% of the market price and with no trading fee, for 1% in all on what converts.

The checkout object

What every checkout endpoint returns, and what webhooks carry in data.checkout.

FieldTypeMeaning
idstringThe checkout's id.
object"checkout"
livemodebooleanFalse for test mode. Never fulfil an order on a false one.
session_idstring | nullThe checkout session (or payment link) it was paid through.
invoice_idstring | nullThe invoice it paid, if any.
subscription_id, subscription_periodstring | null, number | nullThe subscription it charged, and which period (1 is the first).
statusstringpending, partially_paid, paid, released or expired. Released: a part payment SpotEx passed to your wallet without you accepting it (after it waited too long, or by our support). The order is not paid.
methodstringonchain (sent from a wallet) or balance (paid from a SpotEx balance).
item, order_idstringWhat you named it, and your own order number.
price, currencydecimal, stringThe price as you asked it, and its currency: USD, EUR, JPY…
amount_usd, currency_rate_usddecimalThe price in dollars when the checkout was quoted, and the dollars per unit of the currency it used (1 for USD).
coin, amount, rate_usdstring, decimalThe coin, the exact amount owed in it, and the rate it was quoted at.
networkstring | nullFor a token on an EVM chain, the one to send on: BSC, ETH, POLYGON, BASE. Null for a coin on its own chain.
addressstring | nullWhere to send it: this checkout's own address. In test mode a test_ stand-in.
received, confirming, remainingdecimalWhat has arrived, what is seen but still confirming, and what is left to send.
fee, netdecimal | nullOnce paid: SpotEx's fee, and what reached your merchant wallet.
convert_*convert_to, convert_status (pending, sent, done or failed), convert_fee and convert_note: set when you receive payments as one coin.
paid_latebooleanCompleted by money first seen after the quote ran out: check its value.
duplicatebooleanA second payment for a checkout session already paid.
accepted_shortbooleanIt went to your wallet short of the amount: see accepted_by.
accepted_bystring | nullWho let it go short: tolerance (within your shortfall setting) or merchant (you accepted it) pay the order; operator or auto mean status released. Null when paid in full.
expires_at, paid_at, created_atISO 8601
hosted_urlstringSpotEx's own checkout page for it.

Invoices

Bill a customer line by line. Each invoice has a page of its own you send them, and is paid once, from any wallet or a SpotEx balance.

curl -X POST https://spotex.trade/api/merchant/v1/invoices \
  -H "Authorization: Bearer $SPOTEX_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: invoice-2041" \
  -d '{ "currency": "EUR", "customer_name": "Acme Ltd",
        "items": [{ "description": "Logo design",
                    "quantity": "1", "unit_price": "300" }],
        "due_date": "2026-11-30" }'
  • Send the customer url: the invoice's page, with its lines, total and due date, and the way to pay it. SpotEx doesn't email them; you can make invoices in the Merchant Center too, and email them from your own mail app.
  • status is open, overdue (past due_at, still payable), paid or void. When paid, checkout.paid fires with the checkout's invoice_id, and its order_id is the invoice number.
  • Up to 50 lines; each amount is quantity × unit_price, rounded to the currency's decimals, and total is their sum. Text on an invoice can't hold links, emails, phone numbers, handles or wallet addresses. Live keys only.
  • Voiding stops new payments. A customer who had already started paying from a wallet can still complete it: then the invoice is paid, and you can refund them from the Merchant Center.

Subscriptions

Charge SpotEx users every week, month or year, from their balance. They subscribe once and can cancel any time.

  • Make a plan — in the Merchant Center or with POST /plans — and send subscribers its url. They choose a coin, agree to the terms and confirm with their authenticator; the first period is paid then.
  • Each period is charged at the day's rate from their balance, as a checkout of its own: you get checkout.paid with its subscription_id and subscription_period. A period is charged once, whatever happens.
  • A failed charge (not enough in their balance) is tried again daily; after the third, the subscription ends. Monthly and yearly subscribers are reminded three days before each charge. A plan's price and period never change: for a new price, make a new plan.

Currencies

Price in your shop's own currency. The buyer sees your price in it, and pays its worth in their coin.

  • Send price with currency, a three-letter code. Prices have the currency's own decimals: two for most, none for JPY, KRW, IDR, VND, PKR and HUF.
  • Your price becomes dollars when the buyer opens a checkout, at the exchange rate then, rounded up to the cent; the coin amount is quoted from that, and both hold for 30 minutes. The checkout keeps your price, the dollars, and the rate it used (currency_rate_usd).
  • Rates come from the European Central Bank and CoinGecko, checked against each other and refreshed every hour. If a currency's rate can't be confirmed, new prices in it are refused with 503 currency_unavailable until it can: retry, or price in USD.
USDEURGBPJPYCHFCADAUDNZDCNYHKDTWDSGDKRWINRIDRPHPTHBMYRVNDPKRBDTAEDSARTRYILSZARNGNBRLMXNPLNCZKHUFRONSEKNOKDKKUAH

Webhooks

We POST every event to your webhook address, signed, and retry with backoff for about a day until your server answers 2xx.

EventWhen
checkout.paidPaid in full, within your shortfall setting, or accepted by you. Fulfil the order on this one, unless duplicate is true: then it is a second payment for an order already paid, which you accepted, and you may want to refund it.
checkout.partialMoney arrived and is held for you: part of the amount (remaining says what is left), all of it but late and worth less now (paid_late), or a second payment on a checkout session already paid (duplicate).
checkout.extraMore arrived after it was paid; it is in your wallet less the fee.
checkout.releasedA part payment that waited too long (or that our support let go) went to your wallet without you accepting it. The order is NOT paid: don't fulfil it; ask the buyer for the rest, or refund.
checkout.refundedYou refunded some or all of it from the Merchant Center.
subscription.createdSomeone subscribed, and their first period is paid (a checkout.paid comes with it). data.subscription.
subscription.past_dueA period's charge failed: retried daily, three times in all.
subscription.canceledEnded by the subscriber, by you, or by its third failed charge. No more charges.
payout.withdrawal.*broadcast (with txid), completed, failed, rejected, cancelled: a withdrawal you sent moving on. data.withdrawal is it as GET /payouts/withdrawals/:id shows it.
payout.transfer.*completed, rejected: a transfer you sent, including one held for approval. data.transfer.
testFrom the "Send a test event" button in the Merchant Center.
POST /your-webhook
SpotEx-Event: checkout.paid
SpotEx-Delivery: evt_8f1c...
SpotEx-Signature: t=1793071234,v1=5b2c...

{ "id": "evt_8f1c...", "type": "checkout.paid", "created": 1793071234,
  "livemode": true, "data": { "checkout": { ... } } }

Check the signature before trusting anything in the body: v1 is an HMAC-SHA256 of <t>.<raw body> with your webhook signing secret. Refuse events whose t is more than five minutes old, and treat the same id twice as one event.

import { constructEvent } from "spotex-pay";

// rawBody: the exact bytes received, before any JSON parsing
const event = constructEvent(rawBody, req.headers["spotex-signature"], secret);
if (event.type === "checkout.paid" && event.livemode) {
  fulfil(event.data.checkout.order_id); // once per event.id
}

The webhook address must be HTTPS on a public domain name, on port 443 or 8443. Redirects are not followed.

Test mode

Build and test your integration without moving any money.

  • Make a test key in Merchant Center → Developers. With it, POST /checkouts, POST /checkout-sessions and their reads work exactly as live, and every object carries "livemode": false.
  • A test checkout's address starts with test_: it is not an address, never send coins to it. Pay it with POST /checkouts/:id/simulate, or open its hosted_url (or a test session's url) and press a button.
  • Your webhook gets checkout.paid and checkout.partial as it would live, signed the same way, with "livemode": false: check it before fulfilling an order.
  • Test and live never mix: a test key can't read live checkouts, nor a live key test ones. Payouts and the balance need a live key. Test objects are deleted after 30 days.

Payouts

Pay out from your merchant wallet, never from your Spot balance, with a key that has the permission.

# Pay a SpotEx user (instant)
curl -X POST https://spotex.trade/api/merchant/v1/payouts/transfers \
  -H "Authorization: Bearer $SPOTEX_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: refund-1043" \
  -d '{ "to": "alice", "coin": "USDT", "amount": "25",
        "note": "Refund for order 1043" }'

# Withdraw on-chain
curl -X POST https://spotex.trade/api/merchant/v1/payouts/withdrawals \
  -H "Authorization: Bearer $SPOTEX_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: supplier-2026-10-27" \
  -d '{ "coin": "USDT", "network": "BSC",
        "address": "0x...", "amount": "250" }'
  • Confirmed by your key alone: no email and no authenticator code.
  • Sent automatically up to $1,000 a payout and $5,000 in 24 hours. Larger ones are accepted and wait for SpotEx to approve: a transfer is then pending_review, a withdrawal security_review. The amount is reserved in your wallet meanwhile.
  • network is needed only for a coin sent on more than one chain. A withdrawal's network fee comes out of your wallet on top of amount.
  • Transfers follow the rules for any transfer between accounts (the minimum amount, and transfers being switched on) and go to the same account up to 20 times a day.
  • Payouts stop while SpotEx has withdrawals paused, for a frozen account, and for a while after a security change on your account.

Idempotency

Retrying is always safe if you send the same key.

Send an Idempotency-Key header (8 to 100 letters, digits, - or _): the same request with the same key returns the same checkout or payout, however often it is sent. It is required for payouts. After a timeout, retry with the same key, never a new one, or you may pay twice. The SDKs make one for you when you leave it out; for payouts, always pass your own.

Errors

A non-2xx status, with a code to branch on and a message to log.

{ "error": { "code": "insufficient_funds", "message": "Not enough USDT in the merchant wallet." } }
StatusCodeMeans
400invalid_requestA field is missing or wrong: the message says which.
400insufficient_fundsNot enough in the merchant wallet for the payout and its network fee.
401unauthorizedMissing, wrong or revoked key.
403permission_deniedThe key lacks the transfer or withdraw permission.
403ip_not_allowedThe request came from outside the key's IP allowlist.
403not_whitelistedA whitelist-only key sending to an address not on your whitelist.
403merchant_unavailableYour merchant account is not taking payments.
403test_modeA live-only call (balance, payouts) made with a test key.
404not_foundNo such object, or not yours.
409conflictThe request clashes with the object's state.
429rate_limitedOver 300 requests a minute for this key: wait Retry-After seconds.
503paused, unavailablePayments or payouts are paused for now: retry later with the same Idempotency-Key.
503currency_unavailableThe currency's exchange rate isn't current: retry in a few minutes, or price in USD.

The SDKs raise these as an error with status, code and message, and a network failure or timeout as network_error.