> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apostra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate Limits

> API rate limits, 429 responses, backoff, and when to prefer webhooks to polling

The API enforces per-IP and per-account rate limits to keep the platform healthy. When you exceed a limit you'll get a `429 Too Many Requests` response — back off and respect the `Retry-After` header.

## 429 response shape

When rate-limited, the API returns the standard error envelope with `code: "RATE_LIMITED"` and includes IETF-standard rate limit headers (`draft-7`):

```http theme={null}
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 60
RateLimit-Limit: 100
RateLimit-Remaining: 0
RateLimit-Reset: 60

{
  "data": null,
  "error": {
    "code": "RATE_LIMITED",
    "message": "Too many requests"
  }
}
```

| Header | Meaning |
| - | - |
| `Retry-After` | Seconds to wait before retrying. **Always honor this value.** |
| `RateLimit-Limit` | Max requests allowed in the current window |
| `RateLimit-Remaining` | Requests remaining in the current window |
| `RateLimit-Reset` | Seconds until the window resets |

> [!TIP]
>
> Read `RateLimit-Remaining` on every response — not just on 429s. Slow down
> preemptively when it's low rather than waiting for a hard rejection.

## General limits

| Scope | Window | Limit |
| - | - | - |
| General API endpoints (per IP) | 1 minute | 100 requests |
| Auth endpoints (`/auth/*`) | 15 minutes | 40 requests (production) |
| Signup endpoints | 1 hour | 60 requests (production) |
| Password reset | 1 hour | 12 requests (production) |
| Emails to one address (verification resend, password reset, access request) | 1 hour | 5 requests (production) |
| Object creation, every `POST` on authenticated v2 routes (per account) | 1 minute | 600 requests (production) |
| Catalog refresh and `/chat` model calls (per account) | 1 minute | 30 requests (production) |

The per-address email limit counts every request for the same address, whether
or not an account exists for it, so a capped response never reveals whether an
address is registered.

> [!NOTE]
>
> These are baseline limits. Per-account quotas are tier-based and may differ
> from the per-IP defaults shown above. If you hit `RATE_LIMITED` consistently
> during normal operation, contact \[
> [support@apostra.com](mailto:support@apostra.com)]\(mailto:[support@apostra.com](mailto:support@apostra.com)) for a higher-tier quota.

## Backoff strategy

When you receive a 429 (or a transient `INTERNAL_ERROR` / `SERVICE_UNAVAILABLE`):

1. **Honor `Retry-After`.** It's the source of truth for when to retry.
2. **Add jitter.** If many clients retry at the same moment you'll thunder onto a recovering server. Add ±25% random jitter to the wait.
3. **Cap retries.** After 3–5 attempts, surface the error to the user rather than retrying silently.
4. **Be careful retrying mutations.** Retrying `POST /campaigns` after a 5xx may create duplicates — for creates, prefer to surface the error to the user rather than auto-retry.

```typescript theme={null}
async function withBackoff<T>(fn: () => Promise<Response>, max = 5): Promise<T> {
  for (let attempt = 0; attempt < max; attempt++) {
    const res = await fn();
    if (res.ok) return res.json().then((j) => j.data);

    if (res.status === 429 || res.status >= 500) {
      const retryAfter = Number(res.headers.get("Retry-After") ?? 2 ** attempt);
      const jitter = retryAfter * (0.75 + Math.random() * 0.5);
      await new Promise((r) => setTimeout(r, jitter * 1000));
      continue;
    }
    // 4xx other than 429 — don't retry
    throw await res.json();
  }
  throw new Error("max retries exceeded");
}
```

## Webhooks vs polling

For long-running operations where state changes are sparse, prefer webhooks where they're offered (campaigns, media buys, notifications). Webhook delivery removes the polling tax entirely. See [Notifications](https://docs.apostra.com/v2/guides/notifications.md) for the supported event topics.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.