---
title: "Events — HTTP Client Rate Limits for Laravel | Roundly"
description: "RequestDeferred, RequestAllowed and RateLimitReset events to log, chart or alert on throttling — or switch them off for zero overhead."
url: https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel/events
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[HTTP Client Rate Limits for Laravel](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)

# Events

When events\_enabled is on (the default), the limiter dispatches:

- RequestDeferred — string $key, int $delayMs, int $hitsInWindow, Timespan $timespan — right before a request is paused because the budget is exhausted (again, if the request loses the slot to another worker while it waits). The key, count and window describe the window that forced the wait (for a compound limit, the strictest one); hitsInWindow is the real number of requests recorded in it, 0 when an adaptive server penalty alone caused the wait.
- RequestAllowed — string $key, int $hitsInWindow, Timespan $timespan — after a request is recorded and allowed through, with the primary window’s hit count including this request.
- RateLimitReset — string $key — after ->reset() cleared a limit’s recorded hits (the primary limit’s key).

All three live in RoundlyConsulting\\HttpClientRateLimits\\Events. Listen for them to log, chart or alert on throttling:

```php
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\HttpClientRateLimits\Events\RequestDeferred;

Event::listen(function (RequestDeferred $event): void {
    logger()->warning('Throttled outbound request', [
        'key' => $event->key,
        'delay_ms' => $event->delayMs,
        'window' => $event->timespan->value,
    ]);
});
```

```php
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\HttpClientRateLimits\Events\RequestAllowed;

Event::listen(function (RequestAllowed $event): void {
    logger()->debug('Outbound request allowed', [
        'key' => $event->key,
        'hits' => $event->hitsInWindow,
        'window' => $event->timespan->label(), // 'Second' | 'Minute' | 'Hour' | 'Day'
    ]);
});
```

```php
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\HttpClientRateLimits\Events\RateLimitReset;

Event::listen(function (RateLimitReset $event): void {
    logger()->info('Rate limit reset', ['key' => $event->key]);
});
```

## Turning events off

Set events\_enabled to false for the lowest possible overhead:

```bash
HTTP_CLIENT_RATE_LIMITS_EVENTS_ENABLED=false
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)
