Batch custom objects CreateOrUpdate

Hello

I want to update the batch of custom objects and create some new objects if they didn’t exists. The problem is that I don’t know which ones are already exists in HubSpot.

When I try to POST to /crm/v3/objects/{obj}/batch/update full batch fails on non-existing objects. When I POST to /crm/v3/objects/{obj}/batch/create it fails on already existing objects, because of unique ID.

I can do it one-by-one, but this will require 2 API requests for a single object (ask if it is exists and next create new or update existing one). In fact sometimes I need to update 1k objects, so 2k api requests ruins my server and meet the HubSpot limits.

Any ideas pls?

Self-answer: I need to batch-read objects first by POST/crm/v3/objects/{objectType}/batch/read to determinate which objects olready exists and next update existing and create non-existing ones. Total 2 api calls per 100 objects - looks good. Thanks me for an answer. :slightly_smiling_face:

Hi, I wonder if objectType in API endpoint is equal to object internal name. I tried to use this /crm/v3/objects/{objectType}/batch/read but it always returned

{

“status”: “error”,

“message”: “Unable to infer object type from: XXX”,

“correlationId”: “fb19b6a8-7924-4cfe-98f8-136a88c5ef36”

}

You can also use the upsert function to create or update:
https://api.hubapi.com/crm/v3/objects/{objectType}/batch/upsert
Which could bring it down to 1 per 100, but that’s likely not an efficiency you need