Skip to main content

Webhooks

Register up to 5 URLs (https, port 443) with POST /v1/webhooks or in the Portal, choosing the events (or "*" for all):

curl -X POST https://api-sandbox.rivusfinance.com/v1/webhooks \
-H "Authorization: Bearer $RIVUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://api.yourcompany.com/webhooks/rivus", "events": ["deposit.paid", "withdrawal.completed"] }'

The response includes the signing secret only once. Store it: you use it to validate every delivery. To rotate it, use POST /v1/webhooks/{id}/rotate-secret (the previous secret stops working immediately).

Events​

EventWhen
conversion.completed / conversion.canceled / conversion.failedThe conversion moved to that status.
withdrawal.created / withdrawal.sent / withdrawal.completed / withdrawal.failed / withdrawal.canceledThe withdrawal was created, sent (USDT, balance debited), completed, failed (USDT, amount back in balance) or canceled.
deposit.paid / deposit.divergentThe Pix charge was paid (or paid with a different amount).
balance.creditedOther balance credits, such as Pix on the permanent code or a manual credit.
transfer.pending / transfer.sent / transfer.rejected / transfer.canceledThe transfer you sent is awaiting approval, was completed (balance debited), rejected or canceled.
transfer.receivedAnother client transferred funds to you (balance credited).

Delivery format​

Each delivery is a JSON POST. data has the same format as the resource in the API:

{
"id": "0f8e7d6c-5b4a-4392-8170-6f5e4d3c2b1a",
"type": "deposit.paid",
"created_at": "2026-11-09T14:03:11.000Z",
"data": { "id": "…", "status": "pago", "amount_brl": 250 }
}

Headers sent: Rivus-Signature, Rivus-Event-Id and Rivus-Event-Type.

Delivery and retries​

  • Respond with any 2xx within 10 seconds. Otherwise it is retried after 1 min, 5 min, 30 min, 2 h, 5 h, 10 h and 12 h; after that the delivery is marked falhou. Redirects are not followed.
  • Delivery is at least once: deduplicate by the event id.
  • Arrival order is not guaranteed. Use the resource's current status as the source of truth.
  • The delivery history for the last 30 days is at GET /v1/webhooks/{id}/deliveries.

Validating the signature​

Rivus-Signature: t=<unix>,v1=<hex>, where v1 = HMAC-SHA256(secret, "<t>.<raw body>"). Reject it if |now − t| > 300 s.

:::warning Use the raw body Compute the HMAC over the exact bytes received, before parsing the JSON. Re-serializing the JSON changes the bytes and breaks the signature. :::

const crypto = require("crypto");

function verify(secret, rawBody, header) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
const expected = crypto.createHmac("sha256", secret).update(parts.t + "." + rawBody).digest("hex");
return crypto.timingSafeEqual(Buffer.from(expected, "hex"), Buffer.from(parts.v1, "hex"));
}

Testing​

POST /v1/webhooks/{id}/test immediately sends a signed ping event to the URL and returns the result, with no retries. Use it to validate your implementation.