Skip to content
Hardcount
Run it locally
Pre-1.0 · one maintainer · Stripe and cards only · no SDKs (client libraries) yet · no production users yet. Docs describe v0.12.0 (30 Nov 2026) · What’s new →

Rate limits

A rate limit caps how many requests Hardcount accepts in a period. A request over the limit gets 429 and runs nothing. This page gives each limit, the headers that report it, and how to retry.

These are the defaults. The person who runs your Hardcount server can change the first three (see Change a limit).

Requests Limit Counted for each
The API and the dashboard: every /v1 route not listed below 1,000 a minute API key. Dashboard users share one count per account and mode (test or live).
Usage: /v1/usage-events… and /v1/integrations/litellm… 1,000 a second API key, or account and mode for the dashboard
Sign-in, password reset and invites (/v1/auth…), and /v1/bootstrap 100 a minute Client IP address
The hosted invoice page, the payment-update page and the public cost dashboard (/v1/public/…) 60 a minute Client IP address
POST /v1/customers/{customer_id}/payment-methods/send-setup-email 1 a minute, only on a server with Redis Customer
  • Each API key has its own counts. A usage-only key on a gateway and a secret key on your server never use up each other’s limit.
  • One key has two separate counts: one for usage routes, one for every other route.
  • /health, /health/ready, /metrics and the routes Stripe and Postmark call are not counted.

The count refills steadily. It is not reset at the start of each minute. A full allowance lets a burst of up to the limit through at once. After that, one request’s allowance comes back every period ÷ limit: every 60 ms at 1,000 a minute, every second at 60 a minute.

A request with a bad key is refused before it is counted. It gets 401 (see Authentication). A key or session cookie of the wrong shape is refused without reading the database; a well-formed one that matches nothing costs one read. Hardcount does not limit how many requests one address sends before they are authenticated on the /v1 routes that take a key or session cookie, or on the Stripe and Postmark webhooks under /v1/webhooks, which are checked by their signature or password. Put a per-address limit on both in front of Hardcount, in your load balancer or proxy. The proxy in Hardcount’s Compose stack carries one, ready to switch on (how). Its 429 is nginx’s own page, with no Retry-After header, not the answer below.

Every counted response carries three headers:

Header Value
X-RateLimit-Limit The limit, such as 1000
X-RateLimit-Remaining Requests you can send now
X-RateLimit-Reset When your full allowance is back, in Unix seconds

A 429 also carries Retry-After: the number of seconds until your next request can pass, at least 1.

{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "too many requests — please retry after the rate limit resets",
"request_id": "req_…"
}
}

The setup-link email answers cooldown_active instead, with the message a setup link was sent to this customer recently — wait before sending again. It counts every request for that customer that got past the rate limit in the last minute, even one that then failed, for example because the customer has no email.

Sign-in has a second, separate guard: after failed sign-ins it answers 429 with code login_throttled. See Errors.

  1. Wait the number of seconds in Retry-After.
  2. Send the same request again, with the same Idempotency-Key header or the same usage idempotency_key.

A 429 rate_limited or login_throttled ran nothing and stored nothing, so the same key is safe to send again. cooldown_active is different: it is stored under the request’s Idempotency-Key like any other answer, so after the minute, send the request with a new key. See Idempotency.

To stay under the limit:

  • Give each integration its own API key.
  • Send usage in batches: POST /v1/usage-events/batch takes up to 1,000 events in one request.
  • Cache answers you poll, such as the live credit balance.

The two calls page shows a client that waits for Retry-After, in four languages.

Hardcount counts requests in Redis. A production server (APP_ENV=production) refuses to start without a Redis it can reach. If Redis goes down after start-up, each limit acts differently:

Requests In production Elsewhere
The API and the dashboard, /v1/bootstrap, and the public pages Every request gets 429, with Retry-After: 60, until Redis is back Not limited
Usage, and the setup-link email Not limited Not limited
Sign-in, password reset and invites Counted by each server process on its own Counted by each server process on its own

Without Redis, a server with several copies (replicas) lets one address sign in up to the limit on each copy. More: Redis going down after boot.

The person who runs the server sets these, as environment variables. On the Docker Compose stack, add them to deploy/compose/.env, then run docker compose up -d. Each must be a whole number of 1 or more; any other value stops start-up.

Setting Default Limit
HARDCOUNT_RATE_LIMIT_GENERAL_PER_MIN 1000 The API and the dashboard, a minute
HARDCOUNT_RATE_LIMIT_INGEST_PER_SEC 1000 Usage, a second
HARDCOUNT_RATE_LIMIT_AUTH_PER_MIN 100 Sign-in, password reset, invites and /v1/bootstrap, a minute

The public-page limit and the setup-link limit cannot be changed. Behind a load balancer, set TRUST_PROXY, or every client shares the load balancer’s address and its per-address limits. More: Settings.

Stuck, or found a bug? Ask in Discussions · Open an issue