# Contacts API v3 Batch Update using email as Unique Id

**URL:** <https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [January 12, 2024, 12:20am UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671 "2024-01-12T00:20:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![DSmith95](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DSmith95](https://community.hubspot.com/u/DSmith95)\
**Post date:** [January 12, 2024, 12:20am UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/1 "2024-01-12T00:20:51Z")

</div>

I am trying to batch update hubspot using the email as the id (as refered to in the batch update API document)

Setting id as the email doesn’t work, nor does adding idproperty: “email” to the same level as id.

Changing id : xxx to email : xxx returns a validation error

{

“inputs”: [

{

“id”: “I Want This to be the email address”,

“properties”: {

“someproperty”:“updated”

}

},

{

“id”: “this would be another email address”,

“properties”: {

“someproperty”:“updatedalso”

}

},

]

}

the best error I get that’s not a validation failure is

“OBJECT\_NOT\_FOUND”

“Could not get some CONTACT objects, they may be deleted or not exist. Check that ids are valid”

this is when setting id to the email address

I know these accounts exist - I have checked via the Hubspot UI.

I cannot update using the RecordID as I will not have this available.  
Any help would be very appreciated

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [January 15, 2024, 6:40am UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/2 "2024-01-15T06:40:55Z")

</div>

Hi @DSmith95 👋

I’ve been able to replicate the issue you’ve described.

While it does say within the [relevant API documentation](https://developers.hubspot.com/docs/api/crm/contacts), that _“You can update contacts individually or in batches. For existing contacts, email and record ID are both unique values, so you can use id or email to update contacts via API”_, it doesn’t actually supply an example of how this can be achieved on the Batch Update Contacts operation. I know it’s possible to achieve on the Update Contact (single) operation, but, unfortunately, it looks like it’s not possible on the Batch Update Contacts operation.

You may have to first use the [CRM Search API](https://developers.hubspot.com/docs/api/crm/search) to find the relevant internal HubSpot Contact IDs before batch updating the Contacts.

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 17, 2024, 7:48pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/3 "2024-01-17T19:48:04Z")

</div>

Hey, @DSmith95 thanks for flagging this. And thanks to [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) for reproducing the issue. I’m going to make an example of my own, and I’ll see if I can get us a definite answer or a documentation update, if needed.

Talk soon! — Jaycee

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 21, 2024, 9:12pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/4 "2024-05-21T21:12:34Z")

</div>

Hey, @DSmith95 and [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) 👋 I submitted this to the dev doc team with an increased urgency. I’ll post here as soon as I get a working example or get it confirmed that this specific endpoint won’t work using email as a unique property.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 22, 2024, 8:16pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/5 "2024-05-22T20:16:04Z")

</div>

Hey y’all. I have an update — this is confirmed **not** possible.

