# Quotas, limits and errors

## How a request is admitted

Each customer request passes the same checks, in this order. The first one that fails answers.

<Figure name="quota-flow" caption="The checks every customer request passes. Refusals on the right; only a request that passes them all is counted against the quota." />

Sessions of team members are also checked for a finished two-factor sign-in (`401 two_factor_required`), their role
(`403 role_forbidden`) and, when the package requires it, 2FA set-up (`403 two_factor_setup_required`); see
[Authentication](/authentication).

## Requests per minute

A package may limit requests per minute. Every customer request counts, whatever the route (a request refused with
429 does not). Past the limit the API answers:

```http
HTTP/1.1 429 Too Many Requests
Retry-After: 60
Content-Type: application/json

{ "error": "too many requests" }
```

## Daily and monthly quotas

A package may also have a daily and a monthly **quota** (UTC day, UTC calendar month). Only **metered** routes count,
one request each:

| Metered | Not metered |
| --- | --- |
| `GET /signals`, `GET /signals/{filingId}` | account, billing, delivery, keys, usage, saved views |
| `GET /companies`, `GET /companies/{issuerId}` | `POST /stream/ticket` |
| `GET /leaderboard` | signals pushed on an open stream |
| opening the live stream (once per connection) | anything done with the sandbox key |

Sessions, the live key and named keys all count. The [API reference](/api) marks each operation with `x-metered`.

Every metered answer carries the state of the quotas your package has (only those it has):

| Header | Meaning |
| --- | --- |
| `X-Quota-Limit-Day` | requests per UTC day |
| `X-Quota-Remaining-Day` | requests left today |
| `X-Quota-Reset-Day` | when the day's count starts again (Unix seconds) |
| `X-Quota-Limit-Month`, `X-Quota-Remaining-Month`, `X-Quota-Reset-Month` | the same for the calendar month |

Over a quota the answer is a 429 with a `code` and `Retry-After` in seconds until the reset:

```http
HTTP/1.1 429 Too Many Requests
Retry-After: 41230
X-Quota-Limit-Day: 5000
X-Quota-Remaining-Day: 0
X-Quota-Reset-Day: 1762819200

{ "error": "the daily request quota of 5000 is used up; it resets at 2026-11-11T00:00:00.000Z", "code": "quota_day_exceeded" }
```

Counting is exact: parallel requests cannot pass a quota together, and a refused request is not counted.
`GET /api/v1/customer/usage` (and the portal's **Usage** page) shows today and this month against the quotas,
refusals, and requests per day and per endpoint for the last 30 days.

### Handling 429 well

1. Read `Retry-After` and wait at least that long before the next request of that kind.
2. For `quota_day_exceeded` and `quota_month_exceeded`, stop the job until the reset; retrying sooner only gets the
   same answer.
3. Watch `X-Quota-Remaining-Day` and slow down before you reach zero.
4. Prefer [webhooks](/webhooks) or the [stream](/stream) over polling: pushed signals cost nothing.

```js
async function getWithRetry(url, init, attempts = 3) {
  for (let i = 0; ; i++) {
    const res = await fetch(url, init);
    if (res.status !== 429 || i + 1 >= attempts) return res;
    const body = await res.clone().json().catch(() => ({}));
    if (body.code === "quota_day_exceeded" || body.code === "quota_month_exceeded") return res; // wait for the reset
    const wait = Number(res.headers.get("Retry-After") ?? "60");
    await new Promise((resolve) => setTimeout(resolve, wait * 1000));
  }
}
```

## Other limits

| What | Limit | Answer |
| --- | --- | --- |
| Page size (`limit`) | 1–200 (leaderboard 1–100) | 400 |
| Named API keys | 20 active per account | `409 api_key_limit` |
| Saved views | 50 per account | `409 saved_view_limit` |
| Open streams | 5 per account | `429 stream_limit`, `Retry-After: 30` |
| Stream client messages | 20 per 10 seconds, 4 KiB each | close 1008 |
| Sign-in | 8 wrong passwords per address and place, 15 minutes | `429 throttled` |
| Push test | 5 per hour | 429 |
| Chat | per package, per month and per minute | `429 chat_quota_exceeded`, `chat_rate_limited` |
| Followed companies, alert rules | per package; 20 rules | `409 follow_limit`, `rule_limit` |

## Errors

Every error is JSON with a human sentence in `error` and, where your code may want to branch, a stable `code`:

```json
{ "error": "this API key does not have the signals:read scope", "code": "key_scope" }
```

Branch on the status and `code`, never on the wording of `error`.

| Status | `code` | Meaning |
| --- | --- | --- |
| 400 | (none) | A parameter or body field is invalid; `error` names it |
| 401 | (none) | No credential, or not a valid one (`error: "unauthorized"`) |
| 401 | `two_factor_required` | The session waits for the 2FA code |
| 401 | `code_invalid`, `token_invalid` | A wrong 2FA code, or a used or expired mailed link |
| 402 | `checkout` | Sign-up payment not finished |
| 402 | `canceled` | The subscription ended |
| 402 | `payment_overdue` | A payment failed and the grace period (7 days by default) is over |
| 402 | `subscription_expired` | A paid period ended without renewal |
| 403 | (`error: "paused"`) | The account is suspended; contact RiskPilot |
| 403 | `sandbox_read_only` | The sandbox key on a route other than the signals routes |
| 403 | `key_not_allowed` | A named key on a route that is not a data route |
| 403 | `key_scope` | A named key without the scope |
| 403 | `session_required` | A route that needs a signed-in person, called with a key |
| 403 | `role_forbidden` | A team member's role does not allow it |
| 403 | `two_factor_setup_required` | The package requires 2FA and the person has none |
| 403 | `email_unverified` | Sign-in before the address was confirmed |
| 404 | (none) | Not found, or outside your package (the two look the same) |
| 409 | various | A limit or a state, for example `api_key_limit`, `follow_limit`, `ticket_closed` |
| 429 | (none) | Requests per minute; `Retry-After: 60` |
| 429 | `quota_day_exceeded`, `quota_month_exceeded` | A quota is used up; `Retry-After` to the reset |
| 429 | `stream_limit`, `throttled`, `chat_rate_limited`, `chat_quota_exceeded` | Other limits |
| 502 | `chat_model_failed` and others | An upstream service (payments, the chat model) failed |
| 503 | `stream_off`, `stream_busy`, `push_unavailable`, `chat_unavailable` | A feature is off or busy right now |

While billing does not allow access, the billing and account routes stay open (`GET /customer/billing` shows
`access` and, for `past_due`, `graceUntil`), so an app can send the person to pay.

Every answer carries an `X-Request-Id` header; quote it when you contact support.
