Missing OAuth scope to subscribe to webhook events

I’m backend developer integrating my company’s website to our HubSpot account. I’m using the HS API to update our HS contacts & companies with changes from our website, no problem.

I also want to update our website data with changes made directly by our support staff on our HubSpot account. I use webhooks for that, with the OAUTH flow, etc, and that works when I manually subscribe to events through the HubSpot page for our account.

However, I need to be able to create event subscriptions programmatically through the API. I think my code is good, but I get the scopes exception error:

"HubSpot\Client\Webhooks\ApiException: [403] Client error: `POST https://api.hubapi.com/webhooks/v3/xxx/subscriptions?hapikey=xxx` resulted in a `403 Forbidden` response:
{"status":"error","message":"This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes."

I initially had just the “contacts” scope in my OAUTH configuration for the app, I deleted & re-created the URL & request in the application page with the additional scopes ‘integration-sync’, ‘crm.import’ & ‘oauth’ as well as ‘contacts’, regenerated the access & refresh tokens, but I still get the same error.

Am I missing a required scope, or am I missing a required step?

Hey @ChrisNY,

I believe this is because you’re using the portal hapikey key instead of the developer API key.

Since you’re managing settings of your dev app webhook, could you try using your developer API keys and see if it works?

For more details on how to access your developer API keys, you can reference this documentation: Developer API keys.

First, gotta say you guys set a high standard for great customer support. I submitted the same question to the hubspot community forum, and a support request ticket.

I got answers from the HubSpot team on both of them - two different answers, but together they solved my problem.

Ivan noted I needed to add the ‘timeline’ scope to my OAuth permissions. Wendy cleverly surmised I was using the portal API key (which I use to modify contacts & companies), instead of the developer API key, which I need to modify the WebHook event subscriptions.

So now all works, thanks!