A useful rate-limit API tells a client three things: what limit applies, how much capacity remains, and when it is reasonable to try again. It should also return 429 Too Many Requests when the client exceeds that limit. That sounds simple, but the details determine whether customers can integrate smoothly—or build retry loops that make an overload worse.

For a small public API, my recommendation is conservative: publish a small set of headers with clearly documented semantics, include Retry-After on throttled responses, and do not promise a permanent standardized format until the relevant IETF work becomes an RFC.

The short answer

A practical baseline response looks like this:

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 30
RateLimit-Limit: 100
RateLimit-Remaining: 0
RateLimit-Reset: 45

In this example:

  • RateLimit-Limit is the quota for the applicable policy.
  • RateLimit-Remaining is the capacity still available under that policy.
  • RateLimit-Reset indicates when the quota state resets.
  • Retry-After tells the client how long to wait before retrying the rejected request.

Those names come from an older IETF Internet-Draft. The newer work uses structured RateLimit and RateLimit-Policy fields, but it remains an Internet-Draft rather than an RFC. Because its syntax can still change, a small API should not force customers to depend on the newest proposed format without a compatibility plan.

The broader principle matters more than the exact header names: make the server’s enforcement behavior legible without revealing the controls used to resist abuse.

Start with the quota semantics, not the headers

Before writing response code, define what the server actually enforces. “100 requests per minute” is not complete enough for an API contract.

Document at least these questions:

  1. What is counted? Requests, content bytes, concurrent requests, or another unit.
  2. What is the scope? API key, customer account, IP address, endpoint, tier, or some combination.
  3. Which policy applies when several limits exist? A customer may have both a monthly request quota and a short burst limit.
  4. Is the window fixed or sliding? These produce different remaining-capacity and reset behavior.
  5. Does a rejected request consume quota? State this explicitly.
  6. Which requests are exempt? Health checks, idempotent reads, or internal traffic may need different treatment.

These are product decisions as much as infrastructure decisions. If your documentation cannot answer them, adding more headers will only make ambiguity look precise.

A four-field contract for a small API

For most small APIs, start with the older, familiar set:

RateLimit-Limit: 100
RateLimit-Remaining: 17
RateLimit-Reset: 42

Then use Retry-After when a request is actually rejected:

HTTP/1.1 429 Too Many Requests
Retry-After: 42
RateLimit-Limit: 100
RateLimit-Remaining: 0
RateLimit-Reset: 42

This is deliberately modest. It is easier for an indie developer to maintain than a large matrix of headers for every internal limit. It also gives customers enough information to avoid obvious retry storms.

But the fields must agree. If Retry-After says 42 seconds while RateLimit-Reset says 90, a client must choose between contradictory instructions. Prefer one clear value when both represent the same retry opportunity. If they describe different policies, identify the policy rather than forcing clients to guess.

A note on units

The older draft describes RateLimit-Reset in seconds until quota reset, while many APIs publish a Unix timestamp under an X-RateLimit-Reset name. That ambiguity is a common source of client bugs. Do not copy a timestamp convention without documenting it.

For a new contract using the older field names, explicitly define:

RateLimit-Reset is the number of seconds until the current quota window resets.

Clients must not interpret the value as an absolute timestamp. If you need an absolute time, define a separate field with an unambiguous name and format.

What RateLimit-Remaining should actually mean

“Remaining” sounds obvious, but it is not useful if it does not map to what the client is allowed to do next.

For a simple fixed-window limiter, the contract can be straightforward:

RateLimit-Limit: 100
RateLimit-Remaining: 17
RateLimit-Reset: 42

This says that the client may make 17 more requests before the next reset, after which the advertised quota returns to 100.

That interpretation becomes questionable for token-bucket, leaky-bucket, sliding-window, or concurrent-request limiters. A concurrency limit, for example, does not naturally have a count of future requests. A token bucket’s capacity can be expressed in tokens, but those tokens may not correspond one-for-one with requests if requests have different costs.

Therefore, either:

  • use simple request-count semantics and enforce them consistently; or
  • name the limit unit explicitly, for example RateLimit-Remaining-Requests and RateLimit-Limit-Requests; or
  • use a more expressive contract that can identify the policy and its unit.

Do not publish a bare request count for a weighted limiter. A request costing ten units is not equivalent to one costing one, and a client cannot safely pace itself from a misleading integer.

RateLimit-Reset is a client hint, not a guarantee

