I am in the process of writing an HS integration solution for our customer database. However, I have not been able to figure out how to properly sync contacts through the API. This is what I am doing:
- Get a list of all contacts from HubSpot
- Check contacts in the database if there is one with the same email address
- If no, add contact to HubSpot
To save on traffic I do as recommended by HubSpot and I use the batch API. It took a while for me to learn that there is a secondary email address that I have to check as well, so I included secondary_email in the list of fields I would like to receive from the contacts API.
Now I just ran into the problem that obviously HubSpot does not only allow one or two email addresses per contact but an infinite list of email addresses which I am supposed to check before importing a new contact.
However, there does not seem to be a way to retrieve all email addresses for a contact in the batch API. So my question is, what am I supposed to do? There is an API to download all email addresses for a given contact, but that just does not make sense at all?
- Download all contacts using the batch API
- Download a list of email addresses for every single contact
That defeats the purpose of using a batch API, that’s tons of useless API calls which slow down the whole process and makes one hit the rate limit even quicker.
Apart from that, I also use the batch API to add contacts. If the batch contains just one contact that throws an error, the whole batch will fail. So I can’t just log single contacts that failed but whole batches of 10. Wouldn’t it be much easier if the API returned those contacts that were added successfully and those that threw exceptions?
What is it I don’t see here?!? How is that process supposed to look like? What would be a proper implementation?