> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upstackdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook

> Send Upstack events to your own HTTPS endpoint as one JSON POST per event, with an optional signature you can check.

> [!NOTE]
>
> **Data direction:** This is a **destination** — Upstack sends event and conversion data **out** to this platform via server-side APIs.

## How do I send Upstack events to my webhook URL?

1. In Upstack, click **Destinations** in the sidebar.
2. Under **Available destinations**, find **Webhook** and click **Connect**.
3. In **Webhook URL**, paste your endpoint. It must start with `https://`.
4. Optional: in **Signing Secret**, enter a secret. Upstack then signs every request. See [How do I check that a request came from Upstack?](#how-do-i-check-that-a-request-came-from-upstack)
5. Click **Create Destination**.

## Which URLs can I use?

A public address that starts with `https://` and answers without a redirect.

| URL | Accepted |
| - | - |
| `https://hooks.example.com/upstack` | Yes |
| `http://hooks.example.com/upstack` | No, it must be HTTPS |
| `https://localhost/upstack` or `https://127.0.0.1/upstack` | No, it points at your own machine |
| `https://10.0.0.5/upstack` or `https://192.168.1.20/upstack` | No, it is a private network address |
| A host name that resolves to a private address | Saved, but every request fails |

## Which events does Upstack send?

These events are sent by default, under their Upstack names:

| Group | Events |
| - | - |
| Store | `page_view`, `view_content`, `view_category`, `add_to_cart`, `view_cart`, `initiate_checkout`, `add_shipping_info`, `add_payment_info`, `purchase`, `subscription_recurring_purchase`, `refund` |
| Accounts and sign-ups | `account_created`, `account_deleted`, `signed_out`, `signup_started`, `signup_completed`, `content_downloaded`, `webinar_registered`, `demo_requested` |
| Trials | `trial_started`, `trial_activated`, `trial_extended`, `trial_ending_soon`, `trial_expired`, `trial_converted` |
| Subscriptions | `subscription_started`, `subscription_created`, `subscription_initial_purchase`, `subscription_upgraded`, `subscription_downgraded`, `subscription_paused`, `subscription_resumed`, `subscription_cancelled`, `subscription_churned`, `subscription_reactivated` |
| Payments and orders | `payment_succeeded`, `payment_failed`, `payment_refunded`, `invoice_created`, `invoice_paid`, `invoice_past_due`, `order_fulfilled`, `order_shipped` |

* To send another event, see [How do I send an event that is not on the list?](#how-do-i-send-an-event-that-is-not-on-the-list)

## How do I send an event that is not on the list?

Add a custom trigger. Upstack sends it with the event name you choose.

1. In Upstack, click **Destinations**, then click your webhook destination.
2. Click the **Event Mappings** tab.
3. Click **Add Custom Trigger**.
4. Fill in **Display name**, **Base event**, and **Destination event name**. Your endpoint receives the **Destination event name** as `eventName`.
5. Click **Save custom event**.
6. Click **Save Changes**.

Full walkthrough: [Destination event mappings](https://docs.upstackdata.com/guides/custom-events/destination-event-mappings.md)

## What does each request look like?

Each event is one `POST` with a JSON body.

| Header | Value |
| - | - |
| `Content-Type` | `application/json` |
| `X-Upstack-Timestamp` | Send time in Unix seconds, for example `1764687845` |
| `X-Upstack-Signature` | `sha256=` and a hex signature. Sent only when the destination has a **Signing Secret** |

Example body for a purchase:

```json theme={null}
{
  "type": "event",
  "eventName": "purchase",
  "id": "px-1_5521873969321",
  "time": "2026-12-02T15:04:05.000Z",
  "user_data": {
    "externalId": "b6f1c2e0-3d4a-4f5e-9a1b-2c3d4e5f6a7b",
    "email": "jane@example.com",
    "phone": "+15555550123",
    "firstName": "Jane",
    "lastName": "Doe",
    "location": {
      "address1": "1 Main St",
      "city": "Austin",
      "region": "TX",
      "zip": "78701",
      "country": "US",
      "ip": "203.0.113.7"
    }
  },
  "data": {
    "value": 64.5,
    "currency": "USD",
    "transactionId": "5521873969321",
    "subtotalPrice": 59,
    "tax": 4.5,
    "shipping": 5,
    "items": [
      {
        "id": "8812",
        "name": "Cotton Tee",
        "sku": "TEE-BLK-M",
        "variant": "44120",
        "price": 29.5,
        "quantity": 2
      }
    ]
  }
}
```

Every field is listed in [Which fields can a request contain?](#which-fields-can-a-request-contain).

## Which fields can a request contain?

Only these fields. A field with no value is left out, so every field below can be missing. `user_data` and `data` are always sent, even when empty.

**Top level**

| Field | Type | What it holds |
| - | - | - |
| `type` | Text | Always `event` |
| `eventName` | Text | The Upstack event name, such as `purchase`, or the **Destination event name** of a custom trigger |
| `id` | Text | The event ID. It stays the same when Upstack retries. Custom trigger events start with `custom_` |
| `time` | Text | When the event happened, in ISO 8601 UTC, for example `2026-12-02T15:04:05.000Z` |
| `user_data` | Object | The visitor. See below |
| `data` | Object | The event details. See below |

**`user_data`**

When Upstack has no email, phone or address for the visitor, `user_data` holds `externalId` only.

| Field | Type | What it holds |
| - | - | - |
| `externalId` | Text | The Upstack visitor ID |
| `email` | Text | The first email Upstack has for the visitor |
| `phone` | Text | The first phone number Upstack has for the visitor |
| `firstName` | Text | First name, from the visitor's first address |
| `lastName` | Text | Last name, from the visitor's first address |
| `location` | Object | The visitor's first address and IP address. See below |

**`user_data.location`**

| Field | Type | What it holds |
| - | - | - |
| `address1` | Text | Street address |
| `address2` | Text | Apartment, suite or unit |
| `city` | Text | City |
| `region` | Text | State or province code, such as `TX` |
| `zip` | Text | Postal code |
| `country` | Text | Country code, such as `US` |
| `ip` | Text | The visitor's IP address |

**`data`: value and orders**

| Field | Type | What it holds |
| - | - | - |
| `value` | Number | The event value. A custom trigger's value override replaces it |
| `currency` | Text | Currency code, such as `USD` |
| `transactionId` | Text | The order ID on purchase events |
| `orderId` | Text | The store's order ID |
| `orderName` | Text | The store's order name, such as `#1042` |
| `cartId` | Text | The cart ID |
| `subtotalPrice` | Number | Order subtotal |
| `tax` | Number | Tax |
| `shipping` | Number | Shipping cost |
| `discount` | Number | Discount amount |
| `coupon` | Text | Discount code |
| `paymentType` | Text | Payment method |
| `shippingTier` | Text | Shipping method |
| `affiliation` | Text | Store or affiliation name |
| `orderSourceName` | Text | Where the order was placed, such as `web` |
| `tags` | List of text | Order tags |
| `items` | List of objects | The products in the event. See below |

**`data.items`**

| Field | Type | What it holds |
| - | - | - |
| `id` | Text | Product ID |
| `name` | Text | Product name |
| `sku` | Text | SKU |
| `variant` | Text | Variant ID |
| `variantName` | Text | Variant name |
| `brand` | Text | Brand |
| `category` | Text | Category |
| `price` | Number | Unit price |
| `quantity` | Number | Quantity |
| `discount` | Number | Discount on this item |
| `url` | Text | Product page URL |
| `imageUrl` | Text | Product image URL |

**`data`: accounts, plans and subscriptions**

Sent on account, trial, subscription, payment and invoice events.

| Field | Type | What it holds |
| - | - | - |
| `accountId` | Text | Account ID |
| `accountName` | Text | Account name |
| `userId` | Text | User ID |
| `subscriptionId` | Text | Subscription ID |
| `invoiceId` | Text | Invoice ID |
| `planId` | Text | Plan ID |
| `planName` | Text | Plan name |
| `billingInterval` | Text | `day`, `week`, `month` or `year` |
| `mrr` | Number | Monthly recurring revenue |
| `arr` | Number | Annual recurring revenue |
| `mrrDelta` | Number | Change in monthly recurring revenue |
| `ltv` | Number | Lifetime value |
| `amount` | Number | Payment or invoice amount |
| `seatCount` | Number | Number of seats |
| `seatDelta` | Number | Change in seats |
| `addonId` | Text | Add-on ID |
| `addonName` | Text | Add-on name |
| `featureId` | Text | Feature ID |
| `featureName` | Text | Feature name |
| `milestoneId` | Text | Milestone ID |
| `milestoneName` | Text | Milestone name |
| `trialStartDate` | Text | Trial start date |
| `trialEndDate` | Text | Trial end date |
| `trialDaysRemaining` | Number | Days left in the trial |
| `inactiveDays` | Number | Days since the user was last active |
| `failureReason` | Text | Why a payment failed |
| `cancelReason` | Text | Why the subscription was cancelled |
| `cancelFeedback` | Text | Feedback given when cancelling |
| `cancelledAt` | Text | When the subscription was cancelled |

## How do I check that a request came from Upstack?

Recompute the signature with your **Signing Secret** and compare it with `X-Upstack-Signature`.

1. Read the raw request body before you parse the JSON.
2. Join the `X-Upstack-Timestamp` value, a dot, and the raw body.
3. Compute an HMAC-SHA256 of that text with your signing secret, as hex.
4. Put `sha256=` in front and compare it with `X-Upstack-Signature`. If they differ, reject the request.
5. To block replayed requests, also reject a timestamp more than 5 minutes old. Every retry gets a new timestamp and signature.

Example in Node.js:

```js theme={null}
import { createHmac, timingSafeEqual } from 'node:crypto';

function isFromUpstack(rawBody, headers, signingSecret) {
  const timestamp = headers['x-upstack-timestamp'];
  const digest = createHmac('sha256', signingSecret).update(timestamp + '.' + rawBody).digest('hex');
  const expected = Buffer.from('sha256=' + digest);
  const received = Buffer.from(headers['x-upstack-signature'] ?? '');
  return received.length === expected.length && timingSafeEqual(received, expected);
}
```

## What happens when my endpoint returns an error?

Upstack tries the event up to 3 more times, about a minute apart, then drops it.

| What your endpoint does | What Upstack does |
| - | - |
| Answers with a 2xx status | Counts the event as delivered |
| Answers with any other status, including a redirect | Tries again |
| Takes longer than 10 seconds to answer | Tries again |
| Cannot be reached | Tries again |

## Why did I get the same event twice?

Upstack sent it again after a failed try. A retry resends every request for that event, including ones your endpoint already accepted. Use `id` to drop events you have already processed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.