Webhook to notify custom URL of unsubscribe



I’d like to have Hubspot notify me when a user opts out of all emails so that I may mark that user as unsubscribed in my database.

I’ve created an app, set up a webhook subscription on property change and activated the subscription. I then went through the OAuth2 authorization property to “install” the app in my Hubspot portal (and got a code back).

So far, I’m seeing no link in either the developer app or the portal. From what I understand, I need to generate an access key that will expire every six hours and need to be re-generated?

Is there a simpler version of having Hubspot notify my custom URL when a user opts out?



Hi @travisroberts,

Once you have the code, you’ll use that in tandem with the first endpoint below to get your access and refresh tokens. After that, when the access token expires every 6 hours, you can make a request to the second endpoint below (using your refresh token) to generate a new access token. This is only necessary for setting the integration up and making requests to the portal; once you’ve set up your subscriptions (third document below), HubSpot will send notifications without any intervention.


Thanks Derek,

I think I’ve finally got the webhook connected to the portal and I can see requests coming in. Since the webhook payload doesn’t include the email address of the contact, I’m guessing I need to use the objectId to retrieve the contact from the API. I’ve tried to make a request to https://api.hubapi.com/contacts/v1/contact/vid/THEOBJECTID/profile?hapikey=MY_APPS_HAPIKEY (with the correct values) and I’m getting a “contact does not exist” response. The scope of the OAuth authorization covered contacts, so is there something I’m missing about retrieving contact details based on the information in the webhook payload?



Hi @travisroberts,

You’re correct that you’ll need to pull the contact info using the contacts API, but you’ll want to use the hapikey from the portal that the webhook message came from, not from your developer portal. The portalId parameter in webhook messages tell you which portal in which the contact exists.