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

# Create Purchase

> This endpoint submits a purchase to Thanx for processing. This allows for issuance of loyalty points to the given user.

<Info>
  Scope required: `purchases.write`
</Info>

### Parameters

<ParamField body="merchant_id" type="string" required>
  Merchant ID
</ParamField>

<ParamField body="user_id" type="string" required>
  User ID
</ParamField>

<ParamField body="amount" type="decimal" required>
  The purchase amount
</ParamField>

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

<ParamField body="location_id" type="string">
  Location ID
</ParamField>

<ParamField body="card_id" type="string">
  Card ID that the user used, if it is registered in Thanx
</ParamField>

<ParamField body="products" type="array(string)">
  Optionally specified array of product strings to associate with the purchase
</ParamField>

### Response

<RequestExample>
  ```bash theme={null}
  curl https://api.thanxsandbox.com/purchases \
    -X POST \
    -H 'X-ClientId: {client_id}' \
    -H 'Accept-Version: v4.0' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer {access_token}' \
    -d '{
      "purchase": {
        "merchant_id":  "weoru",
        "location_id":  "hljkfd2345",
        "user_id":      "wgljsdwer23",
        "card_id":      null
        "amount":       13.45,
        "purchased_at": "2020-09-15T00:52:10.655+00:00",
        "products":     ["coffee", "pizza"]
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {}
  ```
</ResponseExample>
