Hi,
I am using the /crm/v3/objects/$objType/batch/read POST API to detect deleted or merged objects on HubSpot, but I have a few questions about its behavior to ensure I use it correctly and avoid unintended deletions in my system.
Scenario 1: Deleted Objects
When an object is deleted on HubSpot, the API returns the following response:
{
“results”: [],
“errors”: [
{
“status”: “error”,
“category”: “OBJECT_NOT_FOUND”,
“message”: “Could not get some COMPANY objects, they may be deleted or not exist. Check that ids are valid.”,
“context”: {
“ids”: [
“8380080352”,
“8144745976”,
“7440157923”
]
}
}
]
}
In this case, if category is OBJECT_NOT_FOUND, I can extract the ids from the errors.context.ids array and handle them as deleted objects in my system.
Scenario 2: Merged Objects
Sometimes, contacts in HubSpot are merged. In such cases, the API can return the following response:
{
“results”: [
{
“id”: “84805801”,
“properties”: {
“email”: “mary.miller@usfoods.com”,
“createdate”: “2020-03-03T20:18:42.589Z”,
“firstname”: “Mary”,
“hs_object_id”: “84805801”,
“lastname”: “Miller”,
“lastmodifieddate”: “2024-08-10T23:13:12.293Z”
},
“createdAt”: “2020-03-03T20:18:42.589Z”,
“updatedAt”: “2024-08-10T23:13:12.293Z”
}
]
}
Here, the id in the response (84805801) is different from the id in my original request (62241). This indicates that the contact was merged. In such cases, I also need to remove this record (62241) from my system.
Questions:
1. Are there other scenarios I should consider to avoid mistakenly deleting or overwriting data in my system?
2. For merged objects, is it safe to assume that if the id in the response differs from the id in my request, the object has been merged, and the new ID should be used?
3. Is there a recommended approach to handle errors and results together to ensure I don’t miss any edge cases?
Any insights or recommendations for using this API correctly would be greatly appreciated, thanks