APIs & Integrations

WAkram4
Member

Webhook Infinite Loop

SOLVE

Hello Everyone,
I am using hubspot webhook API. My query is, how I can prevent from infinite loop. My webhook triggers again & again and creating infinite loop. Actually I want my webhook should not trigger when record is created or updated using API. It should only be trigger when record is created or updated using UI.
Thanks

0 Upvotes
1 Accepted solution
zaklein
Solution
Contributor | Diamond Partner
Contributor | Diamond Partner

Webhook Infinite Loop

SOLVE

Hi @WAkram4 

Assuming you are using HubSpot App webhook subscriptions (either via HubSpot App web UI or Webhooks API), there should be a field called "changeSource" in the data sent by HubSpot to your subscribed consumption endpoint.

If, for example, the source of the detected HubSpot CRM record change was an API call, the value supplied within this field should be "API".

The Webhooks API documentation gives the following description for the "changeSource" field: "The source of this change. Can be any of the change sources that you find on contact property histories." This may include, but is not necessarily limited to:

  • CRM_UI
  • FORM
  • CONTACTS
  • ACADEMY
  • IMPORT

I made a note during testing (from a while ago) that a HubSpot App webhook subscription is not triggered if the detected change was initiated by the same app's authentication credentials. Therefore, I wouldn't expect this to be a problem if you're using OAuth credentials from the same app.

But, for whatever reason, if you are using multiple authentication methods, you could consider configuring your webhook consumption endpoint to change its behaviour depending on the "changeSource" field.

I hope that's helpful. Let me know if you have any follow up questions.

All the best,

Zach

View solution in original post

5 Replies 5
WAkram4
Member

Webhook Infinite Loop

SOLVE

Excellent, its working for me.

1) When we update the record using same app and webhook created using UI from the same app. The webhook trigger any time. Whether we update it using API with same app authentication or UI.

2) changeSource option is excellent, it is working for me.

Thank you, it makes my life easy.

zaklein
Solution
Contributor | Diamond Partner
Contributor | Diamond Partner

Webhook Infinite Loop

SOLVE

Hi @WAkram4 

Assuming you are using HubSpot App webhook subscriptions (either via HubSpot App web UI or Webhooks API), there should be a field called "changeSource" in the data sent by HubSpot to your subscribed consumption endpoint.

If, for example, the source of the detected HubSpot CRM record change was an API call, the value supplied within this field should be "API".

The Webhooks API documentation gives the following description for the "changeSource" field: "The source of this change. Can be any of the change sources that you find on contact property histories." This may include, but is not necessarily limited to:

  • CRM_UI
  • FORM
  • CONTACTS
  • ACADEMY
  • IMPORT

I made a note during testing (from a while ago) that a HubSpot App webhook subscription is not triggered if the detected change was initiated by the same app's authentication credentials. Therefore, I wouldn't expect this to be a problem if you're using OAuth credentials from the same app.

But, for whatever reason, if you are using multiple authentication methods, you could consider configuring your webhook consumption endpoint to change its behaviour depending on the "changeSource" field.

I hope that's helpful. Let me know if you have any follow up questions.

All the best,

Zach

JustinDowty
Participant | Diamond Partner
Participant | Diamond Partner

Webhook Infinite Loop

SOLVE

Hey Zach,

 

I came here to ask the same question, and in testing I can see that if my app is both listening for a specific property change via a webhook and is making changes itself, those changes do trigger the webhooks. The only way I can see to ignore webhooks that are triggered due to the app itself is to ignore all webhooks with the changeSource of INTEGRATION. This is not ideal, since there could be other integrations making changes that I would need to account for. I found this post from March that seems to imply a sourceId field that could be useful for this, but I do not see that field available on the webhook payloads: https://developers.hubspot.com/changelog/bugfix-integrations-and-crm-property-change-sources. Is this currently just a limitation we have to live with and ignore all webhooks with a changeSource of INTEGRATION, or is there something I am missing.

dennisedson
HubSpot Product Team
HubSpot Product Team

Webhook Infinite Loop

SOLVE

@zaklein 👋, what is your advice to avoid this 😀

0 Upvotes
WAkram4
Member

Webhook Infinite Loop

SOLVE

Laptop, but its not issue of device. Its issue of developing logic

0 Upvotes