409 Conflict problem when creating/updating contacts

I have some logic in a custom app that creates or updates a contact depending on whether it exists in Hubspot or not.

To determine whether a contact exists or not, i’m using the search API, and searching contacts by email address.

In some cases, i’m creating a contact (via the api) - and then almost immediately updating the contact. When updating at this point, the contact that’s just been created isn’t found using the search api - so my app tries to create the contact again. However, at this point, i’m getting a 409 conflict error saying that the contact already exists.

My question is how come the Search API doesn’t find contacts that have just been created?

Hi, @ncarps :waving_hand: Have you looked at adding a slight delay into your process. I didn’t find a specific document for this behaviour. Looking at replies from other HubSpotters on similar issues in the community (example), I see that there can be a delay of 5–10 seconds for this data to be fully indexed and available to the Search API.

Best,

Jaycee

Hi @Jaycee_Lewis - yes that’s what it looks like I’ll have to do. I was hoping there might be something a bit more solid than that but if that’s the best way to avoid the conflict errors then so be it.

Thanks :+1:

Hi, @ncarps I agree 100%.

I found this bit at the very bottom of the Search API documentation — Limitations. “It may take a few moments for newly created or updated CRM objects to appear in search results.”

Just non-specific enough to allow for some wiggle room flexibility :blush:

Best,

Jaycee