APIs & Integrations

LCM4
Membro

Contact batch upsert endpoint

resolver

Hi!

I'm trying to use the upsert endpoint

 

 

 

https://api.hubapi.com/crm/v3/objects/contacts/batch/upsert

 

 

 

 to update existing contacts and create not existing ones, but cannot get it to work

 

I'm passing the following body (first input exist so should update, and the following two does not exist and should create them)

 

 

 

{
    "inputs": [
        {
            "id": "35791753356",
            "properties": {
                "firstname": "Maria",
                "lastname": "Johnson"
            }
        },
        {
            "id": "doesnotexist",
            "properties": {
                "firstname": "John 1",
                "lastname": "Doe 1",
                "email": "test.test1@test.com"
            }
        },
        {
            "id": "doesnotexist2",
            "properties": {
                "firstname": "John 2",
                "lastname": "Doe 2",
                "email": "test.test2@test.com"
            }
        }
    ]
}

 

 

 

 

But I get the following response

 

 

 

{
    "status": "error",
    "message": "Updates in a single batch must specify its unique property.",
    "correlationId": "d6594c05-a699-4014-a51d-6693c172f179",
    "category": "VALIDATION_ERROR"
}

 

 

 

 

What am I doing wrong? The documentation says that when providing a not existing id it will create the contact but it does not work

0 Avaliação positiva
1 Solução aceita
SteveHTM
Solução
Conselheiro(a) de destaque | Parceiro Platinum
Conselheiro(a) de destaque | Parceiro Platinum

Contact batch upsert endpoint

resolver

And if you do try to use 'email' as the idProperty...

 

HTTP 400

{
  "status": "error",
  "message": "Unable to perform update/upsert by non-unique 0-1 property email in portal ID XX3719",
  "correlationId": "fccd25a3-fb03-45ed-bf1d-982736c99cbe",
  "category": "VALIDATION_ERROR"
}

 

 

Scatching my head for how this might work...

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature

Exibir solução no post original

12 Respostas 12
lstepany
Colaborador(a) | Parceiro Diamante
Colaborador(a) | Parceiro Diamante

Contact batch upsert endpoint

resolver

I faced the same issue and after investigating a bit I found out that the hs_object_id is not set as unique id in property settings (although it is unique). Funny enough! 

 

lstepany_0-1737469586006.png

So besically it is not possible to use hs_object_id for butch upsert endpoint. A workaround would be to create a nea property and make it unique after what to create a workflow which will copy the original IDs to the newly created unique property. Then use that prop in the req body 😄

0 Avaliação positiva
SteveHTM
Conselheiro(a) de destaque | Parceiro Platinum
Conselheiro(a) de destaque | Parceiro Platinum

Contact batch upsert endpoint

resolver

@LCM4 - my reading of the descrption here suggests thst you need to provide the idProperty selection along with the id value. Using an email address as the idProperty that would look like:

"inputs": [
    {
      "idProperty": "email",
      "id": "joe@company.com",
      "properties": {
        "additionalProp1": "string",
        "additionalProp2": "string",
        "additionalProp3": "string"
      }
    }
]

 

But there is a rather strange warning that "email upserts are not supported" - which maybe practically limits what you can use the  API for. Unless this format works of course:

"inputs": [
    {
      "idProperty": "hs_object_id",
      "id": "", #null for new contact
      "properties": {
        "email": "joe@company.com",
        "additionalProp2": "string",
        "additionalProp3": "string"
      }
    }
]

Best of luck!

 

Steve

 

 

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Avaliação positiva
LCM4
Membro

Contact batch upsert endpoint

resolver

It would return this

 

{
    "status": "error",
    "message": "Duplicate IDs found in batch input: []. IDs must be unique",
    "correlationId": "218c3962-47cc-4248-87ea-0064604ff943",
    "context": {
        "ids": [
            ""
        ]
    },
    "category": "VALIDATION_ERROR"
}

 

 


