# 429 API Rate Limit Error

**URL:** <https://community.hubspot.com/t/429-api-rate-limit-error/53250>\
**Category:** Data Hub\
**Created:** [March 16, 2022, 8:27am UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250 "2022-03-16T08:27:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [March 16, 2022, 8:27am UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/1 "2022-03-16T08:27:48Z")

</div>

Hey RevOps-Gang,

hope you’re all doing well. I encountered a problem in a Custom Code Action recently which I thought HubSpot took care of, on its own, but I might be wrong. I have a Python-based action that does multiple requests against the HubSpot API. Some requests cannot be done with the api-library (e.g. HubDB stuff with filtering and sorting) so I use the **requests** library for that.

As mentioned in the documentation [here](https://developers.hubspot.com/docs/api/workflows/custom-code-actions)

_If the call fails due to a rate limiting error, or a 429 or 5XX error from [axios](https://www.npmjs.com/package/axios) or [@hubspot/api-client](https://www.npmjs.com/package/@hubspot/api-client), HubSpot will reattempt to execute your action for up to three days, starting one minute after failure. Subsequent failures will be retried at increasing intervals, with a maximum gap of eight hours between tries_

I’m not entirely sure, but this should also mean that calls with the requests library are also retried if it encounters a rate limit error, correct?

Most of these calls follow this pattern with _try_ and _except_ statements:

`try: getPlantContent = requests.get( "https://api.hubapi.com/cms/v3/hubdb/tables/plant_content/rows?" + plantContentProperties + plantContentFilters + "&hapikey=" + os.getenv( "HAPIKEY")).json()["results"][0]["values"]except ApiException as e: print("Exception when calling rows_api->get_table_rows: %s\n" % e)`

Now, I’ve noticed that this is missing the raise keyword in the except block. Is this of importance? If so, what does it do? The only info I found is that it re-raises the exception if there is no other argument associated with raise.

Thank you all for your help! Please be easy on me since I’m not a trained dev.

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![MiaSrebrnjak](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miasrebrnjak/32/10_2.png) [@MiaSrebrnjak](https://community.hubspot.com/u/MiaSrebrnjak)\
**Post date:** [March 18, 2022, 2:41pm UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/2 "2022-03-18T14:41:04Z")

</div>

Hi @ChrisoKlepke,

Thank you for reaching out to the Community!

I want to tag in some subject matter experts to see if they have any suggestions.

Hi @JBeatty, @taran42, [@A\_Wessolly](https://community.hubspot.com/t5/user/viewprofilepage/user-id/328782), do you have any thoughts on this? Thank you!!

Cheers  
Mia, Community Team

---

<div class="post-metadata">

**Author:** ![tfoston01](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@tfoston01](https://community.hubspot.com/u/tfoston01)\
**Post date:** [April 16, 2022, 1:34pm UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/3 "2022-04-16T13:34:28Z")

</div>

Looking at this phrase…

If the call fails due to a rate limiting error, or a 429 or 5XX error from axios or @hubspot/api-client, HubSpot will reattempt to execute your action for up to three days, starting one minute after failure. Subsequent failures will be retried at increasing intervals, with a maximum gap of eight hours between tries

Unless your script is also going to run long to take full advantage of the long time span of re-trying you shouldn’t count on this. When you’re running into persistent API rate limiting issues, you’ll want to consider some level of decoupling to your flow. I would suggest looking into making a job queue to break up your processes up so that you’re better able to regulate the API calls

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [April 19, 2022, 6:41am UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/4 "2022-04-19T06:41:19Z")

</div>

Hey @tfoston01 ,

Thank you very much for getting in on this. I was aware of this sentence in the documentation. What I’m confused by is the wording of that sentence. It seems to me the code action should retry itself if one of the 3 scenarios applies.

- call fails due to a rate limiting error,
- or a 429 or 5XX error from axios
- or @hubspot/api-client,

If I use the requests library and run into a 429 I think the first bullet applies, but in no instance got the action retried. That’s why I suspected something wrong with my code, or more specifically the exception, since it also says in the documentation:

_If you’re using Python and encounter a rate limiting error but you want HubSpot to retry your call, you’ll need to raise the error in the `except` block of your custom code action._

So, either I’m doing something wrong, or the documentation is wrong in that, that the retries are not supported with the requests library. What are your thoughts on this?

In any case, you mentioned a job queue to get around all of that. How would someone create something like that in the custom code action? Is there something you can point me to?

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![tfoston01](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@tfoston01](https://community.hubspot.com/u/tfoston01)\
**Post date:** [April 20, 2022, 4:36am UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/5 "2022-04-20T04:36:03Z")

</div>

The documentation is wrong.

From experience, the SDK will retry a failed API call 6 times max. After that, it stops retrying and you’re on your own to essentially restart things yourself.

At A8Labs, we actually don’t use the SDK and instead make the API calls ourselves using

the axios library. We evaluate the response headers and look for the rate-limiting headers specifically and take pauses/sleep if we can anticipate a 429 coming.

For job queueing and decoupling, please check out the article below

> **[AWS SQS : The Ultimate Decoupling Solution](https://towardsaws.com/aws-sqs-the-ultimate-decoupling-solution-de8a8c8862e7)**
>
> AWS SQS: The Ultimate Decoupling Solution Overview From the time since cloud computing came into existence, it has been revolutionizing and coming up with new services and features for the ease and …

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [April 20, 2022, 6:24am UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/6 "2022-04-20T06:24:05Z")

</div>

Thank you for the insight @tfoston01 . I’m not that familiar with JS and/or axios but if that’s the limitation for Python and the requests library right now I will give this issue to more qualified people than me.

@MiaSrebrnjak, it might be a good idea to check the documentation with the responsible team again and change it if it proves to be confusing.

Maybe @jackcoldrick or @jbogaert are the right people for this?

---

<div class="post-metadata">

**Author:** ![MiaSrebrnjak](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miasrebrnjak/32/10_2.png) [@MiaSrebrnjak](https://community.hubspot.com/u/MiaSrebrnjak)\
**Post date:** [April 20, 2022, 12:42pm UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/7 "2022-04-20T12:42:10Z")

</div>

Hi @ChrisoKlepke, thank you for flagging this! I’ll send it to our technical writers for a review!

Cheers  
Mia, Community Team

---

<div class="post-metadata">

**Author:** ![dthreatt](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dthreatt](https://community.hubspot.com/u/dthreatt)\
**Post date:** [June 14, 2024, 7:35am UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/8 "2024-06-14T07:35:05Z")

</div>

It just doesnt work. I get rate limit errors on workflows that have no APIs or custom codes. Its ridiculous.

---

<div class="post-metadata">

**Author:** ![Unmatched](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/unmatched/32/10061_2.png) [@Unmatched](https://community.hubspot.com/u/Unmatched)\
**Post date:** [April 29, 2024, 8:07pm UTC](https://community.hubspot.com/t/429-api-rate-limit-error/53250/9 "2024-04-29T20:07:33Z")

</div>

Hey! We’ve built an app that will be able to help you with this. It’s called Time Turner, and it allows you to [throttle your HubSpot workflows](https://app.hubspot.com/l/ecosystem/marketplace/apps/_detail/time-turner-workflow-email-drip-feeder) and drip-feed your emails out over time.

Let me know what you think?

[Here’s the install link for Time Turner!](https://app.hubspot.com/l/ecosystem/marketplace/apps/_detail/time-turner-workflow-email-drip-feeder)
