Developer docs

Everything you need to take payments with the TrustSettle API, webhooks, payment links and the Pay button.

The short version. Your server creates a payment, you send the customer to the checkout_url we return, and we send your server a signed webhook when the payment is confirmed. There is no SDK to install, and no card or wallet code to maintain. Prefer no code at all? Use a payment link or the Pay button.

Quickstart

  1. Get a test key. Create an account. You get a ts_test_ API key straight away and a webhook signing secret (whsec_). Both are shown once, so store them somewhere safe.
  2. Create a payment from your server with POST /v1/payments (below), or try it in the playground first.
  3. Send the customer to checkout_url. They pay by card or with the coin they hold.
  4. Listen for the webhook. When the status becomes paid we call your webhook URL. Check the signature, then fulfil the order.
curl https://trustsettle-api.trustsettle.workers.dev/v1/payments \
  -H "Authorization: Bearer ts_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "500.00",
    "currency": "USD",
    "order_id": "INV-123",
    "customer_email": "buyer@example.com",
    "description": "Order INV-123",
    "success_url": "https://yourshop.com/thanks",
    "cancel_url": "https://yourshop.com/cart"
  }'

The response contains the checkout_url:

201 Created
{
  "id": "pay_Hq3x...",
  "object": "payment",
  "order_id": "INV-123",
  "amount": 500,
  "currency": "USD",
  "status": "pending",
  "provider": null,
  "customer_email": "buyer@example.com",
  "customer_name": null,
  "description": "Order INV-123",
  "metadata": {},
  "link_id": null,
  "invoice_number": null,
  "checkout_url": "https://trustsettle.web.app/checkout?session=pay_Hq3x...",
  "created_at": "2026-11-25T10:00:00.000Z",
  "expires_at": "2026-11-25T11:00:00.000Z",
  "paid_at": null
}

Test and live

Every account starts in test mode. Test payments use a sandbox, so no real money moves. The mode is set by your API key:

KeyModeWhat happens
ts_test_...TestSandbox payments. Never counted against plan limits. Invoice numbers look like TEST-0001.
ts_live_...LiveReal payments. Crypto is sent straight to your own settlement wallet. Invoice numbers look like INV-0001.

Find and roll your keys in the dashboard under API keys. Your test key and live key work side by side: use the test key to test and the live key to go live, without swapping keys, even after the setup fee is paid. Rolling a key stops only that key, and the other keeps working. The dashboard also has a test/live switch for payment links and invoices you create there. Test and live payments are completely separate and one can never change the other.

Base URL: https://trustsettle-api.trustsettle.workers.dev

Authentication

Call the API from your server only, and send your key as a bearer token on every request. The merchant API sends no CORS headers on purpose, so it cannot be called from a browser. Keep the key out of your website code.

Header
Authorization: Bearer ts_test_xxxxxxxxxxxxxxxxxxxxxxxx

A missing or wrong key returns 401 unauthorized. If you have not paid the setup fee for the mode you are using, you get 402 setup_fee_required.

Create a payment

POST/v1/payments
FieldTypeDescription
amount *string or numberPositive, at most 2 decimals, up to 1,000,000. Send it as a string such as "500.00" to avoid float surprises.
currency *stringUSD, EUR or GBP.
order_id *stringYour own reference, 1 to 64 characters: letters, digits, _ . -. Unique per merchant (see below).
customer_emailstringIf you pass it, the customer is not asked for it again, and they get a receipt there.
descriptionstringUp to 200 characters. Shown on the checkout page and the invoice.
metadataobjectAnything you want back in webhooks. Up to 2 KB of JSON.
success_urlstringWhere the customer goes after paying. Must be https on one of your approved domains.
cancel_urlstringWhere the customer goes if the payment is cancelled, fails or expires. Same rule.

Approved domains are the Redirect domains in the dashboard under Settings. A subdomain of an approved domain is accepted. This stops your key being used to build open redirects.

Try this call in the playground →

Safe to retry (idempotency)

order_id makes the call safe to repeat. Sending the same order_id again returns the same payment with 200 instead of 201, so a timeout or a double click never creates two payments. If you reuse an order_id with a different amount or currency you get 409 order_conflict.

Expiry

A payment that nobody has started paying expires after 60 minutes and moves to expired. Once the customer has picked a coin and been shown an address, the payment stays open so a late transfer can still be matched.

Retrieve a payment

GET/v1/payments/:id

Returns the payment object shown above. Use it to check a status when you do not want to wait for a webhook, for example on your own "thank you" page. Treat the webhook as the source of truth, and never mark an order paid because a customer landed on success_url.

curl https://trustsettle-api.trustsettle.workers.dev/v1/payments/pay_Hq3x... \
  -H "Authorization: Bearer ts_test_..."

