# Search contact by voucher

### Overview

Any contact that has a unique voucher code assigned can be searched for using the get /Contact endpoint. An account ID, voucher code and voucher code group must be provided to ensure the relevant contact is returned.

This is currently used to identify a contact by a unique voucher code, and the POS / Order and pay provider will then apply a basket to that contact using the [append-booking-data](https://developers.airship.co.uk/basics/contacts/append-booking-data "mention")&#x20;

### Example Request

{% tabs %}
{% tab title="GET" %}

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

{% endtab %}
{% endtabs %}

### Configuration

#### Headers

| Field                           | Notes                                                                                                                                                                          |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Authentication` (bearer token) | The authentication token is linked to the account that you are searching bookings in. If you are unsure of what your Authentication token is, ask our support team to confirm. |

#### Body

| Field        | Notes                                                                                                                                                                                                                                                                  |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `account_id` | The account ID represents the account that you are searching bookings in. If you are unsure of what your account ID is, ask our support team to confirm.                                                                                                               |
| `code`       | The unique voucher code which you are searching for.                                                                                                                                                                                                                   |
| `ucgid`      | The unique voucher code group which the voucher is associated with. As the same voucher code can exist in different code groups (be issued in different campaigns at different points in time) - the ucgid enables us to narrow down which code is being searched for. |

### **Basic payload example**

{% tabs %}
{% tab title="Request" %}

```json
{
  "account_id": 2,
  "voucher_code_data": 
    {
      "code": "PL1022393E",
      "ucgid": 523
    }
}
```

{% endtab %}

{% tab title="200 Response" %}

```json
{
    "allow_sms": false,
    "allow_email": true,
    "allow_call": false,
    "allow_snail_mail": false,
    "udfs": [],
    "units": [
        {
            "id": 14458,
            "name": "Head Office",
            "groups": [
                {
                    "id": 126832,
                    "name": "Football visitor"
                },
                {
                    "id": 126842,
                    "name": "Christmas Competition entry"
                }
            ]
        },
        {
            "id": 14478,
            "name": "London venue",
            "groups": [
                {
                    "id": 126778,
                    "name": "WIFI"
                }
            ]
        }
    ],
    "feedback": "https://api.airship.co.uk/v1/contact/51616336/feedback",
    "bookings": "https://api.airship.co.uk/v1/contact/51616336/bookings",
    "purchases": "https://api.airship.co.uk/v1/contact/51616336/purchases",
    "proof_of_presence": "https://api.airship.co.uk/v1/contact/51616336/pops",
    "id": 51616336,
    "gender": "M",
    "title": "Mr",
    "first_name": "John",
    "last_name": "Smith",
    "dob": "1984-11-27",
    "building_name": "",
    "building_num_street": "2 Test Way",
    "locality": "",
    "postcode": "L1 1AA",
    "city": "London",
    "country": "United Kingdom",
    "county": "",
    "mobile_number": "447816000001",
    "home_number": "",
    "preferred_method_id": "0",
    "work_number": "",
    "email": "John.Smith@airship.co.uk",
    "source_id": "134747",
    "membership_number": "",
    "membership_type": ""
}
```

{% endtab %}

{% tab title="422 Response" %}
A 422 response can be given in the following scenarios;

1. Account ID is incorrect

```json
{
    "message": "The given data was invalid.",
    "errors": {
        "account_id": [
            "You do not have access to this account"
        ]
    }
}
```

2\. Unique code group ID is incorrect

```json
{
    "message": "The given data was invalid.",
    "errors": {
        "ucgid": [
            "This ucgid does not exist"
        ]
    }
}
```

{% endtab %}
{% endtabs %}
