# Webhook through accesstoken for private apps

**URL:** <https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599>\
**Category:** APIs & Integrations\
**Tags:** webhooks\
**Created:** [May 21, 2024, 5:47am UTC](https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599 "2024-05-21T05:47:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gayathri139](https://avatars.discourse-cdn.com/v4/letter/g/4da419/32.png) [@gayathri139](https://community.hubspot.com/u/gayathri139)\
**Post date:** [May 21, 2024, 5:47am UTC](https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599/1 "2024-05-21T05:47:19Z")

</div>

Can we update the webhookurl or hit these endpoint “[https://api.hubapi.com/webhooks/v3/appId/subscriptions](https://api.hubapi.com/webhooks/v3/appId/subscriptions)” or “[https://api.hubapi.com/webhooks/v3/appId/settings](https://api.hubapi.com/webhooks/v3/appId/settings)” with access token.I tried with api key it worked but i want to hit through access token to update my webhook settings ,Is it possible?If possible, How?

---

<div class="post-metadata">

**Author:** ![james-portant](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/james-portant/32/104419_2.png) [@james-portant](https://community.hubspot.com/u/james-portant)\
**Post date:** [May 21, 2024, 1:15pm UTC](https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599/2 "2024-05-21T13:15:44Z")

</div>

Hi @gayathri139,

Yes, it is possible to update the webhook URL or hit the specified endpoints using an access token for private apps in HubSpot.  
HubSpot is deprecating API keys in favor of OAuth access tokens, you should be able to perform these actions with an access token.

Here is a step-by-step guide on how to achieve this:

### 1. Obtain the Access Token

First, ensure you have the access token for your private app:

1. Navigate to your HubSpot account.
2. Go to **Settings** \> **Integrations** \> **Private Apps**.
3. Create a new private app and ensure you have the appropriate scopes (permissions) for managing webhooks.
4. Copy the access token provided.

### 2. Update Webhook Settings Using Access Token

You can use the access token to authenticate your requests to the HubSpot API. Here is an example using the curl command to update webhook settings.

#### Update Subscription Endpoint

To update webhook subscriptions, you can use the following curl command:

curl --request POST \ --url [https://api.hubapi.com/webhooks/v3/{appId}/subscriptions](https://api.hubapi.com/webhooks/v3/%7BappId%7D/subscriptions) \ --header ‘Authorization: Bearer YOUR\_ACCESS\_TOKEN’ \ --header ‘Content-Type: application/json’ \ --data ‘{ “subscriptionDetails”: { “eventType”: “contact.creation”, “propertyName”: “email” } }’

Replace YOUR\_ACCESS\_TOKEN with your actual access token and {appId} with your app ID. Modify the subscriptionDetails as per your requirements.

#### Update Webhook URL Endpoint

To update the webhook URL settings, you can use the following curl command:

curl --request PUT \ --url [https://api.hubapi.com/webhooks/v3/{appId}/settings](https://api.hubapi.com/webhooks/v3/%7BappId%7D/settings) \ --header ‘Authorization: Bearer YOUR\_ACCESS\_TOKEN’ \ --header ‘Content-Type: application/json’ \ --data ‘{ “webhookUrl”: “[https://your-new-webhook-url.com](https://your-new-webhook-url.com)”, “maxConcurrentRequests”: 5 }’

Replace YOUR\_ACCESS\_TOKEN with your actual access token, {appId} with your app ID, and [https://your-new-webhook-url.com](https://your-new-webhook-url.com) with your new webhook URL. You can also adjust maxConcurrentRequests as needed.

### Example Using a Programming Language

If you prefer using a programming language like Python, here is an example using the requests library:

import requests # Replace with your actual values access\_token = ‘YOUR\_ACCESS\_TOKEN’ app\_id = ‘YOUR\_APP\_ID’ webhook\_url = ‘[https://your-new-webhook-url.com](https://your-new-webhook-url.com)’ # Update webhook settings url = f’[https://api.hubapi.com/webhooks/v3/{app\_id}/settings](https://api.hubapi.com/webhooks/v3/%7Bapp%5C_id%7D/settings)’ headers = { ‘Authorization’: f’Bearer {access\_token}', ‘Content-Type’: ‘application/json’ } data = { “webhookUrl”: webhook\_url, “maxConcurrentRequests”: 5 } response = requests.put(url, headers=headers, json=data) if response.status\_code == 200: print(“Webhook URL updated successfully.”) else: print(f"Failed to update webhook URL: {response.status\_code} - {response.text}")

### 

Make sure your private app has the necessary scopes to manage webhooks. Using the Authorization: Bearer YOUR\_ACCESS\_TOKEN header in your requests will authenticate them correctly.

If you encounter any issues, double-check your access token and permissions, and ensure your requests are correctly formatted.  
Good luck and please give me a shout if I can help with anything.  
Cheers,  
James - CEO @ [Portant  
 ](http://www.portant.co/)  
**Portant App for HubSpot:** [https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-in…](https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-integration)

---

<div class="post-metadata">

**Author:** ![gayathri139](https://avatars.discourse-cdn.com/v4/letter/g/4da419/32.png) [@gayathri139](https://community.hubspot.com/u/gayathri139)\
**Post date:** [May 21, 2024, 1:45pm UTC](https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599/3 "2024-05-21T13:45:23Z")

</div>

i tried hitting the curls you provided and i got this as response, and could you please share the scopes that are required to hit these.

{

```
"status": "error",

"message": "The scope needed for this API call isn't available for public use. If you have questions, contact support or post in our developer forum.",

"correlationId": "30d4e060-e524-4211-8715-5e7f724eba11",

"links": {

    "support": "https://help.hubspot.com/",

    "forum": "https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations"

},

"category": "MISSING\_SCOPES"

```

}

---

<div class="post-metadata">

**Author:** ![james-portant](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/james-portant/32/104419_2.png) [@james-portant](https://community.hubspot.com/u/james-portant)\
**Post date:** [May 21, 2024, 3:14pm UTC](https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599/4 "2024-05-21T15:14:40Z")

</div>

Sorry @gayathri139 , maybe I copied it wrong:  
curl --request PUT \  
--url ‘[https://api.hubapi.com/webhooks/v3//settings?hapikey=YOUR\_HUBSPOT\_DEVELOPER\_API\_KEY](https://api.hubapi.com/webhooks/v3//settings?hapikey=YOUR_HUBSPOT_DEVELOPER_API_KEY)’ \  
--header ‘content-type: application/json’ \  
--data ‘{  
“throttling”: {  
“period”: “SECONDLY”,  
“maxConcurrentRequests”: 5  
},  
“targetUrl”: “[https://www.example.com/hubspot/target](https://www.example.com/hubspot/target)”  
}’  
Found here: [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/webhooks)

For scopes:

- Go to **Settings** \> **Integrations** \> **Private Apps**.
- Select your private app.
- Ensure that the following scopes are enabled:
  - webhooks
  - Any other specific scopes required for your API operations (e.g., contacts if you are dealing with contact creation).

I hope that works this time.

Cheers,

James

---

<div class="post-metadata">

**Author:** ![gayathri139](https://avatars.discourse-cdn.com/v4/letter/g/4da419/32.png) [@gayathri139](https://community.hubspot.com/u/gayathri139)\
**Post date:** [May 22, 2024, 5:58am UTC](https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599/5 "2024-05-22T05:58:25Z")

</div>

Hii James, Thanks for the time and assistance.  
You provided the curl to hit it with api key, but i need it to hit through ACCESS TOKEN,Thats my actual requirement. You again provided the curl which i have already tried and got the response using api key.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 22, 2024, 9:12pm UTC](https://community.hubspot.com/t/webhook-through-accesstoken-for-private-apps/107599/6 "2024-05-22T21:12:05Z")

</div>

Hey, @gayathri139 👋 Happy to help clarify things here.

Looking at the [documentation](https://developers.hubspot.com/docs/api/webhooks#:~:text=You%20can%20also%20manage%20webhooks%20in%20a%20private%20app.%20In%20private%20apps%2C%20webhook%20settings%20can%20only%20be%20edited%20in%20the%20in%2Dapp%20settings%20for%20your%20private%20app%2C%20and%20cannot%20currently%20be%20edited%20through%20the%20API.):

- The Webhooks API can **only** be accessed using your Developer API key — “Webhooks are set up for a HubSpot app, not individual accounts.”
- You can set up and manage Webhooks via a Private App, but it **must** be done in-app – “You can also [manage webhooks in a private app](https://developers.hubspot.com/docs/api/create-and-edit-webhook-subscriptions-in-private-apps). In private apps, webhook settings can only be edited in the in-app settings for your private app, and **cannot currently be edited through the API**.”. Otherwise, if you try to use your Private App token using the Webhooks API, you’ll get an error (as you noted)

If you have a Public App (using OAuth) you can use the Developer API key and The Webhooks API to setup and manage your webhook subscriptions. If you are using a Private App, it must be done in-app.

I hope this helps get you moving forward.

Best,

Jaycee