Try it in the playground →

Payment statuses

A status only ever moves forward. A late or replayed event can never turn a paid payment back into a failed one.

StatusMeaningWebhook
pendingCreated and waiting for the customer.none
processingThe customer has paid and the network is confirming it.none
paidConfirmed and checked against your invoice amount. Safe to fulfil the order.payment.paid
partially_paidThe customer sent less than the invoice amount.payment.partially_paid
failedThe payment did not go through. No funds were confirmed.payment.failed
expiredNobody paid in time.payment.expired
cancelledThe payment was cancelled.payment.cancelled
refundedThe payment was refunded.payment.refunded
reviewThe amount, currency or payout address did not match your invoice, so a person has to check it. Do not fulfil the order.none

The checkout page

You never build a payment form. The hosted checkout shows the amount and your business name, and asks for an email if you did not send one. The customer then picks how to pay, and the page shows Payment successful only after our server says the payment is paid. Nothing in the browser can fake that.

For live payments the customer pays a provider address and the money is converted and sent to your own settlement wallet. We never hold your funds. If the provider ever reports a different payout address than the one on your invoice, the payment goes to review instead of paid.

Webhooks

Set your webhook URL in the dashboard under Webhooks. It must be https and reachable from the public internet (private and internal addresses are refused). We send a POST with a JSON body each time a payment reaches one of these statuses: paid, partially_paid, failed, expired, cancelled or refunded.

Example event: payment.paid
{
  "id": "k3Jx9...",
  "type": "payment.paid",
  "created": 1795600000,
  "data": {
    "id": "pay_Hq3x...",
    "order_id": "INV-123",
    "amount": 500,
    "currency": "USD",
    "status": "paid",
    "provider": "nowpayments",
    "metadata": {},
    "link_id": null,
    "invoice_number": "INV-0001",
    "paid_at": "2026-11-25T10:07:41.000Z"
  }
}
FieldDescription
idUnique id of this event. A retry of the same event keeps the same id.
typepayment. followed by the status.
createdUnix time (seconds) the event was created.
data.idThe payment id (pay_...).
data.order_idThe order_id you sent. Use it to find your order.
data.invoice_numberSet on paid events, for example INV-0001.
data.link_idThe payment link it came from, or null for API payments.
data.metadataThe metadata you sent.

Acknowledging and retries

Duplicates

Webhooks are delivered at least once, so the same event can arrive twice. Make your handler safe to run twice, for example by storing the event id (or checking that the order is not already paid) before you fulfil it.

Verify a webhook

Every webhook carries a header, TrustSettle-Signature: t=<unix time>,v1=<hex>, where v1 is the HMAC-SHA256 of t + "." + rawBody using your webhook secret (whsec_...). Always verify it, using the raw request body, and reject anything older than 5 minutes.

import crypto from 'node:crypto';
import express from 'express';

const app = express();

// You need the RAW body to check the signature, so do not JSON-parse before verifying.
app.post('/hooks/trustsettle', express.raw({ type: 'application/json' }), (req, res) => {
  const header = req.get('TrustSettle-Signature') || '';
  const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
  const t = parts.t, v1 = parts.v1;
  if (!t || !v1) return res.sendStatus(400);

  const expected = crypto.createHmac('sha256', process.env.TS_WEBHOOK_SECRET)
    .update(`${t}.${req.body.toString('utf8')}`).digest('hex');

  const a = Buffer.from(v1), b = Buffer.from(expected);
  if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) return res.sendStatus(400);
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return res.sendStatus(400); // replay window: 5 min

  const event = JSON.parse(req.body.toString('utf8'));
  if (event.type === 'payment.paid') {
    // mark event.data.order_id as paid. Make this safe to run twice (see "Duplicates").
  }
  res.sendStatus(200); // any 2xx acknowledges
});

Sign or check a sample webhook in the playground → You can also simulate a payment event and watch your server receive it.

Roll the secret if it leaks. In the dashboard under Webhooks, roll the signing secret. The old one stops working immediately, so update your server straight after.

Playground Test mode

Try the API from this page, with your own ts_test_ key and no code. Requests go to the real API and the responses are real, so you can see exactly what your server will receive: success shapes, every error code, idempotent replays and signed webhooks.

Test keys only. A ts_live_ key is refused here and again by our server. The key is kept in this page's memory (or this tab's session storage if you tick the box), and is only ever sent to the TrustSettle API. Nothing here moves real money. Production calls must still come from your server, never from a browser.

Find it in the dashboard under API keys. For webhooks to arrive, set your webhook URL under Webhooks. Approved Redirect domains apply to success_url and cancel_url as usual.

Start from an example

Request body

POST /v1/payments

The same call in your server code

Calls are limited to 60 a minute. Test payments never count against plan limits. Test receipts are only emailed to your own address.

