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

# Purchases

These webhooks are sent anytime Thanx detects a qualifying user purchase.

<Note>
  **Duplicate deliveries are expected.** A single purchase can trigger this
  webhook multiple times — the same `id` is re-sent as the purchase is processed
  through authorization and settlement, and across payment rails. Delivery is
  not exactly-once (best-effort, with duplicates expected). Deduplicate by `id`
  and treat repeat deliveries for an `id` as updates. Because `amount` and
  `products` may be refined between deliveries, prefer the values from the last
  delivery you receive for a given `id`.
</Note>

### Payload Description

<ParamField body="id" type="string">
  The ID of the purchase record in Thanx
</ParamField>

<ParamField body="user" type="hash">
  User information

  <Expandable title="user">
    <ParamField body="id" type="string">
      The ID of the user record in Thanx
    </ParamField>

    <ParamField body="email" type="string">
      The user's email. This value may not be present.
    </ParamField>

    <ParamField body="first_name" type="string">
      The user's first name. This value may not be present.
    </ParamField>

    <ParamField body="last_name" type="string">
      The user's last name. This value may not be present.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="merchant" type="hash">
  Merchant information

  <Expandable title="merchant">
    <ParamField body="id" type="string">
      The ID of the merchant record in Thanx
    </ParamField>

    <ParamField body="name" type="string">
      The name of the merchant
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="location" type="hash">
  Location information

  <Expandable title="location">
    <ParamField body="name" type="string">
      The location name or category
    </ParamField>

    <ParamField body="id" type="string">
      The ID of the location record in Thanx, if permitted
    </ParamField>

    <ParamField body="street" type="string">
      The street address of the location, if permitted
    </ParamField>

    <ParamField body="city" type="string">
      The location's city, if permitted
    </ParamField>

    <ParamField body="state" type="string">
      The location's state, if permitted
    </ParamField>

    <ParamField body="zip" type="string">
      The location's zip code, if permitted
    </ParamField>

    <ParamField body="time_zone" type="string">
      The location's time zone, if permitted
    </ParamField>

    <ParamField body="latitude" type="string">
      The location's latitude, if permitted
    </ParamField>

    <ParamField body="longitude" type="string">
      The location's longitude, if permitted
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="purchased_at" type="string">
  Time the purchase was made in ISO8601-format
</ParamField>

<ParamField body="amount" type="string">
  The purchase amount, represented as a string to prevent precision issues commonly associated with floating point numbers on the receiving side. This value may be refined between the authorization and settlement deliveries for the same purchase `id`; prefer the value from the last delivery you receive.
</ParamField>

<ParamField body="order" type="hash">
  The order information, if this purchase reflects an online order

  <Expandable title="order">
    <ParamField body="id" type="string">
      The order ID in the provider's system
    </ParamField>

    <ParamField body="provider" type="enum">
      (`OLO`, `Toast`, `Other`)
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="products" type="array(string)">
  <Warning>
    By default, these webhooks are sent 10 minutes after a purchase record is
    initially captured by the Thanx platform (usually initially from the credit
    card networks or ordering providers). Due to the nature of how Thanx collects
    item-level data, this data may not always be captured by Thanx by the time
    this webhook is sent out. If the purchase is digital (placed via Thanx-managed
    ordering experiences), this attribute will be populated. If the purchase is
    an in-store purchase, this attribute may not be populated depending on how
    quickly the webhook is configured to send.

    This data can be collected by working with the Thanx team to adjust the
    webhook latency, send an additional webhook at the time of item matching,
    or looked up via other mechanisms.

    Because of this, later deliveries for the same purchase `id` may include
    products that earlier deliveries omitted; treat the last delivery you
    receive as the most complete.
  </Warning>

  The list of products the user bought
</ParamField>

<ResponseExample>
  ```json theme={null}
  {
    "purchase": {
      "id": "92b7b0dac4",
      "user": {
        "id": "weori235",
        "email": "bob@bob.com",
        "first_name": "Bob",
        "last_name": "McBob"
      },
      "merchant": {
        "id": "9a1f0772c9ac",
        "name": "Pizza Shack"
      },
      "location": {
        "id": "e7183da044",
        "name": "Pizza Shack 12",
        "street": "123 Pizza Lane",
        "city": "Smalltown",
        "state": "CA",
        "zip": "12345",
        "time_zone": "America/New_York",
        "latitude": "37.76271750294678",
        "longitude": "-122.42438230349147"
      },
      "purchased_at": "2020-01-01T20:00:00Z",
      "amount": "9.99",
      "order": {
        "id": "RTF234S",
        "provider": "OLO"
      },
      "products": ["Snickers", "Twix"]
    }
  }
  ```

  ```json Mall-specific Response theme={null}
  {
    "purchase": {
      "id": "92b7b0dac4",
      "user": {
        "id": "weori235",
        "email": "bob@bob.com"
      },
      "merchant": {
        "id": "9a1f0772c9ac",
        "name": "The Best Mall Ever"
      },
      "location": {
        "name": "Food"
      },
      "purchased_at": "2020-01-01T20:00:00Z",
      "amount": "9.99",
      "order": {},
      "products": []
    }
  }
  ```
</ResponseExample>
