API Reference
Webhooks
PayLio sends a signed POST request to your callback URL when a payment is completed, and retries it until your server accepts it.
How delivery works#
| Property | Value |
|---|---|
| Method | POST with a JSON body |
| URL | The callback you passed to Create Checkout or Create a crypto payment. Payments without a callback use the account webhook URL from Dashboard → Webhooks. |
| Signature | X-PayLio-Signature: hex HMAC-SHA256 of the raw body |
| Signing key | Per-payment callback: the payment's ipn_token (plugins: the secret they sent at creation). Account webhook URL: your signing secret (whsec_…). |
| Other headers | X-PayLio-Event (event name) and X-PayLio-Delivery (delivery ID, new for every resend) |
| Timeout | 10 seconds |
| Success | Any 2xx response |
| Redirects | Not followed. Point the callback at the final URL. |
| Retries | Up to 12 attempts with backoff, see Retries |
Retries#
Every event is stored before it is sent and tried right away. If your endpoint times out, cannot be reached or answers with anything but 2xx, PayLio tries again after a growing delay:
| After failed attempt | Next try in |
|---|---|
| 1 | 1 minute |
| 2 | 2 minutes |
| 3 | 5 minutes |
| 4 | 15 minutes |
| 5 | 30 minutes |
| 6 | 1 hour |
| 7 | 2 hours |
| 8 | 4 hours |
| 9 | 8 hours |
| 10 and 11 | 12 hours |
After the 12th failed attempt (about 40 hours) the delivery is marked failed and not retried automatically. A URL that can never work (not https, a private address, credentials in the URL) fails at once. Each attempt is signed again with a fresh timestamp, so the body of a retry differs from the first try.
Handle duplicates
A retry can reach you even if an earlier attempt was processed but answered too slowly. Fulfil each order only once, and keep using Payment Status to reconcile open orders.Delivery log and resending#
Dashboard → Webhooks lists your last 100 deliveries with event, payment, endpoint host, status (pending, delivered, failed), attempts, the last HTTP status or error and the time of the next retry. Resend creates a new delivery of the same event with a newX-PayLio-Delivery ID; deliveries to your account URL go to the URL that is saved now.
Signing secret#
The account webhook URL is signed with a secret of the form whsec_ followed by 64 hex characters. It is created when you save a webhook URL and shown once; afterwards the dashboard only shows a masked version. Use the whole string, including whsec_, as the HMAC key. Rotate secret replaces it immediately; pending retries are signed with the new secret. Per-payment callbacks (API callback, WooCommerce, WHMCS) keep their own key and are not affected by rotation.
Test events#
Send test event posts a signed test.ping to your account webhook URL. It is listed in the delivery log with a Test badge and is retried like any other event. Answer it with 2xx; do not change any order.
{
"event": "test.ping",
"test": true,
"message": "Test event from PayLio. Your endpoint received and can verify signed webhooks.",
"timestamp": 1791983126
}Events#
| Event | When |
|---|---|
payment.paid | The payment was received. For card payments, the USDC has also been sent to your wallet. |
payment.forwarded | Direct crypto only: the funds were forwarded to your wallet. |
test.ping | Only when you click Send test event in the dashboard. |
No event is sent for underpaid or canceled payments. Check them in the dashboard or via the API.
Payload#
POST /paylio/webhook HTTP/1.1
Content-Type: application/json
User-Agent: PayLio-Webhook/1.0
X-PayLio-Signature: 5d41402abc4b2a76b9719d911017c592...
X-PayLio-Event: payment.paid
X-PayLio-Delivery: cm3x9k2f40001qz8h7t2v5b1c
{
"event": "payment.paid",
"id": "3f6c2a1e-8b4d-4c7a-9e21-5d0b7f9a1c34",
"paymentId": "3f6c2a1e-8b4d-4c7a-9e21-5d0b7f9a1c34",
"status": "paid",
"amount": "54.34",
"originalAmount": "49.99",
"customerFeeAmount": "4.35",
"passFeeToCustomer": true,
"currency": "USD",
"coin": "polygon_usdc",
"receivedAmount": "53.9",
"forwardedAmount": "49.6",
"txidIn": "0xa22a82b4...",
"txidOut": "0x94c2c3e8...",
"note": "Order #1042",
"timestamp": 1791983126
}Keys in webhook bodies use camelCase, unlike the snake_case API responses.
eventstringpayment.paid or payment.forwarded.paymentIdstringid carries the same value.statusstringpaid for this event.amount / originalAmount / customerFeeAmountstring | nullcoin / receivedAmount / forwardedAmountstring | nullcoin is the coin identifier, e.g. trc20/usdt, and receivedAmount is in coin units.txidIn / txidOutstring | nullnotestring | nulltimestampnumberpayment.forwarded#
{
"event": "payment.forwarded",
"paymentId": "3f6c2a1e-8b4d-4c7a-9e21-5d0b7f9a1c34",
"forwardTxid": "0x7be1...",
"amountForwarded": "98.5",
"toWallet": "0xYourWallet",
"timestamp": 1791983311
}Verify and handle a webhook#
- Read the raw request body before parsing it.
- Compute HMAC-SHA256 of the raw body with the stored
ipn_token(or yourwhsec_secret for the account webhook URL) and compare it toX-PayLio-Signaturein constant time. - Confirm the payment with
GET /payment-status. - Fulfil the order only once, even if the same event reaches you twice (retries and resends).
- Respond with
200within 10 seconds and do slow work afterwards.
import crypto from "node:crypto";
// Use the raw body: the signature is computed over the exact bytes.
app.post("/paylio/webhook", express.raw({ type: "application/json" }), async (req, res) => {
const event = JSON.parse(req.body.toString("utf8"));
const order = await findOrderByPaylioId(event.paymentId);
if (!order) return res.status(404).send("unknown payment");
const expected = crypto
.createHmac("sha256", order.paylioIpnToken)
.update(req.body)
.digest("hex");
const received = String(req.get("X-PayLio-Signature") || "");
if (received.length !== expected.length ||
!crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected))) {
return res.status(403).send("invalid signature");
}
// Never trust the webhook alone: confirm with the API.
const url = `https://paylio.org/api/v1/payment-status?payment_id=${encodeURIComponent(event.paymentId)}`;
const payment = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.PAYLIO_API_KEY}` },
}).then((r) => r.json());
if (payment.status === "paid" && !order.paid) {
await markOrderPaid(order.id, payment.txid_out);
}
res.status(200).send("ok");
});Callback URL requirements#
| Rule | Why |
|---|---|
| Must use https:// | Webhooks are never sent over plain HTTP. |
| Must resolve to a public IP | localhost, private networks and cloud metadata hosts are blocked. |
| No user:password@ in the URL | Credentials in URLs are rejected. |
| Max 2048 characters | Longer URLs fail validation. |
/paylio/webhook?order=1042) to find the order faster. Allow PayLio's requests through your firewall, WAF or bot protection.