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
| Event | When |
|---|---|
conversion.completed / conversion.canceled / conversion.failed | The conversion moved to that status. |
withdrawal.created / withdrawal.sent / withdrawal.completed / withdrawal.failed / withdrawal.canceled | The withdrawal was created, sent (USDT, balance debited), completed, failed (USDT, amount back in balance) or canceled. |
deposit.paid / deposit.divergent | The Pix charge was paid (or paid with a different amount). |
balance.credited | Other balance credits, such as Pix on the permanent code or a manual credit. |
transfer.pending / transfer.sent / transfer.rejected / transfer.canceled | The transfer you sent is awaiting approval, was completed (balance debited), rejected or canceled. |
transfer.received | Another 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
2xxwithin 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 markedfalhou. Redirects are not followed. - Delivery is at least once: deduplicate by the event
id. - Arrival order is not guaranteed. Use the resource's current
statusas 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. :::
- Node.js
- Python
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"));
}
import hmac, hashlib, time
def verify(secret: str, raw_body: bytes, header: str) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
if abs(time.time() - int(parts["t"])) > 300:
return False
expected = hmac.new(secret.encode(), parts["t"].encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts["v1"])
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.