APIs & Integrations

Bertrand2
Member

Retrieve contact id after contact creation

Hi,

I’d like to know how to best store the Hubspot identifier associated with a newly created contact.

Upon user creation in our app we send a POST request to:

POST https://forms.hubspot.com/uploads/form/v2/:portal_id/:form_guid

According to the documentation and true to our experience of the API, this API call returns a 204 HTTP response code upon successful creation, but returns an empty body (i.e. does not return the identifier for the newly created contact).

We’ve thought about sending a subsequent request to:

GET /contacts/v1/contact/email/:contact_email/profile

right after the first API call, but we’re afraid that there might be a race condition in the WRITE / READ pattern it induces (i.e. if there’s some latency in the second call doesn’t see the newly created user).

Are those two calls generally safe to issue one after another.

We’d like to store the Hubspot identifier on our app’s side so that all calls to the API at a later date can be based on that identifier instead of the user email, which can be updated at any time.

Thanks for your reply on this matter.

1 Reply 1
Dadams
HubSpot Employee
HubSpot Employee

Retrieve contact id after contact creation

Hi @Bertrand

The form submission and contact creation are asynchronous, so if you’re making the GET request immediately after the POST the contact may not exist yet. The process normally takes less than a second but there is going to be a delay.

You’ll normally be able to get the contact record if you delay the GET by a few seconds. Otherwise, if this process isn’t very time sensitive, you could also run a job that periodically checks for the records in batches:

Get a batch of contacts by email address

GET /contacts/v1/contact/emails/batch/ - For a given portal, return information about a group of contacts by their email addresses.

0 Upvotes