API Scheduling/Limiting/Privacy

Hi all, hope you’re having a good weekend.

I’ve just set up an API to Hubspot via Pathfix and after some tinkering, finally managed to get it create “Companies” in my app, using the data in Hubspot.

I have a couple of things I need to do now, which I’m not sure how to tackle.

  1. I need to give the user the ability to sync my app and Hubspot at any time (in the event they make an update in Hubspot, and need it to pull through immediately.
  • How do I limit this? I don’t want people spamming it.
  1. Once the initial sync has been completed, it should then run automatically at a specified interval.
  • How do I set it up to do this/how do I set up a recurring API call?

  • In theory, there could be quite a lot of data being transferred because I have multiple customer using Hubspot, is it better if I set the API call to run more frequently (say once per hour), or just run it once per day (out of hours). Is there any best practice I should be following here?

  1. I’m currently using a single instance, and controlling privacy/visibility through a field against the company called “Parent Organisation” - if the users parent org does not match the company’s parent org, they can’t see it.
  • If the API call is recurring and “nobody” has triggered it, how can I still set the parent org correctly when I “create a thing”. For example, when the user pushes the sync button, I can easily pass “current users parent org”. I’m probably over thinking this as I guess the workflow somehow still runs against a user?
  1. There are some fields that need to be mapped between the two systems, “name” is populated through the API by default, for example, but there are other fields in my app that don’t have the same naming convention in Hubspot./
  • How can I allow the user to see a list of fields in my app and then choose which fields from Hubspot they map to?

I am not super familiar with the Hubspot API but doing some Googling I see that they support webhooks within HubSpot Apps. Assuming you’re using a Hubspot App within the targeted Hubspot account, a more efficient solution would be to programmatically create one or more webhooks (based on the info you need) when a user connects their Hubspot account. This webhook would hit an API endpoint in your app each time a company is created in the Hubspot account, which you can then use to create the company in your app. The crm.objects.companies.read scope seems to have everything you need for companies, the rest are detailed here: Webhooks API

Yeah but that won’t help for previously created and if you need to sync all data then getting webhooks per change can leads to thousands of calls a hour and unnecessary WU and performance lag.


  1. A button to GET all data that matches criteria. Then store last time it was synced and don’t let the sync button be clickable if the last sync was X hrs ago.

  2. Recurring api call every 24hrs etc or prob a seperate call every day at 3am or so that iterates thru the sync for all companies

  3. Just assing the proper parent company and then reg privacy rule will limit properly

  4. That’s more complicated. You have to manually set up thr get call to include all field names from all your user. Then when creating a new company do conditionals for each field. Eg if a user has first name field as first and another as fname then for the first name in your bubble thing: if first is not empty → first value. Elseif fname is not empty → fname value and so on. It’s not as complicated as it sounds just gotta get it set up…

He already has set up the initial import functionality

Only way that is happening is with webhooks

  1. Makes sense, thank you!

  2. Would you mind just explaining how I set this up? I’m still struggling with recurring workflows.

  3. How does the workflow know which user it is? When the user clicks the sync button, I can send “current user”, but how would this work for a workflow that is recurring?

  4. Ok that makes sense - for now I think I will just do the standard fields and deal with the custom mapping later, given how much work it is.

Thanks for the help.

If the user needs a change to pull through immediately, they can just press the “sync” button and make an API call, no?

Sure, so it’s not about which user in a recurring WF.

The basic setup is something like this:

  1. you have a sync thing that stores the user, active?, date of last sync, etc.
  2. Then you have a API WF which syncs the user’s HubSpot using a GET call and then taking the data and updating / creating the user’s things in Bubble and setting the date of last sync for the user’s sync thing.

So the only difference for the the recurring WF is like this: It runs at X time and makes a list of lsync things where the date of last sync > X mins/hours ago and then processes a API WF on that list (the API WF from #2 above). So instead of based on user its applies the rule for all users / sync things that meet the criteria.

NOTE: User / Company are interchangeable above based on your setup.

IF immediate means only when they push button but not immediate every time there’s a hubspot change then that works just fine. Setting up HubSpot is not as easy as proposed by @aj14 or as it should be because for global webhooks it has to be set up already by the customer b4 any programmatic setup and even then really, not best practices to use that approach and to use HubSpot’s private apps isn’t a picnic.

Sounds good. It’s not as complicated as it sounds, just adding field and conditionals for the values (and a lot easier if most of your customers use similar naming conventions). There’s no excuse for HubSpot not providing slugged field names but whatever.

1 Like

Thank you, very helpful - appreciate you taking the time to answer!