How to Post/Push HubSpot Created contact through my Post API to my DB?

contacts

#1

Hello,
I’ve been struggling to identify the exact flow of getting Contacts from HubSpot and post them to my db as soon as contact gets created. What I’ve done so far:

  1. Created an app using Developer Account and mentioned these details:

    • Details Section: App name, Author name, Short Description, Logo Image
    • Monitoring Section: Nothing
    • Webhook Subscriptions: Created new “Contact Creation” subscription and under Configure section in “Webhook URL” Specified my post API that will require authentication and would expect contact JSON to create a new entry in my database.
    • Timeline API: I’m not sure what it is for and what should I enter here?
  2. installed this app by creating Authorize URL and directly hitting this URL in browser. After granting this app the access, I got to see this app into “Integrations” section of the Hubspot portal (other than Developer account).

  3. Now every time when I’m creating a new contact, I can see few errors (with status code 401 i.e. Authentication Error) in Monitoring section of the app in developer portal.

What I’m trying to figure out here is:

  • Where should I authenticate my API?
  • Where should I map which fields should be posted to my post API?

Any help would be greatly appreciated!


#2

Hi @shilpasoni

Are you seeing the 401 responses in the webhook logging? The only authentication we’d support with webhooks would be a static key in the URL (similar to our hapikey=xxxx used for our API keys). Otherwise, you can verify that the data is coming from HubSpot based on the X-HubSpot-Signature we include in the requests, documented here:

Webhooks would only send the data related to the webhook, which wouldn’t include any properties if you’re watching for new records. You’d need to separately pull the details for the contacts using the Contacts API if you need to get all of the properties.


#3

Hi @dadams,

Thanks for the response! And where can I map the fields? i.e. suppose if I need contacts to be created into my database as soon as they get created in HubSpot, where can I specify that contact’s firstname should be into “firstname” key’s value of my API’s JSON? Or should my API directly expects a Json String as parameter?

Regards,
Shilpa


#4

There isn’t a way to adjust which properties would be included in the webhook response. Property change webhooks will contain the new value of the property, but creation webhooks won’t contain any property data (you can see examples of a property update and contact creation payload here).

If you need to get the data for the contact, you’ll need to pull the record data using the Contacts API. The webhook will contain an objectId which would be the contact vid for contacts, so you can use this endpoint to get the data for the contacts you’d get from the webhooks:


#5

Hi @dadams,

I have an issue and I tried to search for keywords in the forum and came across this post. We have built an integration where we sometimes send Hubspot contacts over to a sales system by enrolling them in workflows and thereby sending them via webhooks, and I wanted to build some security around on the webhook side by comparing a hash to the header “X-Hubspot-Signature” you mention.

The problem is that I don’t seem to get that header key at all. Below is a code snippet of my webhook, and this is the string I get in my database:

Connection, Content-Length, Content-Type, Accept-Encoding, Host, User-Agent, X-HubSpot-Client-IP, X-HubSpot-Correlation-Id, X-HubSpot-Caller, X-HubSpot-Timeout-Millis

Can you provide some insight here?

Thanks, and kind regards,

/Noah

public class HS_qualified_lead_test_security_webhook : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
	    var ok = true;
	    using (var rdr = new StreamReader(context.Request.InputStream))
	    {
		    var headers = string.Join(", ", context.Request.Headers.AllKeys);
                        // save headers to db
	    }

	    context.Response.StatusCode = (int)HttpStatusCode.NoContent ;
    }

    public bool IsReusable => false;

}