# Contacts

## Get Contact

<mark style="color:blue;">`GET`</mark> `https://api.carts.guru/contacts`

This endpoint allows you to get the information for single contact.

#### Query Parameters

| Name      | Type   | Description                             |
| --------- | ------ | --------------------------------------- |
| siteId    | string | Your site ID (provided at integration). |
| accountId | string | The contact's ID in your website.       |

#### Headers

| Name       | Type   | Description                                                        |
| ---------- | ------ | ------------------------------------------------------------------ |
| x-auth-key | string | Personal token to access Carts Guru API (provided at integration). |

{% tabs %}
{% tab title="200 Carts Guru successfully retrieved." %}

```javascript
{
    "data": [{
        "_id": "Contact's id",
        "siteId": "Your site id",
        "firstName": "Contacts first name"
        "lastName": "Contacts last name",
        "addresses": [{
            "title": "Residence type",
            "line1": "",
            "line2": "",
            "postcode": "Contacts zipcode",
            "city": "Contacts city",
            "country": "Contacts Country"
        }],
        "phoneNumbers": [{
            "title": "type",
            "phoneNumber": "Contacts phone number"
        }],
        "emails": ["Contacts email"],
        "communicationPreferences": {
            "sms": "Default",
            "call": "Optin",
            "email": "Optout"
        }
    }]
}
```

{% endtab %}

{% tab title="401 Something in your request parameters is wrong." %}

```javascript
{}
```

{% endtab %}
{% endtabs %}

## Update Contact's Opt-in Status

<mark style="color:green;">`POST`</mark> `https://api.carts.guru/contacts/:id`

This endpoint allows you to change the contacts Opt-in status.

#### Path Parameters

| Name | Type   | Description                                                       |
| ---- | ------ | ----------------------------------------------------------------- |
| id   | string | The contact's \_id from the Carts Guru document (see get method). |

#### Query Parameters

| Name   | Type   | Description                             |
| ------ | ------ | --------------------------------------- |
| siteId | string | Your site ID (provided at integration). |

#### Headers

| Name       | Type   | Description                                                        |
| ---------- | ------ | ------------------------------------------------------------------ |
| x-auth-key | string | Personal token to access Carts Guru API (provided at integration). |

#### Request Body

| Name       | Type    | Description                                                                          |
| ---------- | ------- | ------------------------------------------------------------------------------------ |
| allowCall  | boolean | <p>True: customer will receive calls.<br>False: customer will not receive calls.</p> |
| allowSms   | boolean | <p>True: customer will receive sms.<br>False: customer will not receive sms.</p>     |
| allowEmail | boolean | <p>True: customer will receive email.<br>False: customer will not receive email.</p> |

{% tabs %}
{% tab title="200 Contacts document with all updated parameters." %}

```javascript

{        "data": [{            "_id": "Contact's id",            "siteId": "Your site id",                    "firstName": "Contacts first name"                    "lastName": "Contacts last name",                    "addresses": [{                                "title": "Residence type",                                "line1": "",                                "line2": "",                                "postcode": "Contacts zipcode",                                "city": "Contacts city",                                "country": "Contacts Country"                    }],                            "phoneNumbers": [{                                "title": "type",                                "phoneNumber": "Contacts phone number"                    }],                    "emails": ["Contacts email"],                    "communicationPreferences": {                                "sms": "Default",                                "call": "Optin",                                "email": "Optout"                    }        }] }
```

{% endtab %}

{% tab title="401 Something in your request parameters is wrong." %}

```javascript
{}
```

{% endtab %}

{% tab title="404 Could not find a contact matching your request." %}

```javascript
{
      "statusCode": "404",
      "error": 'Not Found',
      "message": 'Contact: x Not found'
}
```

{% endtab %}
{% endtabs %}

## Anonymize Contact

<mark style="color:orange;">`PUT`</mark> `https://api.carts.guru/contacts/:id`

Allows you to delete all the identifying properties of your contacts on Carts Guru database

#### Path Parameters

| Name | Type   | Description                                                      |
| ---- | ------ | ---------------------------------------------------------------- |
| id   | string | The contacts \_id from the Carts Guru document (see get method). |

#### Query Parameters

| Name       | Type   | Description                                                                                                        |
| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------ |
| cg\_action | string | Describes the action you want the Carts Guru API to perform on your contact ('anonymize' is the only one allowed). |
| siteId     | string | Your site ID (provided at integration)                                                                             |

#### Headers

| Name       | Type   | Description                                                        |
| ---------- | ------ | ------------------------------------------------------------------ |
| x-auth-key | string | Personal token to access Carts Guru API (provided at integration). |

{% tabs %}
{% tab title="200 The contacts document with all their personal information deleted." %}

```javascript
{
    "data": [{
        "_id": "Contact's id",
        "siteId": "Your site id",
        "firstName": "undefined"
        "lastName": "undefined",
        "addresses": "undefined",
        "phoneNumbers": "undefined",
        "emails": "undefined",
        "communicationPreferences": {
            "sms": "Default",
            "call": "Optin",
            "email": "Optout"
        }
    }]
}
```

{% endtab %}

{% tab title="400 The action sent is not part of the actions of the API" %}

```javascript
{
      "statusCode": "400",
      "error": "Bad Request",
      "message": "Action: jump Not found"
}
```

{% endtab %}

{% tab title="401 Something in your request parameters is wrong." %}

```
{}
```

{% endtab %}

{% tab title="404 Could not find a contact matching your request." %}

```javascript
{
      "statusCode": "404",
      "error": 'Not Found',
      "message": 'Contact: x Not found'
}
```

{% endtab %}
{% endtabs %}

```bash
curl -XGET https://api.carts.guru/contacts.csv?siteId=0000000-0000-0000-0000-0000000000 \
  --header 'x-auth-key: 00000000000000000' 
```

## Import CSV File

<mark style="color:orange;">`PUT`</mark> `https://api.carts.guru/contacts.csv`

Allows you to import a CSV File which contains a list of all the emails/phone-numbers of your current contacts in the Carts Guru database. These contacts Opt-in status will be updated to Opt-out for the type specified in the file.\
\
\
The CSV file format: 'mutipart/form-data'\
File key name: 'file'

#### Query Parameters

| Name   | Type   | Description                             |
| ------ | ------ | --------------------------------------- |
| siteId | string | Your site ID (provided at integration). |

#### Headers

| Name       | Type   | Description                                                        |
| ---------- | ------ | ------------------------------------------------------------------ |
| x-auth-key | string | Personal token to access Carts Guru API (provided at integration). |

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

```javascript
{
    status: "success"
}
```

{% endtab %}
{% endtabs %}

```bash
curl -XPUT https://api.carts.guru/contacts.csv?siteId=0000000-0000-0000-0000-000000 \
  --header 'x-auth-key: 00000000000000000' \
  --form "file=@valid.csv;type=application/csv"
```

{% hint style="info" %}

## Import Requirements:

{% endhint %}

![](/files/-LHK4jN_WD4GtwRL-ZGG)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cartsguru.gitbook.io/custom-integration/carts-guru-integration/contact-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
