How it works
When you create a payment or cashout withcallbackUrl, Safefy sends an HTTP POST request to that URL whenever status reaches a relevant state.
For full domain-specific payloads, see:
Payment events
Cashout events
MED (dispute) events
Delivered through the webhooks registered in the dashboard (Webhooks), not throughcallbackUrl. Format, fields and
best practices in MED webhooks.
Sent headers
Signature
Every callback sent to yourcallbackUrl is signed with a secret unique to your account. Only Safefy and you
know it: a callback with a valid signature came from Safefy and was not changed on the way.
Where to get the secret
- In the Safefy dashboard, open Webhooks.
- In the Payment and payout callback signature box, click Show secret (“Mostrar segredo”).
- Store the value (it starts with
whsec_) on your server, for example in an environment variable. Never put it in a browser or mobile app.
How to validate
TheX-Safefy-Signature-V2 header looks like:
- Read the raw request body, exactly as received (before parsing JSON).
- Split
t(timestamp) andv1(signature) from the header. - Build the string
"{t}.{body}": the timestamp, a dot and the raw body. - Compute HMAC-SHA256 of that string with your secret, as lowercase hex.
- Compare it with
v1using a constant-time comparison. - Reject the callback if the signature does not match or if
tis more than 5 minutes away from your clock. This blocks replays of old callbacks. - Only then process the event.
Legacy signature (until 2026-10-29)
During the transition,X-Safefy-Signature is still sent as sha256={hex(HMAC-SHA256(key, body))}, where the key is
the paymentId (payment.* events) or the payoutId (cashout.* events). Do not use it in new integrations.
From 2026-10-29 only X-Safefy-Signature-V2 is sent.
Retries
If your endpoint does not return2xx, Safefy retries:
- Attempt 1 (immediate)
- Attempt 2 after ~2 seconds
- Attempt 3 after ~4 seconds
200 OK) and process asynchronously.
Idempotency
Because retries can happen, your webhook processing must be idempotent.- Recommended key:
id(delivery id) ordata.id + type - Ignore already-processed events
Quick example
Payment status flow
Understand the transaction lifecycle and when each webhook is fired:Best practices
Respond quickly
Return 200 OK immediately and process the webhook asynchronously.
Be idempotent
Use the webhook id to avoid processing the same event twice.
Validate the signature
Verify X-Safefy-Signature-V2 and reject callbacks older than 5 minutes before trusting the payload.
Use HTTPS
Configure your callbackUrl with HTTPS in production.