Webhooks
Get payment, billing and checkout events on your server as they happen.
Register an endpoint
Call Create a webhook endpoint with a public
https URL and the events you want. Store the secret in the response: it is shown once.
Register once with a test key and once with a live key. Each mode allows 16 endpoints.
- To move an endpoint, update its URL. The secret stays the same.
- To pause it, set
enabledtofalse. - To remove it, delete it.
Subscribe to * to get every event, including ones added later. * cannot be combined with other events.
subscribedEvents comes back in the order you sent it, and a name you send twice is kept once. A name that is not an
event is refused with 400, the code parameter_invalid and param set to subscribedEvents. The message lists every
event you can subscribe to.
Endpoint versions
An endpoint has an apiVersion. It is the version you give when you create it, or else the version of the request that
created it. Its events are written in that version, and your default version does not change it. Only
Update a webhook endpoint changes it, and a version
that does not exist is refused with 400 and the code api_version_invalid. See Versioning.
Events
Payments
| Event | When |
|---|---|
payment.succeeded | A collection or payout succeeded. |
payment.failed | A collection or payout failed. See failureCode. |
payment.expired | A payment was not approved in time. |
payment.reversed | A reversal succeeded. |
payment.reversal_failed | A reversal was refused. The payment is SUCCEEDED again. |
Refunds
| Event | When |
|---|---|
refund.created | You created a refund. Its status is pending. |
refund.updated | A refund succeeded, or failed and the held money went back to your balance. |
See Refunds. A refund's payout sends no payment.* events.
Customers
| Event | When |
|---|---|
customer.created | A customer was created. |
customer.updated | A customer was changed. |
customer.balance.updated | A customer's credit balance changed. See Customer credit. |
customer.entitlements.updated | The limits of a customer's features changed because a plan change took effect. The object carries the previous and the current limits. |
Subscriptions
| Event | When |
|---|---|
customer.subscription.created | A subscription was created. |
customer.subscription.updated | A subscription was changed. |
customer.subscription.trial_will_end | A subscription's trial ends soon. |
customer.subscription.deleted | A subscription's access ended because it was not paid. |
customer.subscription.canceled | A subscription was canceled. |
Invoices and credit notes
| Event | When |
|---|---|
invoice.created | An invoice was created. |
invoice.paid | An invoice was paid. |
invoice.updated | A payment you recorded paid part of an open invoice, or autoAdvance changed on an open invoice. The invoice stays open. amountRemaining is what is still to pay. See Record a payment. |
invoice.voided | An invoice was voided. |
invoice.upcoming | A subscription renews in renewalNoticeDays days. The object is a preview of the renewal invoice, with no ID, number or pay link. See Renewals and days to pay. |
invoice.overdue | A renewal invoice is unpaid at its due date, which is when the subscription expires. The change to past_due at the period end arrives as customer.subscription.updated. |
invoice.payment_mismatched | A payment for an invoice did not match the amount due. |
invoice.payment_reversed | A payment on an invoice was reversed and the money went back to the customer. The object is the invoice with paymentReversedAt and the reversed paymentId. The invoice and the subscription keep their status: cancel the subscription with atPeriodEnd: false if access should stop. See Refunds. |
invoice.overpaid | A payment the customer's subscription cannot use became the customer's refundable credit. See Customer credit. |
credit_note.created | A credit note was issued against an invoice. |
Checkout sessions
| Event | When |
|---|---|
checkout.session.completed | A checkout session was paid. |
checkout.session.expired | A checkout session expired without a payment. |
checkout.session.reversed | The payment that completed a checkout session was reversed. The payment's own reversal arrives as payment.reversed. |
checkout.session.payment_mismatched | A payment for a checkout session did not match the amount due. |
checkout.session.payment_duplicated | A checkout session was paid more than once. |
Checkout sessions are for one-time payments and new subscriptions. An invoice is paid through its pay link, and you get the invoice.* events for it, not the checkout.session.* events. See Pay invoices.
Payload
Every event has the same envelope:
{
"id": "4b1d7c2e-9f3a-4e6b-8c5d-2a1f0e9d8c7b",
"apiVersion": "2026-11-06",
"type": "payment.succeeded",
"created": "2026-09-28T09:15:42Z",
"livemode": false,
"data": {
"object": {
"id": "0b6f3c1e-8f2a-4a51-9a57-6d1f0c2b7e93",
"status": "SUCCEEDED",
"kind": "COLLECTION",
"payment_method_details": {
"type": "mobile_money",
"mobile_money": { "network": "mpesa", "phone": "25574*****11" }
},
"amount": 10000,
"fee": 150,
"currency": "TZS",
"merchantReference": "order-1042",
"metadata": { "orderId": "1042" }
}
}
}| Field | Meaning |
|---|---|
id | The event's ID. |
apiVersion | The version of your endpoint, which the event is written in. |
type | What happened. |
created | When it happened, in UTC. |
livemode | false for test and true for live. |
data.object | The object the event is about, as it was when the event happened. |
Amounts in an event are integers in the minor unit. See Money. Events are never expanded. For anything
not in data.object, retrieve the payment or the other object.
Each event is a POST with these headers:
| Header | Value |
|---|---|
X-Webhook-Signature | t=<unix seconds>,v1=<signature>. Check it before you act on the event. |
X-Webhook-Event-Id | The event's id. |
X-Webhook-Event-Type | The event's type. |
The signature covers the body only, so deduplicate on the body's id and act on the body's type.
Check the signature
Anyone can send a request to your URL, so check every event's signature before you act on it:
- Split
X-Webhook-Signatureon,. Take the value oft(a unix timestamp) and every value ofv1. Ignore any other part. - Compute HMAC-SHA256 of the string
<t>.<raw body>, keyed with your endpoint's whole secret (whsec_…), as lower-case hex. - Compare it with each
v1in constant time. Accept the event if any one matches. If none does, answer400and ignore the event. - Reject events whose
tis more than five minutes old, so a captured request cannot be replayed later.
After you rotate your secret, events carry two v1 values for a while, one per secret. Check
them all.
Use the raw body exactly as received. Parsing and serialising it again breaks the signature.
Verify with the steps above. A webhook library built for another signature format cannot verify these events.
import hashlib
import hmac
import time
def verify(raw_body: bytes, signature_header: str, secret: str, tolerance: int = 300) -> bool:
timestamp, signatures = None, []
for part in signature_header.split(","):
key, _, value = part.partition("=")
if key == "t":
timestamp = value
elif key == "v1":
signatures.append(value)
if timestamp is None or not signatures:
return False
signed = f"{timestamp}.".encode() + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
matches = any(hmac.compare_digest(expected, signature) for signature in signatures)
return matches and abs(time.time() - int(timestamp)) <= toleranceRotate your secret
Call Rotate a webhook endpoint's secret and
deploy the new secret. The old one keeps working for 24 hours, or for oldSecretValidForHours (0 to 24, where 0 stops
it at once).
Respond and retry
- Answer
2xxwithin 10 seconds, then do the work. A redirect, any other status, a timeout or no answer counts as a failed delivery. - A failed delivery is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 24 hours and 48 hours. That is 8 attempts in all. Every retry sends the same body.
- After 20 deliveries in a row fail all their attempts, the endpoint is switched off and you get an email. Switch it back on with Update a webhook endpoint.
- You can get an event twice. Skip any
idyou have handled. - Events can arrive out of order. Act on the object's
status, not on the order events came in.