Even with a fixed-window limiter, a reset time can be approximate by the time a client reads the response. Network delay, clock differences, and concurrent requests can all affect the result.

Use it as guidance:

  • Do not promise that capacity will be restored at the exact second.
  • Do not use it as a synchronization lock.
  • Do not let a client schedule a large synchronized retry at the same instant as many other clients.
  • Build in jitter when clients add their own backoff.

For fixed windows, clients can also spread retries across a small interval around the advertised reset time. This is often more reliable than every client retrying on the same second.

A useful client-side policy is:

  1. Honor Retry-After when present.
  2. Otherwise use the documented reset guidance.
  3. Add random jitter.
  4. Retry only if the request is safe to repeat.
  5. Cap attempts rather than retrying indefinitely.

The server should still use Retry-After when it knows when the rejected request may succeed. It is more direct than making the client infer a delay from quota metadata.

Retry-After belongs on the 429

Retry-After has a defined role: it tells the client when to make a follow-up request. On a 429, it should normally describe the delay before retrying the request that was rejected.

A safe response is:

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 30
RateLimit-Limit: 100
RateLimit-Remaining: 0
RateLimit-Reset: 30

{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Too many requests. Retry after 30 seconds."
  }
}

The body should be useful to humans debugging an integration, but it should not repeat sensitive details. Avoid naming the exact internal rule that triggered the rejection if revealing it would help someone evade that control.

There is one important distinction: the rejected request did not necessarily consume quota. In a fixed-window design, a request received after the quota reaches zero may be rejected without decrementing the counter further. State this in your documentation because retry-heavy clients can otherwise create additional load without making progress.

Send quota information before rejection

Rate-limit headers are most valuable on successful responses. If a client sees that only two requests remain, it can slow down before receiving a 429.

A practical policy is:

  • include the quota headers on successful responses when inexpensive to calculate;
  • include them on 429 responses;
  • include them on errors that still consumed quota, so the client can update its view;
  • omit them when the server genuinely cannot provide reliable information.

Do not fabricate 0 because you do not know the remaining capacity. An unknown state and an exhausted quota are different. If omission is possible, omit the field; if omission breaks parsing, document that behavior.

For high-volume APIs, sending headers on every response may add unnecessary work. A small API should favor clear behavior over premature optimization. Measure the actual cost before introducing sampling or header omission.

Multiple limits require multiple policies

Real APIs often enforce several limits simultaneously. A customer might have:

  • a short burst allowance;
  • a sustained daily request allowance;
  • a concurrency limit;
  • an account-wide spending cap.

A single set of three headers cannot honestly describe all of them. Either document that the response exposes only one “primary” policy, or use distinct field names or a structured representation.

For example, a custom but readable contract might look like:

RateLimit-Burst-Limit: 20
RateLimit-Burst-Remaining: 4
RateLimit-Burst-Reset: 12
RateLimit-Monthly-Limit: 100000
RateLimit-Monthly-Remaining: 87342
RateLimit-Monthly-Reset: 518400

This is not a proposed standard, but it makes the scope explicit. Custom fields are acceptable when they are documented, consistent, and tested. The tradeoff is that every client must understand them.

The newer IETF draft addresses multiple policies with named structured fields. That approach can be cleaner, but its draft status means an API built around it should either tolerate syntax evolution or wait for final standardization.

What not to expose

Good rate-limit signaling should reduce customer confusion without becoming an abuse-control blueprint. Avoid publishing:

  • internal token-bucket refill rates tied to detection logic;
  • the exact number of abusive requests observed;
  • enforcement thresholds for IP or identity reputation;
  • details that reveal how requests are classified before rejection;
  • separate limits for customers that expose evasion opportunities.

There is a balance here. Clients need enough information to pace themselves, but they do not need to know every internal defense. If several controls can produce a 429, return one consistent public contract rather than revealing which internal rule fired.

Do not include a raw error such as “IP reputation threshold exceeded” if a generic “rate limit exceeded” communicates enough for correct client behavior. Detailed operational diagnostics can stay in server-side logs, where authorized staff can inspect them.

A practical implementation checklist

Before publishing your rate-limit contract, verify the following:

Enforcement

  • Every response that consumes quota updates the remaining count.
  • Rejected requests do not unexpectedly consume additional quota.
  • The count and reset value describe the same policy and scope.
  • Multiple active limits are represented clearly or deliberately excluded and documented.

