Laravel 7 min read

Laravel API rate limits: handling 429 errors in a business sync

Laravel integration stopping with 429 errors? How I investigate API limits, retries, queue behaviour and saved progress before scoping a reliable recovery plan.

Laravel API rate limits: handling 429 errors in a business sync

Your Laravel application starts an accounts sync or stock import, makes some progress, then stops when the connected API returns 429 Too Many Requests. Running it again might finish the work. It might also repeat records that were already sent, or hit the same limit immediately.

I would treat this as an integration workflow to investigate: which requests are being limited, what happens to unfinished work, and how the application resumes. A higher retry count is only useful when the retry behaviour and saved progress are correct.

Confirm which system is returning the 429

The HTTP specification defining 429 describes a rate-limit response: too many requests within a period. The response may include a Retry-After header describing how long to wait.

First, I would establish whether the response comes from the external API, a gateway in front of it, or the Laravel application's own endpoint. Those lead to different investigations. Changing an inbound Laravel rate limiter would not fix a provider limiting outbound requests from your application.

I would record the request's destination, operation, timestamp, response status and relevant rate-limit information, with credentials and personal data removed. Then I would compare that evidence with the provider's current documentation. Different APIs can count requests in different ways; one integration's timing rules should not be copied into another without checking.

Count all the work sharing the allowance

A sync can look reasonable in isolation while several workers, scheduled imports and manual actions are all making requests through the same account. I would map those callers before deciding how fast any one job should run.

For example, a staff member pressing “sync now” while a scheduled import is running could create overlapping work. That is an example to test, not a diagnosis I would assume. I would look for the actual request pattern and whether the API applies its limit per account, credential, endpoint or another documented scope.

The plan may need coordination across callers. Slowing one loop while the other workers continue unchanged may leave the overall request rate too high.

Check that Laravel recognises the failed request

Laravel's HTTP client documentation explains that ordinary client requests do not automatically throw exceptions for every 4xx or 5xx response. The response needs appropriate status handling, or explicit exception handling configured by the application. Requests using retry behaviour also need their configured failure behaviour reviewed.

I would inspect what the integration does with a 429 response. Does it record a retryable interruption, incorrectly mark the batch as complete, or continue parsing an error body as if it contained normal records? A job finishing without an exception does not prove the external operation succeeded.

Does an API limit keep stopping your sync?I can review the requests, queue behaviour and saved progress, then scope a recovery path that fits the connected service and your business workflow.
Discuss your API integration with Adam

Make the waiting and retry policy deliberate

I would use the provider's documented retry guidance, including a valid Retry-After value when supplied. Where it does not provide a wait time, the application needs a bounded policy appropriate to that service. Repeated immediate retries are not a recovery plan.

Laravel's HTTP client provides configurable retry behaviour, including delays and a condition deciding whether to retry. Those are building blocks. They do not decide which business operations can safely be repeated or coordinate every other request using the same allowance.

I would distinguish a rate limit from a validation error, expired credentials and an uncertain network outcome. Each can require a different response. I would also consider spacing retries so several waiting workers do not all resume together and recreate the same burst.

Let queued work wait without losing its retry budget

If a provider requires a substantial pause, I would review whether the job should be delayed rather than hold a worker waiting. Laravel's queue documentation describes releasing jobs to run later and configuring their allowed attempts or retry period.

The settings need to work together. A job repeatedly released because of rate limiting can use up allowed attempts. Increasing attempts indefinitely can hide a permanent fault. I would agree when work should retry, when it should become a visible failure and who is responsible for recovery.

I would also check how delayed integration work affects unrelated jobs. An accounts sync waiting for an API should not accidentally consume all the capacity needed for another important application workflow.

Save a reliable checkpoint before resuming

For an import, I would review what “progress” means: a completed record, page, batch or provider cursor. A checkpoint should represent work that actually completed. Advancing it past a failed response can cause records to be skipped.

Partial completion needs an explicit plan. If some records were saved before the interruption, restarting the batch should account for those records. If a cursor can expire or source data can change during a long pause, the recovery method needs to respect the provider's behaviour.

Sending data to another system adds another question: can a repeat request create another order, invoice or stock movement? I would review stable identifiers, existing-record checks and any provider-supported idempotency mechanism. An idempotency key is only useful when the API supports the intended operation and the application uses it consistently. I have covered the related problem of duplicate orders in a Laravel API integration separately.

Make paused, failed and completed work visible

The person relying on the sync needs to know whether it is waiting for a retry, requires intervention or has finished. I would propose a useful record of the run: its last confirmed progress, next intended retry, relevant failure reason and reconciliation status.

For a business-critical integration, “the queue is running” is not a sufficient completion check. I would compare expected work with confirmed results and decide how exceptions are presented. Logs should support that investigation without storing secret keys or unnecessary customer information.

If the queue itself is not processing jobs, that is another part of the diagnosis. My article on Laravel queues that stop processing emails and imports explains where I would start with that situation.

Test the interruption and the recovery

I would test controlled response sequences in an isolated environment, without creating real charges or duplicate external records. Useful scenarios include:

  • A successful batch followed by a 429, then a later successful retry.
  • A rate limit with a documented wait time, and one without that header.
  • Repeated limits that reach the application's recovery deadline.
  • Two callers sharing the same constrained integration.
  • A partial write or uncertain response that must not create a duplicate.

The test should verify what was saved, what was retried and what the user sees. After release, I would monitor the actual provider responses and backlog. A passing local test does not prove a production request allowance has changed.

My Laravel development and ongoing support work includes API integrations, inherited codebase reviews and reliability fixes. The right scope depends on the existing implementation, the connected service and the consequences of missing or repeated work.

Get a clearer recovery plan for your integrationTell me which systems are connected, what stops syncing and how you currently restart the work. You work directly with me, Adam Dawson, to scope the investigation and next steps. Please leave API keys, passwords and customer records out of the initial enquiry.
Talk to Adam about your syncExplore Laravel support

Need a hand with this?

Get help with accounting data, unreliable background jobs and integrations that need to be understood and supported.

A related project

Making accounting sync visible and recoverable

Background invoice synchronisation with progress, failure reporting and matching between accounting records and operational orders.

Talk directly to Adam

Share this article

Back to Blog