But there is a rather strange warning that "email upserts are not supported" - which maybe practically limits what you can use the  API for.


Might be that since email is not supported here, or documentation is wrongly written on how pass the data correctly (seen that before). Tried the V1 API where a similar endpoint exist and works just right, but yeah, this one does not 😞

 

And a note hehe

I've tried deleting the id, idProperty, both at the same time, leave the id for the one that exist and none of those are working

0 Avaliação positiva
SteveHTM
Solução
Conselheiro(a) de destaque | Parceiro Platinum
Conselheiro(a) de destaque | Parceiro Platinum

Contact batch upsert endpoint

resolver

And if you do try to use 'email' as the idProperty...

 

HTTP 400

{
  "status": "error",
  "message": "Unable to perform update/upsert by non-unique 0-1 property email in portal ID XX3719",
  "correlationId": "fccd25a3-fb03-45ed-bf1d-982736c99cbe",
  "category": "VALIDATION_ERROR"
}

 

 

Scatching my head for how this might work...

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
VStruyf
Colaborador(a) | Parceiro Diamante
Colaborador(a) | Parceiro Diamante

Contact batch upsert endpoint

resolver

I have the same error. Did you find the solution?

0 Avaliação positiva
dannio
Top colaborador(a) | Parceiro Diamante
Top colaborador(a) | Parceiro Diamante

Contact batch upsert endpoint

resolver

It worked for me when I specify email as the id though. Here's my request:

POST https://api.hubapi.com/crm/v3/objects/contacts/batch/upsert

 

{
  "inputs": [
    {
        "properties": {
            "phone": "1234"
        },
        "id": "test1@gmail.com",
        "idProperty": "email"
    },
    {
        "properties": {
            "phone": "12345"
        },
        "id": "test2@gmail.com",
        "idProperty": "email"
    },
    {
        "properties": {
            "phone": "123456"
        },
        "id": "test3@gmail.com",
        "idProperty": "email"
    },
    {
        "properties": {
            "phone": "23455"
        },
        "id": "doesnotexistyet@gmail.com",
        "idProperty": "email"
    }
  ]
}

 

All updated if exists, and the one that didn't "doesnotexistyet@gmail.com" inserted without any issues.

0 Avaliação positiva
SAMsan
Colaborador(a)

Contact batch upsert endpoint

resolver

So should we consider documentation is wrong and we can't batch update/insert contacts?
I tried to get this working according to guidelines without any success, it returns error 400 if using `email` as `idProperty` value
Response is : `Unable to perform update/upsert by non-unique 0-1 property email in portal ID XXX`.

Batch read does work correctly with same params.

0 Avaliação positiva
SAMsan
Colaborador(a)

Contact batch upsert endpoint

resolver

As an update, this endpoint totally works with custom objects although I can't get associations working, the batch update/insert is OK.

0 Avaliação positiva
SteveHTM
Conselheiro(a) de destaque | Parceiro Platinum
Conselheiro(a) de destaque | Parceiro Platinum

Contact batch upsert endpoint

resolver

Yes - seems useless for most obvious practical purposes. Like many things its not clear how you can get this feedback to the product management team.

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Avaliação positiva
JMacias5
Membro

Contact batch upsert endpoint

resolver

Any work arounds or fixes been found?

0 Avaliação positiva
LCM4
Membro

Contact batch upsert endpoint

resolver

Haven't tested it recently, and I don't remember how i fixed this issue

But a workaround that maybe you try is
1. Check by id or email, etc if the contact exists

2. If it exists, use the update endpoint

3. If it does not exist, use the create endpoint

 

Using this workaround will use 2 requests, but for me it is necessary

0 Avaliação positiva
Tuscher
Participante

Contact batch upsert endpoint

resolver

I have the same issue. Seems that the upsert endpoint is completely useless.

0 Avaliação positiva