# Webhooks that bring every sale into your system

> Get sales, refunds, renewals and funnel events by webhook in any system that accepts HTTP, with a log of every delivery and automatic retries.

Page: https://www.snappcheckout.com/en/webhooks

The Snapp webhook sends a JSON POST to the URL you choose for every approved sale. It can also notify you of refunds, chargebacks, every subscription event and the funnel steps before the purchase. It works with any system that accepts HTTP.

## Account webhooks and offer webhooks

In Integrations, you add webhooks with a name, URL and authentication token and choose which offers use each one. A saved webhook can be used in as many offers as you want.

If you prefer, add the URL and token directly in the offer, on the Integration tab. An offer can have more than one webhook, and each has its own event options.

## Which events you get

Every approved sale arrives as `purchase.approved`, whether it's a one-time purchase or the first charge of a subscription. The other events are optional and you turn them on per webhook:

- **Refunds and chargebacks.** A refunded one-time sale, a lost chargeback and a dispute opened or won. Turn this on only if your system reads the `event` field, otherwise a refund could be treated as a new sale.
- **Subscription events.** Paid or declined renewal, billing abandoned by the gateway, cancellation, expiration, and refund or chargeback on a billing cycle.
- **Sales + full tracking.** Also sends the funnel events, for tracking tools.

| Event | When it arrives | Option |
|---|---|---|
| `purchase.approved` | Purchase approved | Always |
| `purchase.refunded` | One-time sale refunded | Refunds and chargebacks |
| `purchase.chargeback` | Chargeback lost on a one-time sale | Refunds and chargebacks |
| `purchase.dispute_opened` | Dispute opened on a one-time sale | Refunds and chargebacks |
| `purchase.dispute_won` | Dispute won by the seller | Refunds and chargebacks |
| `subscription.renewed` | Renewal paid | Subscription events |
| `subscription.renewal_failed` | Renewal declined, with the gateway still retrying | Subscription events |
| `subscription.unpaid` | The gateway stopped retrying | Subscription events |
| `subscription.canceled` | Canceled by the buyer, by you or by the gateway | Subscription events |
| `subscription.expired` | End of the contracted billing cycles | Subscription events |
| `subscription.refunded` | Refund on a billing cycle | Subscription events |
| `subscription.chargeback` | Reversal or dispute on a billing cycle | Subscription events |
| `checkout.viewed` | Checkout visit, once per session every 24 hours | Sales + full tracking |
| `checkout.initiated` | Buyer filled in name, email and phone | Sales + full tracking |
| `payment.pending` | Pix or boleto generated and not yet paid | Sales + full tracking |
| `payment.failed` | Payment declined at purchase, sent within 1 minute | Sales + full tracking |
| `cart.abandoned` | Buyer left their email and didn't buy within 30 minutes | Sales + full tracking |

To grant or block a subscriber's plan, read `subscription.active`. It arrives as `true` on a paid renewal and `false` when the gateway stops billing.

## What's in the JSON

Each delivery is a POST with `Content-Type: application/json`. If you add a token, it goes in the `Authorization` header as `Bearer`. With Sign requests turned on, each delivery also carries an HMAC signature in the `X-Snapp-Signature` header.

- **`event` and `eventId`.** The first says what happened. The second is unique per occurrence and lets you ignore repeated deliveries.
- **`customer`.** The buyer's name, email, phone, tax ID, country, IP and address.
- **`offer`, `product`, `orderBumps` and `items`.** What was purchased, with the product's custom ID (`customId`) when you set one.
- **`amount` and `payment`.** Amount, currency, payment method and gateway.
- **`tracking`.** `src`, `sck`, UTMs, click IDs and campaign data.
- **`subscription`, `failure`, `refund` and `cancellation`.** Filled in when they apply and sent as `null` when they don't, so the format is the same for every event.
- **`isUpsell` and `isDownsell`.** Tell you whether the sale came from the [upsell](https://www.snappcheckout.com/en/upsell-and-order-bump) funnel.

Funnel events carry the `offer`, `customer`, `amount` and `tracking` blocks, with UTMs, click IDs, `fbp`, `fbc`, user agent and `sessionId`. In the offer, the Data sent button shows a sample of the JSON.

The [webhook reference](https://www.snappcheckout.com/docs/webhooks) describes every field, every event and the gateways that trigger each one, with JSON examples and code for receiving deliveries.

## A log of every delivery

Each delivery is listed on the Events page with the status Success, Failed or Retrying. At the top you see the total, deliveries not counting retries, successes, failures and those being retried. You can filter by period, event type, offer and customer name or email, and open each delivery to see the JSON that went out.

A delivery fails when the response doesn't have a 2xx status or doesn't arrive within 30 seconds. When that happens, Snapp retries up to 3 times: about 30 minutes after the failure, then 1 hour later and then 6 hours after that. If your URL responded with 429, the first retry goes out after 2 minutes.

You can also resend any event from the dashboard. The resend goes to the original destination and is logged as a new event. The log is kept for 90 days. Checkout visits (`checkout.viewed`) don't appear on the Events page and aren't resent.

## Ready-made integrations

Some tools don't need a webhook at all:

- **UTMify** gets your sales, plus refunds and chargebacks.
- **vTurb** gets the conversion for each paid sale that carries the conversion key (`src` or `sck`) in the checkout URL.
- **Discord.** The Snapp bot adds the buyer to your server with the offer's role and removes the role after a full refund, a chargeback or the end of the subscription.
- **Pixel and Conversions API** for Meta, plus TikTok, Google Ads and Taboola.
- **Resend**, so checkout emails go out from your own sender address.

Deliveries to UTMify, vTurb and the Meta, TikTok and Taboola conversion APIs also show up on the Events page.

## Frequently asked questions

### Does it work with any automation tool?

It works with any system that accepts a JSON POST over HTTP. Paste the URL the tool generates and, if it asks for one, the token.

### How do I know the delivery came from Snapp?

Add an authentication token to the webhook. Snapp sends the token in the `Authorization` header, and your system checks it before accepting the request.

### Does the webhook fire on every subscription renewal?

Only if you turn on Subscription events. With it off, the webhook fires only on the first sale, and renewals don't arrive as new sales.

### How do I avoid processing the same sale twice?

Store the `eventId`. It's unique per occurrence, so a repeated delivery arrives with the same value and can be ignored.

### What if my system is down?

The delivery is marked as failed and Snapp retries up to 3 times. After that, you can resend it from the Events page.

### How do I test the webhook before selling?

Generate a test purchase in the offer. The link runs through the complete checkout with the automations, without a real charge, and is valid for 5 minutes.
