> ## 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.

# Get Purchases

> This section describes endpoints that enable a third party to fetch a user's purchases. This endpoint describes all available purchases.

<Note>
  Please review proper request headers [here](/consumer/usage/headers).
</Note>

### Parameters

<ParamField query="merchant_id" type="string">
  Only return purchases for this merchant
</ParamField>

<ParamField query="location_id" type="string">
  Only return purchases for this location
</ParamField>

<ParamField query="user_id" type="string">
  Only return purchases for this user. Note: the bearer token will be used to
  determine which user's purchases are being requested when the request is made
  by a logged in user.
</ParamField>

<Snippet file="pagination/params.mdx" />

### Response

<ResponseField name="id" type="string">
  The ID of the purchase record
</ResponseField>

<ResponseField name="user_id" type="string">
  The user ID
</ResponseField>

<ResponseField name="merchant_id" type="string">
  The merchant ID
</ResponseField>

<ResponseField name="location_id" type="string">
  Location ID
</ResponseField>

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

<ResponseField name="amount" type="decimal">
  The purchase amount
</ResponseField>

<ResponseField name="order" type="hash">
  Provides information about the associated order, if any

  <Expandable title="order">
    <ResponseField name="id" type="string">
      The ID of the order in the provider's system
    </ResponseField>

    <ResponseField name="provider" type="enum">
      The online ordering provider (`OLO`, `Toast`, `Other`)
    </ResponseField>
  </Expandable>
</ResponseField>

<Snippet file="pagination/response.mdx" />

<RequestExample>
  ```bash Get Purcheases theme={null}
  curl https://api.thanxsandbox.com/purchases \
    -X GET \
    -H "Content-Type: application/json"  \
    -H "Accept-Version: v4.0" \
    -H "Accept: application/json" \
    -H "Authorization: Bearer ${token}" \
    -H "X-ClientId: ${client_id}" 
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "purchases": [
      {
        "id": "92b7b0dac4",
        "user_id": "weori235",
        "merchant_id": "9a1f0772c9ac",
        "location_id": "e7183da044",
        "purchased_at": "2020-01-01T20:00:00Z",
        "amount": 9.99,
        "order": {
          "provider": "OLO",
          "id": "YWEI2342F"
        }
      }
    ],
    "pagination": {
      "total_page": 1,
      "per_page": 10,
      "current_page": 1
    }
  }
  ```
</ResponseExample>
