Switchflag
API

Rate Limiting

Token bucket rate limiting at 100 requests per minute per API key, with retry headers.

Limits

MetricValue
Max requests100 per minute
WindowSliding window (token bucket)
ScopePer API key (per environment)

Rate limit headers

Every API response includes rate limit headers:

HeaderDescription
X-RateLimit-LimitMaximum requests allowed per window (always 100)
X-RateLimit-RemainingRequests remaining in the current window

When rate limited

When you exceed the limit, the API returns 429 Too Many Requests:

{
  "error": "Too many requests"
}

The response includes an additional header:

HeaderDescription
Retry-AfterSeconds to wait before retrying

How it works

The rate limiter uses a token bucket algorithm:

  1. Each API key starts with 100 tokens
  2. Each request consumes 1 token
  3. Tokens refill proportionally over the 60-second window
  4. If no tokens remain, the request is rejected with 429

The token refill is continuous — you don't have to wait for the full window to reset. If you've used 100 tokens and wait 6 seconds, you'll get ~10 tokens back.

Best practices

  • Use the SDK — the SDK caches flag configs in memory, so you only hit the API once per flag key (standard) or once per 60 seconds (edge)
  • Check X-RateLimit-Remaining — monitor this header to detect when you're approaching the limit
  • Respect Retry-After — when rate limited, wait the specified duration before retrying