I worked with the docs team to get the [documentation updated](https://developers.hubspot.com/docs/api/crm/contacts#update-contacts:~:text=To%20update%20contacts%20in%20batches%2C%20you%20can%20use%20the%20contacts%27%20record%20ID%20values%20(id).). Next, I need to track down the team that owns the endpoints tab examples and get that updated. But we have our long-awaited confirmation. I know this is not the answer we were hoping for, and I am grateful that the documentation won’t send anyone else on a wild goose chase using a method that isn’t possible.

Thank you for your patience.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [May 24, 2024, 6:03am UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/6 "2024-05-24T06:03:57Z")

</div>

Thanks for the update [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) 🙂

---

<div class="post-metadata">

**Author:** ![RChen10](https://avatars.discourse-cdn.com/v4/letter/r/ed8c4c/32.png) [@RChen10](https://community.hubspot.com/u/RChen10)\
**Post date:** [September 4, 2024, 1:52pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/7 "2024-09-04T13:52:27Z")

</div>

Not sure it will help. How about adding `“idProperty”: “email”,` in request payload?

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [September 12, 2024, 6:36am UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/8 "2024-09-12T06:36:49Z")

</div>

@RChen10 👋 Thanks for the idea, but unfortunately this does not work at the moment.

**Example request**

POST /crm/v3/objects/CONTACTS/batch/update

```lia-code-sample
{
 "inputs": [
 {
 "id": "test@test.com",
 "idProperty": "email",
 "properties": {
 "firstname": "Example 1"
 }
 },
 {
 "id": "example@example.com",
 "idProperty": "email",
 "properties": {
 "firstname": "Example 2"
 }
 }
 ]
}

```

**Example response** (status code 400)

```lia-code-sample
{
 "status": "error",
 "message": "Unable to perform update/upsert by non-unique 0-1 property email in portal ID 25377334",
 "correlationId": "6ab7356a-d80f-4284-bd48-54183fc235d0",
 "category": "VALIDATION_ERROR"
}

```

---

<div class="post-metadata">

**Author:** ![CSewell1](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CSewell1](https://community.hubspot.com/u/CSewell1)\
**Post date:** [September 18, 2024, 5:32pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/9 "2024-09-18T17:32:36Z")

</div>

[@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) Adding to this, it **does NOT work** with **any unique properties**.

Consider `emailCopy` as a unique property.

 ![CSewell1_0-1726680313999.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/7da0094d2d29ed680f28140fce046f776f32789a.png)

I tried following request:

```lia-code-sample
curl --request POST \
 --url https://api.hubapi.com/crm/v3/objects/contacts/batch/update \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
 --header 'content-type: application/json' \
 --data '{
 "inputs": [
 {
 "idProperty": "emailCopy",
 "id": "test@hello.com",
 "properties": {
 "role": "user"
 }
 }
 ]
}'

```

and got following response

```lia-code-sample
HTTP 400

{
 "status": "error",
 "message": "Invalid property(ies) supplied as unique properties for upsert operation: [PropertyCoordinates{portalId=7192871, objectTypeId=ObjectTypeId{legacyObjectType=CONTACT}, propertyName=emailCopy}]",
 "correlationId": "<id>",
 "category": "VALIDATION_ERROR"
}

```

Also, the sample request body (the one on the right) in the [documentation provided here](https://developers.hubspot.com/docs/api/crm/contacts?_gl=1*4ibc55*_gcl_au*MTI4NDI0MTg0Ny4xNzI2NTE2NDE1*_ga*MTY3NTIzMjYwNC4xNzI2NTE2NDE1*_ga_LXTM6CQ0XK*MTcyNjY3NTkwOS4yLjAuMTcyNjY3NTkwOS42MC4wLjA.#update-contacts:~:text=To%20update%20contacts%20in%20batches%2C%20you%20can%20use%20the%20contacts%27%20record%20ID%20values%20(id).) is invalid. It has a malformed JSON structure:

 ![CSewell1_1-1726680671773.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/f/4f105030736dc6c7482cb0ebb53677c6a16fcdc6.png)

---

<div class="post-metadata">

**Author:** ![CSewell1](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CSewell1](https://community.hubspot.com/u/CSewell1)\
**Post date:** [September 18, 2024, 5:20pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/10 "2024-09-18T17:20:42Z")

</div>

[@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074)

Since email was not working as a unique field, I explicitly made another unique field `emailCopy` and then tried hitting the endpoint using that field, but still got the following error message.

Request:  
curl --request POST \  
--url [https://api.hubapi.com/crm/v3/objects/contacts/batch/update](https://api.hubapi.com/crm/v3/objects/contacts/batch/update) \  
--header ‘authorization: Bearer YOUR\_ACCESS\_TOKEN’ \  
--header ‘content-type: application/json’ \  
--data ‘{  
“inputs”: [  
{  
“idProperty”: “emailCopy”,  
“id”: “[test@hello.com](mailto:test@hello.com)”,  
“properties”: {  
“role”: “user”  
}  
}  
]  
}’  
Response:

HTTP 400

“message”: “Invalid property(ies) supplied as unique properties for upsert operation: [PropertyCoordinates{portalId=7192871, objectTypeId=ObjectTypeId{legacyObjectType=CONTACT}, propertyName=emailCopy}]”

I verified that `emailCopy` is a unique property.

 ![CSewell1_0-1726679779486.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/f/0f9ac628e4cb3e515b4149be14e9bca4ab8b813f.png)

Seems like this endpoint DOES NOT WORK with any unique fields except for `id`.

Also, the [documentation on this page](https://developers.hubspot.com/docs/api/crm/contacts?_gl=1*4ibc55*_gcl_au*MTI4NDI0MTg0Ny4xNzI2NTE2NDE1*_ga*MTY3NTIzMjYwNC4xNzI2NTE2NDE1*_ga_LXTM6CQ0XK*MTcyNjY3NTkwOS4yLjAuMTcyNjY3NTkwOS42MC4wLjA.#update-contacts:~:text=To%20update%20contacts%20in%20batches%2C%20you%20can%20use%20the%20contacts%27%20record%20ID%20values%20(id).) is incorrect. The request body (one on the right) is malformed JSON.

 ![CSewell1_1-1726679932863.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/b/ebf81985a8279d6930dcf41aa61786a445a8f3db.png)

---

<div class="post-metadata">

**Author:** ![CSewell1](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CSewell1](https://community.hubspot.com/u/CSewell1)\
**Post date:** [September 25, 2024, 6:23pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/11 "2024-09-25T18:23:30Z")

</div>

@DSmith95 **HERE IS THE SOLUTION ✌🏻**

Try this using the **v1 APIs**. They are quite stable and still supported. The page itself quotes:

“Our APIs are in the [midst of a transition](https://developers.hubspot.com/blog/building-the-next-generation-of-hubspots-apis). As part of our effort to improve API consistency and completeness, we launched [the next generation of HubSpot’s API](https://developers.hubspot.com/docs/api/overview) in early 2020. **However, not every endpoint or API has been updated to the latest version, and our older endpoints are still stable and supported**.”

Use this v1 batch contacts endpoint:

[https://legacydocs.hubspot.com/docs/methods/contacts/batch\_create\_or\_update](https://legacydocs.hubspot.com/docs/methods/contacts/batch_create_or_update)

Use the following example request body

```lia-code-sample
[
 // assume existing email
 {
 "email": "test+old@hello.com",
 "properties": [
 {
 "property": "email",
 "value": "test+old@hello.com"
 },
 {
 "property": "firstname",
 "value": "User"
 },
 {
 "property": "lastname",
 "value": "Old Updated"
 }
 ]
 },
 // new email
 {
 "email": "test+new@hello.com",
 "properties": [
 {
 "property": "email",
 "value": "test+new@hello.com"
 },
 {
 "property": "firstname",
 "value": "User"
 },
 {
 "property": "lastname",
 "value": "New"
 }
 ]
 }
]

```

CC: [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) - I see a lot of users in the community suffering from the same issue. Maybe you can suggest them with using this.

---

<div class="post-metadata">

**Author:** ![SBasile](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sbasile/32/88586_2.png) [@SBasile](https://community.hubspot.com/u/SBasile)\
**Post date:** [November 7, 2024, 7:28pm UTC](https://community.hubspot.com/t/contacts-api-v3-batch-update-using-email-as-unique-id/97671/12 "2024-11-07T19:28:02Z")

</div>

I would really like to know when HubSpot intends to fix this. The v1 batch interface only reples with a 202 and provides no token or route which you can use in order to track the request’s completion. That makes it difficult to get the ids of newly created contacts. The v3 upsert route will create the contact but will only add the email address and ignores all other contact properties passed with the POST request. It does reply with the ids of the newly created contact records. So you then have to use that information and do a separate batch update to get the remaining information into the record.
