# Bulk Enrichment

{% hint style="info" %}
At the moment, the real-time & waterfall options are only available in the single contact [Enrichment API](https://docs.exactbuyer.com/contact-enrichment/enrichment)
{% endhint %}

To get more detail about the API parameters, response types and sample calls, click the arrow to the right on the card below.

## Bulk Enrich Contacts

<mark style="color:green;">`POST`</mark> `https://api.exactbuyer.com/v1/bulk-enrich`

This endpoint allows you to enrich multiple contacts at once.

#### Headers

| Name                                        | Type   | Description  |
| ------------------------------------------- | ------ | ------------ |
| X-API-Key<mark style="color:red;">\*</mark> | string | Your API key |

#### Request Body

| Name             | Type  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ---------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| required\_fields | array | <p>A list of certain fields which must be present in each enriched contact. If the required\_fields are specified, a match will only be considered successful if it contains all of these fields. <br><br>Possible values for each <code>field\_type</code> entry in the required\_fields list:<br><br><code>email</code>: Require any email<br><code>work\_email</code>: Require work email <code>personal\_email</code>: Require personal email<br><code>phone</code>: Require phone number<br><code>social\_profile</code>: Require any social profile e.g. linkedin profile</p> |
| query\_list      | array | A list of emails/social profiles/phones to enrich. Up to 1000 inputs can be provided in one request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

{% tabs %}
{% tab title="200 The enriched contacts will be returned in the same order as the query list in the request. If a record isn't enriched, the 'enriched\_contact' object will contain null." %}

```json
{
  "contacts": [
        {
          "enriched_contact": {
              "full_name": ...,
              .....
            },
          "value": "linkedin.com/in/edankrolewicz"
        },
        {
          "enriched_contact": null,
          "value": "linkedin.com/in/randomlinkedinaddress"
        }
    ],
  "records_enriched": 1
}
```

{% endtab %}
{% endtabs %}

<details>

<summary>API Response</summary>

<pre class="language-javascript" data-overflow="wrap"><code class="lang-javascript"><strong>/*The enriched contacts will be returned in the same order as the query list in the request. If a record isn't enriched, the 'enriched_contact' object will contain null. */
</strong>{
  "contacts": [
        {
          "enriched_contact": {
              'full_name': ...,
              .....
            },
          "value": "linkedin.com/in/edankrolewicz"
        },
        {
          "enriched_contact": null,
          "value": "linkedin.com/in/randomlinkedinaddress"
        }
    ],
  "records_enriched": 1
}
</code></pre>

</details>

<details>

<summary>Request Format</summary>

#### query\_list

This array will contain all the targets that a user wants to enrich. These may be in the form of **email/social profile/phone**

```haskell
[
  {
      "field_type": "social_profile",
      "value": "linkedin.com/in/edankrolewicz"
  },
  {
      "field_type": "phone",
      "value": "+1-773-474-9362"
  },
  {
      "field_type": "email",
      "value": "edan@exactbuyer.com"
  }
]
```

#### required\_fields

Specify the fields that **MUST** be present in all enrichments from our API response. The below example tells the ExactBuyer API to return the four fields for all enriched entities. Detailed explanation [here](#bulk-enrich-contacts)

```haskell
[
  {
    "field_type": "social_profile"
  },
  {
    "field_type": "work_email"
  },
  {
    "field_type": "personal_email"
  },
  {
    "field_type": "phone",
  }
]
```

</details>

#### Credit Deduction:

The credits deducted will be equal to the amount of records that the bulk enrichment API was successfully able to enrich. This means that if the API was able to find data for the `required_fields` that were sent as parameters then it will deduct one credit per enrichment.&#x20;

{% hint style="info" %}
It does not matter if the contact was previously enriched in the past 30 days through another API, if enrichment is successful for this contact in the bulk enrichment then a credit will be deducted against it.
{% endhint %}

### Examples

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

```python
import requests
import json

url = "https://api.exactbuyer.com/v1/bulk-enrich"

required_fields = json.dumps([
    {
        "field_type": "social_profile"
    }
])

query_list = json.dumps([{
  "value": "linkedin.com/in/edankrolewicz",
  "field_type": "social_profile"
}])

payload = {
  'required_fields': required_fields,
  'query_list': query_list
}

headers = {
  'X-API-Key': 'YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location --request POST 'https://api.exactbuyer.com/v1/bulk-enrich' \
--header 'X-API-Key: YOUR_API_KEY' \
--form 'required_fields="[
    {
        \"field_type\": \"social_profile\"
    }
]"' \
--form 'query_list="[{
  \"value\": \"linkedin.com/in/edankrolewicz\",
  \"field_type\": \"social_profile\"
}]"'
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const myHeaders = new Headers();
myHeaders.append("X-API-Key", "YOUR_API_KEY");

const formdata = new FormData();

const required_fields = JSON.stringify([
    {
        "field_type": "social_profile"
    }
]);

const query_list = JSON.stringify([{
  "value": "linkedin.com/in/edankrolewicz",
  "field_type": "social_profile"
}])

formdata.append("required_fields", required_fields);
formdata.append("query_list", query_list);

const requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: formdata,
  redirect: 'follow'
};

fetch("https://api.exactbuyer.com/v1/bulk-enrich", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}
{% endtabs %}