You do not need the API to get paid. In the dashboard open Payment links, enter what the payment is for and an amount, and share the link by WhatsApp or email. Your client enters their email, pays at the normal checkout, and the payment appears in your dashboard.

Pay button for your website One line

Add a ready-made Pay with TrustSettle button to any page with one script tag. It needs no API key and no backend, because the amount is fixed by the payment link. In the dashboard press Add to website on a link to copy the exact snippet.

<script src="https://trustsettle.web.app/button.js" data-link="lnk_..."></script>
AttributeDefaultWhat it does
data-link *Your payment link id (lnk_...).
data-labelPay with TrustSettleButton text.
data-themedarkdark or light.
data-emailPrefills the client's email on the pay page.
data-target_blankUse _self to open in the same tab.

Use a reusable link for a public page. A one-payment link stops working after the first payment, so the button would stop working for everyone else.

The button opens the pay page in a new tab. It does not use an iframe, because the pay page cannot be framed on purpose. If you need a different amount for every order, create the payment from your server with the API instead.

If you load the script after the page has changed, call TrustSettle.mount() to draw any new buttons. You can also skip the script and use a plain link: <a href="https://trustsettle.web.app/pay/lnk_...">Pay now</a>.

Branding your checkout

Your customers see your business, not a generic page, from the moment they open a payment link or press the Pay button, through to the hosted checkout you send them to from the API. Set it once in the dashboard under Settings, then Checkout branding. It applies straight away, including to payments and links you have already created.

SettingWhat it doesRules
Business nameShown as "Pay your business" and in the browser tab title. Without a logo it also replaces the TrustSettle mark at the top of a payment link.2 to 80 characters. Set under Business.
LogoReplaces the TrustSettle mark at the top of the payment link page, and appears on a white tile at the top of the amount panel on the hosted checkout.PNG, JPEG or WebP. Resized in the dashboard to fit 400 by 160 pixels and stored at under 100 KB. SVG is not accepted.
Accent colourThe amount panel, the main buttons and the selected payment method.6 hex digits such as #0a7c66. White text sits on it, so a colour that is too light is rejected.

Where it appears

What stays the same. The footer still reads "Secure checkout by TrustSettle", so customers know who is processing the payment, and the payment page cannot be changed beyond the logo and colour. Invoices and receipt emails are not branded yet. Branding is the same in test and live mode, so you can check it with a test payment link before going live.

The checkout and payment link endpoints return a brand object ({ "color": "#0a7c66", "logo": "data:image/png;base64,..." }, each field null when unset) that the TrustSettle pages use. The merchant API does not change.

Invoices and receipts

Every paid payment, from the API or a payment link, gets its own numbered invoice written at the moment it is marked paid, so numbers never repeat. Live invoices are INV-0001, INV-0002 and so on, and test ones are TEST-0001. The number appears as invoice_number on the payment and in the payment.paid webhook.

Errors

Errors use standard HTTP status codes and one JSON shape. Show error.message to your developers, and branch on error.code in code.

Error response
{
  "error": {
    "code": "invalid_amount",
    "message": "amount must be a positive number with at most 2 decimals."
  }
}
HTTPCodeWhat to do
400invalid_jsonThe request body is not valid JSON.
400invalid_amountFix the amount: positive, at most 2 decimals, within the limit.
400invalid_currencyUse USD, EUR or GBP.
400invalid_order_id1 to 64 characters: letters, digits, _ . -.
400invalid_emailcustomer_email is not a valid address.
400invalid_metadataMust be an object under 2 KB.
400invalid_redirectsuccess_url or cancel_url is not https on an approved domain.
401unauthorizedMissing, malformed or rolled API key.
402setup_fee_requiredPay the setup fee for this mode in the dashboard (Billing).
402subscription_requiredLive payments need a paid plan.
402plan_limit_reachedYour plan's monthly live volume is used up. Upgrade or wait for next month.
404not_foundNo such payment on your account.
409order_conflictThis order_id already exists with a different amount or currency.
409payout_wallet_requiredAdd a settlement wallet in Settings before taking live payments.
413payload_too_largeRequest bodies are limited to 32 KB.

Going live

  1. Run a full test payment with your ts_test_ key and confirm your server handles the webhook, including a replay of the same event.
  2. Choose a plan in Billing and pay the second half of the setup fee.
  3. Add your settlement wallet in Settings. Payments are sent straight to it. Double-check the address and network.
  4. Create your ts_live_ key under API keys (your test key keeps working), store the live key in your server's secrets and deploy.
  5. Make one small real payment end to end and check that the funds arrive and your order is marked paid.

Stuck? Email support@trustsettle.co with the payment id (pay_...). Questions from customers about paying are answered in the FAQ.