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 enabled to false.
  • 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

EventWhen
payment.succeededA collection or payout succeeded.
payment.failedA collection or payout failed. See failureCode.
payment.expiredA payment was not approved in time.
payment.reversedA reversal succeeded.
payment.reversal_failedA reversal was refused. The payment is SUCCEEDED again.

Refunds

EventWhen
refund.createdYou created a refund. Its status is pending.
refund.updatedA refund succeeded, or failed and the held money went back to your balance.

See Refunds. A refund's payout sends no payment.* events.

Customers

EventWhen
customer.createdA customer was created.
customer.updatedA customer was changed.
customer.balance.updatedA customer's credit balance changed. See Customer credit.
customer.entitlements.updatedThe limits of a customer's features changed because a plan change took effect. The object carries the previous and the current limits.

Subscriptions

EventWhen
customer.subscription.createdA subscription was created.
customer.subscription.updatedA subscription was changed.
customer.subscription.trial_will_endA subscription's trial ends soon.
customer.subscription.deletedA subscription's access ended because it was not paid.
customer.subscription.canceledA subscription was canceled.

Invoices and credit notes

EventWhen
invoice.createdAn invoice was created.
invoice.paidAn invoice was paid.
invoice.updatedA 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.voidedAn invoice was voided.
invoice.upcomingA 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.overdueA 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_mismatchedA payment for an invoice did not match the amount due.
invoice.payment_reversedA 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.overpaidA payment the customer's subscription cannot use became the customer's refundable credit. See Customer credit.
credit_note.createdA credit note was issued against an invoice.

Checkout sessions

EventWhen
checkout.session.completedA checkout session was paid.
checkout.session.expiredA checkout session expired without a payment.
checkout.session.reversedThe payment that completed a checkout session was reversed. The payment's own reversal arrives as payment.reversed.
checkout.session.payment_mismatchedA payment for a checkout session did not match the amount due.
checkout.session.payment_duplicatedA 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" }
    }
  }
}
FieldMeaning
idThe event's ID.
apiVersionThe version of your endpoint, which the event is written in.
typeWhat happened.
createdWhen it happened, in UTC.
livemodefalse for test and true for live.
data.objectThe 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:

HeaderValue
X-Webhook-Signaturet=<unix seconds>,v1=<signature>. Check it before you act on the event.
X-Webhook-Event-IdThe event's id.
X-Webhook-Event-TypeThe 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:

  1. Split X-Webhook-Signature on ,. Take the value of t (a unix timestamp) and every value of v1. Ignore any other part.
  2. Compute HMAC-SHA256 of the string <t>.<raw body>, keyed with your endpoint's whole secret (whsec_…), as lower-case hex.
  3. Compare it with each v1 in constant time. Accept the event if any one matches. If none does, answer 400 and ignore the event.
  4. Reject events whose t is 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)) <= tolerance

Rotate 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 2xx within 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 id you have handled.
  • Events can arrive out of order. Act on the object's status, not on the order events came in.

On this page