Webhooks API
You can receive real-time notifications about platform events by configuring webhook endpoints via APIs. You can create multiple webhook endpoints per entity; each endpoint has its own URL, signing secret, and event type subscription allowlist (event_types). Only events whose type is in that allowlist are delivered to the endpoint (when the endpoint is active). All webhook endpoints must use HTTPS URLs that accept POST requests with JSON payloads. Use the APIs to create, list, get, update (PATCH), delete, and toggle activation. Use GET /api/webhooks/event-types for the catalog of subscribeable event types when building create or edit forms.
Event Structure
Every webhook event follows this structure:
Example payin event:
Example subaccount credit event (data includes both amount_cents and amount_in_minor_units; values match for USD):
Each event includes:
-
id: Unique identifier that remains constant across retries -
type: Description of the event -
data: Object containing event-specific information
Available Event Types
The following events are currently available:
Payout Events:
payout.debited: Triggered when funds are debited from the sender’s accountpayout.settled: Triggered when the payout is successfully settled to the recipientpayout.failed: Triggered when a payout fails during processing
Payin Events:
payin.settled: Triggered when a payin is successfully settled and funds are receivedpayin.failed: Triggered when a payin fails during processing
Subaccount Events:
subaccount.credit_received: Triggered when an inbound credit is received on a virtual subaccount. Thedataobject containssubaccount_id,amount_cents(legacy), andamount_in_minor_units(same value asamount_centsfor USD today).
Each payout event contains a data object with a payout_id field containing the UUID of the relevant payout.
Each payin event contains a data object with a payin_id field containing the UUID of the relevant payin.
Security and Authentication
To verify webhook authenticity, each payload is signed with a signature passed in the X-Webhook-Signature header. This signature is an HMAC SHA-256 hash, using your endpoint’s signing secret as the key and the content as:
where the timestamp is included in the header as X-WEBHOOK-TIMESTAMP.
Warning: Use raw webhook payloads for signature verification. Any modification (such as prettifying or serializing) will result in signature mismatches.
Python Signature Validation Example
Here’s how to validate webhook signatures in Python:
Delivery and Retry Mechanism
A successful delivery requires:
-
A
2XXHTTP response within 10 seconds. -
Returning the response immediately, then processing the event asynchronously.
-
Idempotent event processing to handle potential duplicates.
Managing Webhook Security
Protect your endpoint’s signing secret. If it is compromised:
-
Create a new endpoint with the same URL and event types.
-
Update your system with the new secret.
-
Delete the old endpoint.
We will continue sending events to the old endpoint until you delete it, after which we will switch to the new one.