Headers

  • RateLimit-Limit is the applicable quota.
  • RateLimit-Remaining is non-negative and uses the documented unit.
  • RateLimit-Reset is documented as a relative duration, not an ambiguous timestamp.
  • 429 responses include Retry-After whenever a retry delay can be advised.
  • Values are computed from the same state used for enforcement, not estimated in a separate path.

Client guidance

  • The documentation says whether all requests or only successful requests count.
  • It explains which requests are exempt, if any.
  • It provides copyable retry logic with exponential backoff and jitter.
  • It warns against retrying non-idempotent operations without an idempotency strategy.
  • It explains that reset timing is approximate.

Privacy and security

  • The public error does not reveal sensitive enforcement logic.
  • Logs retain detailed diagnostics without returning them to clients.
  • User-supplied identifiers do not become part of public header names or values.
  • Repeated 429 responses do not leak whether an account exists.

Test the contract, not only the limiter

Unit tests for the limiter are necessary but insufficient. Test the HTTP behavior your customers consume.

At minimum, verify:

Request 1: 200, remaining decreases by one
Request N: 200, remaining reaches zero
Request N+1: 429, Retry-After present
After the advised delay: request accepted
Concurrent requests: counts remain internally consistent
Multiple policies: response is not misleading

Also inspect actual response headers rather than only the limiter’s internal state. Middleware, gateways, and error handlers can drop or overwrite headers.

For a commercial API, monitor the rate of 429 responses, retry attempts after 429, quota exhaustion by customer segment, and mismatches between advertised and enforced capacity. The goal is not merely to count rejections. It is to learn whether customers are integrating correctly or whether your limits are creating avoidable friction.

For a broader view of the operational metrics worth tracking, see AI API Usage Analytics for Small Teams: What to Measure Before You Buy More Tools.

Should you use the newer RateLimit fields?

The short answer is: not exclusively, unless your clients can tolerate a draft and you have a migration plan.

The current draft-ietf-httpapi-ratelimit-headers work defines richer structured headers:

RateLimit-Policy: "default";q=5000;w=3600
RateLimit: "default";r=0;t=45
Retry-After: 45

The policy describes the quota, window, and unit. The current-state header connects that result to a policy and reports remaining quota and timing. The structure can express multiple policies more cleanly than three independent custom headers.

However, it is still an Internet-Draft. It has Standards Track intent, but it is not an RFC, and its syntax remains subject to change. That makes a draft-only commitment risky for a small API whose customer integrations may last longer than the current implementation effort.

A conservative path is:

  1. Implement the familiar RateLimit-Limit, RateLimit-Remaining, and RateLimit-Reset contract.
  2. Include Retry-After on 429 responses.
  3. Document every field precisely.
  4. Keep the internal policy representation separate from the public response format.
  5. Reassess the standards status before making a breaking change.

That separation allows you to adopt a finalized format later without redesigning your limiter.

The decision in one minute

If you are launching a small public API, choose the boring path:

  • define one clear request quota first;
  • expose limit, remaining capacity, and relative reset timing;
  • put Retry-After on every useful 429 response;
  • keep the values consistent with actual enforcement;
  • document units, scope, counting behavior, and reset semantics;
  • use additional named headers or a structured policy when one limit is not enough;
  • keep sensitive abuse controls out of the public contract.

The goal is not to advertise how defensively your service is built. The goal is to let legitimate clients deliver their work without guessing, failing, or generating a retry storm.

Frequently asked questions

Should RateLimit-Reset contain a Unix timestamp?

Only if your documentation explicitly says so. Many older X-RateLimit-Reset conventions use Unix timestamps, while the older IETF RateLimit-Reset draft describes a relative reset delay. Mixing these meanings creates immediate integration errors. For a new API, a documented duration in seconds is often easier to inspect and test.

Does every response need rate-limit headers?

Not technically, but successful responses are the best early-warning signal. Include them when you can calculate them reliably. Always include useful retry guidance on 429 responses.

Should clients retry a 429 immediately?

No. An immediate retry consumes capacity and can worsen the incident. Honor Retry-After, add jitter, cap attempts, and avoid blindly repeating non-idempotent work.

Can I publish only Retry-After?

You can, and it solves the immediate retry decision. It does not tell a client how close it is to exhaustion, so proactive pacing remains difficult. Combining Retry-After with quota state gives better integration guidance.

Is the newer structured draft safe to use now?

It can be useful for controlled experimentation, but it is not finalized. Do not call it an RFC or build an irreversible client contract around syntax that may change. Keep public serialization behind an adapter if you experiment with it.

Sources