# Add anonymous purchase data

### Endpoint

```
https://api.airship.co.uk/v1/purchases
```

### Configuration

Along with the account\_id, either the `booking_reference`, `unique_code`,  `card_reference`, `membership_number` or `table_number` is required to associate a purchase to a contact.

| Field                  | Notes                                                                                                                                                                                               |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `account_id`           | <p>Required</p><p></p><p>The account ID represents the account that you are storing this contact to. If you are unsure of what your account ID is, ask our support team to confirm</p>              |
| `booking_reference`    | The unique booking reference associated to the purchase.                                                                                                                                            |
| `unique_code`          | The unique voucher code used on the purchase.                                                                                                                                                       |
| `unique_code_group_id` | <p>Optional<br>Airships unique code group ID associated to the voucher. If the client has re-useable vouchers codes (for different promotions) - this id is required to pass in a unique\_code.</p> |
| `membership_number`    | The customers loyalty / membership number used on the purchase.                                                                                                                                     |
| `card_reference`       | The customers loyalty card number used on the purchase.                                                                                                                                             |
| `table_number`         | The table number which the customer sat at\*                                                                                                                                                        |
| `provider_id`          | This is the partners ID to help identify the source of a purchase. If you need one creating, please contact <support@airship.co.uk>, we'll get one added and provide you an ID                      |

\*The table number has some additional checks in place within Airship. We will look for any customers from the booking integration who;

* Has a booking
* Had that table number associated in the booking extract
* Had a booking seated date on the same day as the purchase date
* Whose booking start time was within 3 hours of the purchase completed time

Operationaly, this requires the customer to be seated at the table defined within the booking platform - or the booking platform to be updated with the seated table number to work.

More detail on the purchases history which can be passed can be found [here](https://developers.airship.co.uk/basics/contacts/append-purchase-history).

### Basic payload example

```json
{
    "account_id": 3,
    "booking_reference": "5G83-234G-23TG",
    "unique_code": "BD34G53",
    "unique_code_group_id": 45121,
    "membership_number": "76398763-42T",
    "card_reference": "1234abc5678",
    "table_number": "44",
    "purchases": [
        {
            "transaction_reference": "77FF-24FF-234F-7",
            "unit_id": 8775,
            "provider_id": 2,
            "created_at": "2021-06-01 00:00:00",
            "items": [
                {
                    "description": "Bacon Cheeseburger",
                    "sku": "abc_8913",
                    "quantity": 1,
                    "value": 7,
                    "tags": [
                        "Burger",
                        "Main course"
                    ]
                },
                {
                    "description": "Garlic Bread",
                    "sku": "5621",
                    "quantity": 2,
                    "value": 8.40,
                    "tags": [
                        "Sides"
                    ]
                }
            ]
        }
    ]
}
```
