← Back to docs

Quota and billing: what the headers tell you

How included quota and overage interact, what happens at the free plan's limit, and how to read the response headers.

1. The headers

Successful live responses include these three headers:

X-RateLimit-Limit: 100        # your tier's included quota
X-RateLimit-Remaining: 73     # checks left this period
X-RateLimit-Reset: 1717196400 # unix timestamp when the period rolls

On Free, the first live checks are a one-off: they never reset, so there is no X-RateLimit-Reset, and X-RateLimit-Remaining counts what is left of them.

On the Free plan with a card on file, a check past the free ones also carries what it costs if gov.uk answers it:

X-Extra-Check-Price: 0.75 GBP

Test keys don't include these: sandbox mode is free and uncounted.

2. Quota flow

For each live check, the server runs through:

1. Is the subscription past_due or unpaid?
   → 402 PAYMENT_REQUIRED (update payment in /app/billing). On Free with a
     card, only the extra checks stop: the free ones still run.

2. Has the account used its included checks (this month's on a paid plan;
   on Free, the first ones, once)?
   2a. NO  → billable_count += 1, run the check
   2b. YES, a paid plan, or Free with a card → overage_count += 1, run the check
       (no ceiling: every extra check runs and is billed at your plan's rate)
   2c. YES, free plan → 402 QUOTA_EXCEEDED, with two links:
       upgrade_url  (the plans, from Pro at £14 a month for 100)
       add_card_url (stay on Free, £0.75 for each extra check, no monthly fee)

3. Has the per-key RPS limit been hit?
   → 429 RATE_LIMITED, Retry-After in seconds

3. Overage billing

Overage usage is metered to Stripe hourly and settled monthly in arrears on the same invoice as your subscription. Free with a card works the same way with no monthly fee: your first 10 live checks are free, once, then each one is £0.75. There's no "top-up": the cron sets the cumulative overage count, so even a crash + retry won't double-bill (the report is idempotent on Stripe's side via the period-start timestamp).

# Example: Pro tier (£14/mo, 100 included, £0.25/overage), 137 checks this month
included  = 100  -> £14.00 base
overage   = 37   -> 37 × £0.25 = £9.25 metered
Total     =        £23.25 on the next monthly invoice

# Example: Free with a card (no monthly fee, first 10 free, £0.75/check),
# 25 checks in your first month
included  = 10   -> £0.00
overage   = 15   -> 15 × £0.75 = £11.25 metered
Total     =        £11.25 on your next monthly invoice
# ...and 25 checks the month after: 25 × £0.75 = £18.75

4. Watching usage from your code

Read the headers after every successful check; emit a metric when X-RateLimit-Remaining falls below your alarm threshold.

const remaining = Number(res.headers.get('x-ratelimit-remaining') ?? '0');
const limit = Number(res.headers.get('x-ratelimit-limit') ?? '0');
if (limit > 0 && remaining / limit < 0.1) {
  myMetrics.gauge('rtw.quota.remaining_pct', remaining / limit);
}

5. The dashboard view

/app/usage shows your current period's billable, overage, and daily breakdown: the same numbers the headers expose, plotted over time.