RASPAY

Webhooks

Receive events in real time and verify the signature.

Webhooks notify your server when something happens. Register HTTPS endpoints in the dashboard, under Developers, on the Webhooks screen, and choose the events of each one. On charges and payouts, the optional field webhookUrl sends the events of that resource to one more URL, with the same secret.

id identifies the event, and data is the full resource at the time of the event, in the same format as the API.

POST to your URL
{
  "id": "3f0a7d7c-52ce-4c2b-8f0e-1a6d9b2e4c11",
  "type": "charge.paid",
  "livemode": true,
  "createdAt": "2026-11-01T15:06:12.000Z",
  "data": {
    "id": "7c1e4f2a-3b58-4e0d-9a6c-2f8d1b7e5a10",
    "object": "charge",
    "livemode": true,
    "status": "paid",
    "amount": 15000,
    "fee": 299,
    "net": 14701,
    "currency": "BRL",
    "reference": "ORDER-0001",
    "description": "Annual plan",
    "customer": {
      "name": "Ana Souza",
      "document": "12345678909",
      "email": "ana@example.com"
    },
    "metadata": {
      "order": "0001"
    },
    "pix": {
      "copyPaste": "0002...",
      "qrCodeBase64": "iVBOR..."
    },
    "checkoutUrl": "https://dashboard.example.com/pay/7c1e4f2a-3b58-4e0d-9a6c-2f8d1b7e5a10",
    "payer": null,
    "beneficiary": null,
    "endToEndId": null,
    "ispb": null,
    "failureReason": null,
    "paidAt": "2026-11-01T15:06:12.000Z",
    "refundedAt": null,
    "createdAt": "2026-11-01T15:04:05.000Z"
  }
}

Events

EventWhen
charge.createdCharge created, with the Pix available.
charge.paidPayment confirmed and balance credited.
charge.refundedPix refunded and balance debited.
charge.disputedPix entered MED (the Central Bank dispute mechanism): the amount moved from available to held. It carries dispute with status, amount and whatever the institution reports about the MED: id, reason, reportedBy (payer_bank or receiver_bank), openedAt, closedAt and returnedAmount. What is not reported is null.
charge.dispute_releasedMED closed without a return: the amount went back from held to available, with the same dispute and status released. If there is a return, you get charge.refunded with dispute.status refunded.
payout.createdPayout created and amount held.
payout.paidPayout completed.
payout.failedPayout failed, was rejected or canceled, and the held amount went back to the balance. See status and failureReason.
payout.returnedA paid payout that the receiving bank sent back. The returned amount (returnedAmount, in cents) went back to your balance; the fee is not returned. The payout stays paid. A return can be partial and come in parts: each credited part sends its own payout.returned with that part's amount, and the total never exceeds the payout amount. Sent whenever a return is credited, automatically or by our team.
test.pingSent by the test button in the dashboard. Has empty data.
webhook.pingSent periodically when the ghost webhook is active. Carries data.ghost = true; it keeps the endpoint and the integration alive.

Verify the signature

Every delivery has these headers. Verify the signature before using the content, because your URL is public and anyone can call it.

HeaderContent
X-Webhook-IdEvent ID. It is the same on retries.
X-Webhook-Signaturet=<timestamp>,v1=<signature>

The signature is the hexadecimal HMAC-SHA256 of <t>.<raw body>, using the whsec_ secret of the environment, available in the dashboard.

  • Compute it over the body exactly as received, before any parsing.
  • Compare in constant time.
  • Refuse a t more than 5 minutes off, to prevent replay of captured messages. Each attempt carries a new t.
import crypto from 'node:crypto';
import express from 'express';

const app = express();
const TOLERANCE = 300;

function verify(rawBody, header, secret) {
  const parts = Object.fromEntries(
    String(header ?? '').split(',').map((item) => item.split('=', 2)),
  );
  const { t, v1 } = parts;
  if (!t || !v1 || Math.abs(Date.now() / 1000 - Number(t)) > TOLERANCE) {
    throw new Error('missing or expired signature');
  }
  const expected = crypto.createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest();
  const received = Buffer.from(v1, 'hex');
  if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected)) {
    throw new Error('invalid signature');
  }
  return JSON.parse(rawBody.toString('utf8'));
}

// The body must arrive raw: re-serialized JSON invalidates the signature.
app.post('/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
  let event;
  try {
    event = verify(req.body, req.headers['x-webhook-signature'], process.env.WEBHOOK_SECRET);
  } catch {
    return res.sendStatus(400);
  }

  res.sendStatus(200);
  enqueue(event); // process after responding
});

Retries

A delivery only counts as received with a 2xx response within 10 seconds. Redirects are not followed and count as a failure. After a failure, we send again at these intervals:

Retry1st2nd3rd4th5th6th
Wait1 min5 min30 min2 h6 h24 h

After the 6th retry the delivery stops. The dashboard shows each delivery and lets you resend it manually.

Best practices

  • Respond 200 immediately and process in a queue.
  • Use the event id to ignore duplicates: delivery is at least once.
  • Do not depend on the order of arrival. Before releasing an order, if you want extra assurance, call GET /v1/charges/{id}.
  • Check the livemode field so that test events are not mixed with live ones.
  • Endpoints must use HTTPS and cannot point to internal addresses.