Skip to content

Rate limits

Each API key has a per-minute budget, and a developer account has a second budget shared by all its keys of one kind. The window slides: it counts the last 60 seconds.

Budgets

KeyPer keyPer developer account
Test key (hsl_test_)60 requests a minute120 a minute across all its test keys
Live key (hsl_live_)120 requests a minute300 a minute across all its live keys
Key issued by a Heka SoftLink administratorSet per key (120 by default)—

Going over a key’s own budget returns 429 with code rate_limited. Going over the account budget returns 429 with code developer_rate_limited. Both send Retry-After. The X-RateLimit-*headers describe the key’s own budget.

Headers

HeaderMeaning
X-RateLimit-LimitRequests allowed per 60 seconds for this key
X-RateLimit-RemainingRequests left in the current window
X-RateLimit-ResetUnix time (seconds) when the oldest counted request leaves the window
Retry-AfterOn 429 only: seconds to wait before retrying
429 Too Many Requests
HTTP/1.1 429 Too Many Requests
Retry-After: 17
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 0

{ "error": { "type": "rate_limit_error", "code": "rate_limited",
  "message": "Rate limit of 120 requests per minute exceeded", "request_id": "req_…" } }

Retrying

async function withRetry(doFetch: () => Promise<Response>, attempts = 5) {
  for (let i = 0; ; i++) {
    const res = await doFetch()
    if (res.status !== 429 && res.status < 500) return res
    if (i === attempts - 1) return res
    const retryAfter = Number(res.headers.get('retry-after'))
    const wait = retryAfter > 0 ? retryAfter * 1000 : Math.min(30_000, 500 * 2 ** i)
    await new Promise((r) => setTimeout(r, wait + Math.random() * 250))
  }
}

Combine retries with an Idempotency-Key on writes so that a retry can never double-apply.

Staying under the limit

  • Batch usage: one POST can carry up to 500 records.
  • Use webhooks instead of polling for invoice and payment changes.
  • Page with limit=100 rather than many small pages.
  • Holding more keys does not raise a developer account’s budget: the account budget covers all its keys of one kind. Developer key budgets are fixed; only keys issued by a Heka SoftLink administrator have a limit that can be changed.