PayLioDocs

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#

PropertyValue
MethodPOST with a JSON body
URLThe callback you passed to Create Checkout or Create a crypto payment. Payments without a callback use the account webhook URL from Dashboard → Webhooks.
SignatureX-PayLio-Signature: hex HMAC-SHA256 of the raw body
Signing keyPer-payment callback: the payment's ipn_token (plugins: the secret they sent at creation). Account webhook URL: your signing secret (whsec_…).
Other headersX-PayLio-Event (event name) and X-PayLio-Delivery (delivery ID, new for every resend)
Timeout10 seconds
SuccessAny 2xx response
RedirectsNot followed. Point the callback at the final URL.
RetriesUp 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 attemptNext try in
11 minute
22 minutes
35 minutes
415 minutes
530 minutes
61 hour
72 hours
84 hours
98 hours
10 and 1112 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.

test.ping
{
  "event":     "test.ping",
  "test":      true,
  "message":   "Test event from PayLio. Your endpoint received and can verify signed webhooks.",
  "timestamp": 1791983126
}

Events#

EventWhen
payment.paidThe payment was received. For card payments, the USDC has also been sent to your wallet.
payment.forwardedDirect crypto only: the funds were forwarded to your wallet.
test.pingOnly 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#

payment.paid
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.

eventstring
payment.paid or payment.forwarded.
paymentIdstring
The PayLio payment ID. id carries the same value.
statusstring
Always paid for this event.
amount / originalAmount / customerFeeAmountstring | null
Charged amount, requested amount and passed-through fee.
coin / receivedAmount / forwardedAmountstring | null
Settlement asset and amounts. For crypto payments coin is the coin identifier, e.g. trc20/usdt, and receivedAmount is in coin units.
txidIn / txidOutstring | null
On-chain transaction hashes.
notestring | null
The note you set on the payment.
timestampnumber
Unix time (seconds) of this attempt. Reject bodies older than a day.

payment.forwarded#

{
  "event":           "payment.forwarded",
  "paymentId":       "3f6c2a1e-8b4d-4c7a-9e21-5d0b7f9a1c34",
  "forwardTxid":     "0x7be1...",
  "amountForwarded": "98.5",
  "toWallet":        "0xYourWallet",
  "timestamp":       1791983311
}

Verify and handle a webhook#

  1. Read the raw request body before parsing it.
  2. Compute HMAC-SHA256 of the raw body with the stored ipn_token (or your whsec_ secret for the account webhook URL) and compare it to X-PayLio-Signature in constant time.
  3. Confirm the payment with GET /payment-status.
  4. Fulfil the order only once, even if the same event reaches you twice (retries and resends).
  5. Respond with 200 within 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#

RuleWhy
Must use https://Webhooks are never sent over plain HTTP.
Must resolve to a public IPlocalhost, private networks and cloud metadata hosts are blocked.
No user:password@ in the URLCredentials in URLs are rejected.
Max 2048 charactersLonger URLs fail validation.
Put an order reference in the path or query of the callback (e.g. /paylio/webhook?order=1042) to find the order faster. Allow PayLio's requests through your firewall, WAF or bot protection.