Contacts added through form API are added as "Offline Sources"

contacts

#1

Hi,

Our application submits new contact to Hubspot by posting to the Hubspot form API. Unfortunately, despite sending the hs_context parameter, with the hutk cookie included, we are getting roughly 50% of contacts listed as coming from Offline Sources.

We also use Hubspot's email API to send a verification email to these new contacts, Our original assumption was that we had a race condition on our end resulting in the email request being sent to Hubspot before the form request. However, even after implementing a 5 second delay between the form API response and the email API send, we are seeing the same problem.

We notice that contacts listed as Offline Sources seem to have the lifecycle set to "Subscriber" before the form submission in their history. Proper contacts (those with sources that are not offline) either get set to "Subscriber" after the form submission, or not at all (going straight to "Lead"). I'm not sure if this is a clue or not at the moment.

Is it possible that Hubspot is giving priority to the email send? What else could cause users that were added via form API submissions to list as offline sources?

Examples of contacts created properly:

Examples of contacts from Offline Sources:

Thanks in advance,
Sam


#3

Hi @sam_topstep, Thank you for providing all that information. It definitely helped when troubleshooting this. To me, it looks like you may have two processes conflicting with one another. From this contact: https://app.hubspot.com/contacts/1806688/contact/60267102/?interaction=note it looks like they were created originally with the Contacts API. On the backend, the email property's original source is API:
http://prntscr.com/livcbn

If they were created with the Forms API, that source should be FORMS.

Further, taking a look at their form submission, they should have been created with the properties first name, last name, email, username, referral-customer and referral invite, but here: https://app.hubspot.com/contacts/1806688/contact/60267102/?interaction=note in the section Anderson Giraldo Mejia submitted v2 Account Creation on API call we only see 2 properties updated. Same thing goes for the other two contacts as well who come from Offline Sources.

This seems to be the issue, but let me know if you have questions.


#4

Hi @Connor_Barley,

Thanks so much for taking the time to look into this.

As far as I know, we're not using the Contact API directly. Would sending an email through the email API end up looking the same?

Edit: Looking over the payload we send with the email API, we are in fact sending the first_name, last_name, username, and email properties with the email call, which would support the idea that they are being updated from there. We delay our email call 5 seconds after our form call. Is that not enough possibly? Is Hubspot giving priority to the email call and pushing it through before the form has a chance to update?

Thanks a ton,
Sam


#5

Hi @sam_topstep, that very well may not be enough time for HubSpot to gather the info, create the record and process it, but I'll have to check on that. It also seems unlikely that it'd be a coincidence that some contacts are being sent an email with those properties included in the payload, and the only two fields that show as being updated in the form are the ones from the form that are not included within the email so you could be very right on that front too. Are you sending off a transactional email with the Single Send API after the Forms API submission? If so, can you link that email here in this thread? Thanks!


#7

Thanks again @Connor_Barley.

Agreed that the matching fields seem a little too perfect to be coincidence, but you never know.

Yes, we are using the Single Send API to send a transactional email as described in the docs you linked. The request is sent 5 seconds after we get a response from the Form API submission.

The email we send is to verify users' email addresses. You can find it here: https://app.hubspot.com/email/1806688/details/5125461403 .

As I mentioned in the original post, only about 50% of our contacts coming in this way are marked as Offline Sources. It's also been very hard to replicate the error reliably, leading me to think it's some sort of race condition between the Form and Sing Send Email API calls.

Let me know what you think, and thanks again!
Sam


#8

Hi @sam_topstep, I'm almost positive that the Single Send API is taking precedence and creating these contacts before the Form submission goes through. Your belief that it's a race condition is probably right. In my experience, sometimes Contacts can take a bit of time to get created in HubSpot. I don't have an exact number because it depends on a lot of factors including if the account the contact is created in has a lot of list-seg, workflows, custom properties, etc. 5 seconds may be too short a wait time, but I also don't know if just waiting more time is the best solution here. It's kind of analogous to a setTimeout function in JS, where you could just delay an action that relies on another process to happen, but there'd be no way to guarantee if the first action had actually been completed. Enter: callbacks / promises.

I'd say the best solution if you can manage it is to save the transactional email for automation in HubSpot, then enroll contacts that come into HubSpot from the Forms API into a workflow. The workflow would then send the transactional email to your contacts who'd already been created in HubSpot, rather than your external system triggering this email. This way you'd guarantee that the contacts were created first before the email was sent. If you rely on custom properties in the Transaction Email API this would not work for you, but if you do not rely on custom properties I'd say this is definitely the most sustainable.

Otherwise you'd need to use a combination of Webhooks to listen for a contact creation or custom property change, then send the email after that, but it'd be a lot of work that may not be worth it.