API Rate Limits and 429 Errors: Backing Off With Retry-After

API Rate Limits and 429 Errors: Backing Off With Retry-After

A 429 Too Many Requests answer means you sent more requests than the API allows in a period of time. The request did nothing, so nothing is lost: read the Retry-After header, wait that many seconds, and send the same request again. For other temporary failures, such as a timeout or a 503, wait a little longer after each try, with some randomness added (exponential backoff with jitter).

Below: how the TalismanLeads verification API counts its limits, the headers that tell you where you stand, a small Python and Node.js client that does both, and how to design a job that rarely sees a 429.

Why APIs limit requests#

A rate limit protects the service and every customer on it:

  • Fairness. Checks run on shared capacity, so one customer's runaway loop must not hold up everyone else's orders.
  • Cost. Some calls are expensive. A price estimate reads the whole list, so estimates have a lower limit than status reads.
  • Safety. A stuck script, or someone guessing keys, is stopped early instead of running all night.

RFC 6585 defines 429 but leaves it to each server how to count, so every API counts a little differently.

How the TalismanLeads API counts requests#

Every call counts against a limit per customer, across all your keys. Making a second key does not give you a second allowance (see API Key Security: Creating, Storing and Rotating Your Keys). The count runs in calendar minutes: it starts again at the top of each minute, not 60 seconds after your first call.

The admin sets the limits, so they can change. The Rate limits page of the docs always shows the ones in force. On November 24, 2026 it listed:

  • Reads: GET /account, GET /checkers, GET /orders and GET /orders/{id}, 60 a minute.
  • Result downloads: GET /orders/{id}/results, 30 a minute.
  • Uploads: POST /uploads, 10 a minute.
  • Estimates: POST /estimates, 10 a minute.
  • New orders: POST /orders, 10 a minute.
  • Open work: 20 task parts unfinished at once.
  • Wrong keys: 20 a minute per IP address.

Yours may differ: an account on a business trial gets a share of each limit until its first top-up, and an account can be given limits of its own. Ask the API:

cURL
curl -i "https://api.talismanleads.io/v1/account" \
  -H "Authorization: Bearer $TALISMANLEADS_API_KEY"
JSON
{
  "balance": "100.00",
  "currency": "USD",
  "limits": {
    "reads_per_minute": 60,
    "result_downloads_per_minute": 30,
    "uploads_per_minute": 10,
    "estimates_per_minute": 10,
    "orders_per_minute": 10,
    "open_task_parts": 20
  }
}

That is an example answer, shortened. GET /account is a read itself, so call it when your job starts, not before every request.

Retrying an order does not use up the order limit#

The order limit counts new orders. Repeating an order with the same Idempotency-Key after a lost answer returns the same order (200 with Idempotent-Replay: true) and does not count, so a safe retry is never refused for being a retry. To stop a broken loop, all order requests together are held to six times the order limit, and at least 60 a minute. More in Idempotency Keys: How to Retry an API Request Without Paying Twice.

Open orders: too_many_open_orders#

A large order is split into task parts, one for each 1,000,000 entries. When too many of your parts are still running, a new order is refused with 429 too_many_open_orders and Retry-After: 60: wait, then repeat it with the same key. A single order may go over the limit when nothing else is open.

Uploads: a daily allowance as well#

Lists over 100,000 entries go through POST /uploads, which has an allowance besides its per-minute limit: 20 files or 100 MB waiting at once, and 500 uploads a day. Past it you get 429 too_many_uploads without a Retry-After, because seconds of waiting will not fix it. Order from an upload you already have, or wait: an unused upload is removed after 24 hours.

Wrong keys#

Requests with a key that does not exist are counted by IP address, and past 20 in a minute they are answered 429 rate_limited. The real problem is the 401 invalid_key before it: fix the key rather than retry.

Reading the RateLimit headers#

Most answers carry three headers about the limit the call counted against:

HTTP
RateLimit-Limit: 60
RateLimit-Remaining: 12
RateLimit-Reset: 23

RateLimit-Limit is the limit for this kind of call, RateLimit-Remaining how many are left this minute, and RateLimit-Reset the seconds until the count starts again. This three-field form comes from earlier versions of the IETF's RateLimit header draft; the latest version uses RateLimit and RateLimit-Policy instead and is still a draft, so other APIs may differ.

  • Pace yourself from them. When RateLimit-Remaining reaches 0, hold the next call of that kind for RateLimit-Reset seconds instead of sending it to be refused.
  • Never require them. They can be absent, for example on a repeated order.

Every answer also carries a Request-Id header. Log it: support can find any request by it.

Honouring Retry-After#

A 429 from this API looks like this (an example):

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

{"error": {"code": "rate_limited",
  "message": "You are sending requests too quickly. Slow down and try again.",
  "request_id": "req_4f9c2a7e1b3d4c5e8f60718293a4b5c6",
  "docs_url": "https://docs.talismanleads.io/errors#rate_limited"}}

Retry-After is the number of seconds to wait. Because the window is a calendar minute, on rate_limited it is the time left until the next minute starts: never more than 60 seconds, and the same as RateLimit-Reset. Wait that long, then send the same request again, with the same Idempotency-Key if it is an order. The refused request did nothing and charged nothing.

  • Never retry sooner than told. A retry inside the same minute is refused again.
  • Add a little jitter. Every refused client resumes at the top of the minute; a random 0 to 1 second on top keeps your workers from arriving at the same instant.
  • Accept a date as well. RFC 9110 allows Retry-After to be a date. This API sends seconds, but a reusable client should handle both.

Exponential backoff with jitter for other errors#

Some failures carry no Retry-After but are still worth retrying: a timeout or dropped connection, a gateway's 502 or 504 page, 500 internal_error, 503 service_unavailable and 503 order_status_unknown. For these, wait longer after each failed try, and pick the wait at random:

Code
wait = random(0, min(cap, base × 2^attempt))

With a base of 2 seconds and a cap of 60, the first retry waits up to 2 seconds, the next up to 4, then 8, 16, 32 and 60. The randomness is what matters when many clients fail at once: Marc Brooker's analysis on the AWS Architecture Blog found that plain exponential backoff still sends retries in waves, and that "full jitter" spreads them out and cuts the total work.

Two exceptions on this API:

  • order_status_unknown means an order may or may not have been placed. Wait at least a minute between repeats, always with the same key, and contact support with the request_id if it lasts more than a few minutes.
  • Other 4xx answers are not retried. invalid_request, insufficient_balance, idempotency_conflict or price_changed will give the same answer however long you wait; fix the cause. Each code is explained in Verification API Errors: What Each Code Means and What to Do.

A small client that does both#

Both versions wait out an empty window from the headers, honour Retry-After (seconds or a date) with jitter, back off on timeouts and 5xx answers, keep one Idempotency-Key for every repeat of an order, and stop on any other 4xx. Set TALISMANLEADS_API_KEY first; a key looks like tl_live_....

Python#

It needs the requests package.

Python
import os
import random
import time
import uuid
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime

import requests

API = os.environ.get("TALISMANLEADS_API_URL", "https://api.talismanleads.io/v1")
KEY = os.environ["TALISMANLEADS_API_KEY"]
MAX_TRIES = 8


def limit_of(method, path):
    """Which of the API's limits a call counts against."""
    if method == "GET":
        return "results" if path.endswith("/results") else "reads"
    return path.strip("/").split("/")[0]  # "orders", "estimates" or "uploads"


def retry_after(value):
    """Retry-After in seconds: a number, or (by the HTTP standard) a date."""
    if not value:
        return None
    if value.strip().isdigit():
        return int(value)
    try:
        when = parsedate_to_datetime(value)
        return max(0.0, (when - datetime.now(timezone.utc)).total_seconds())
    except (TypeError, ValueError):
        return None


def backoff(attempt, base=2.0, cap=60.0):
    """Exponential backoff with full jitter: anywhere from 0 to base * 2^attempt, capped."""
    return random.uniform(0, min(cap, base * 2 ** attempt))


class Client:
    def __init__(self):
        self.session = requests.Session()
        self.session.headers["Authorization"] = f"Bearer {KEY}"
        self.resume_at = {}  # limit -> the moment its window starts again

    def call(self, method, path, json=None, idempotency_key=None):
        limit = limit_of(method, path)
        headers = {"Idempotency-Key": idempotency_key} if idempotency_key else {}
        for attempt in range(MAX_TRIES):
            # Out of calls of this kind this minute: wait for the window first.
            pause = self.resume_at.get(limit, 0) - time.monotonic()
            if pause > 0:
                time.sleep(pause)
            try:
                r = self.session.request(method, API + path, json=json,
                                         headers=headers, timeout=330)
            except (requests.ConnectionError, requests.Timeout):
                time.sleep(backoff(attempt))  # lost answer: same request, same key
                continue

            # Remember what the headers say, so the next call does not hit the limit.
            remaining = r.headers.get("RateLimit-Remaining")
            reset = r.headers.get("RateLimit-Reset")
            if remaining == "0" and reset and reset.isdigit():
                self.resume_at[limit] = time.monotonic() + int(reset)

            try:
                body = r.json()
            except ValueError:
                body = None  # a gateway's 502 or 504 page is not JSON
            if r.ok:
                return body
            code = ((body or {}).get("error") or {}).get("code")

            if r.status_code == 429 and code != "too_many_uploads":
                wait = retry_after(r.headers.get("Retry-After"))
                # Never sooner than told; a little jitter so clients do not all return at once.
                time.sleep((wait if wait is not None else backoff(attempt)) + random.uniform(0, 1))
                continue
            if r.status_code >= 500:
                floor = 60 if code == "order_status_unknown" else 0
                time.sleep(max(floor, backoff(attempt)))
                continue
            # Any other 4xx is a mistake to fix, not a reason to wait.
            error = (body or {}).get("error", {})
            raise RuntimeError(f"{r.status_code} {code}: {error.get('message')} "
                               f"(request {error.get('request_id')})")
        raise RuntimeError(f"Gave up on {method} {path} after {MAX_TRIES} tries")


if __name__ == "__main__":
    api = Client()
    print("Limits in force:", api.call("GET", "/account")["limits"])
    entries = ["+14155550142", "+12125550187"]
    quote = api.call("POST", "/estimates",
                     json={"checker": "global_carrier_checker", "entries": entries})
    order = api.call("POST", "/orders",
                     json={"checker": "global_carrier_checker", "entries": entries,
                           "expected_charge": quote["charge"]},
                     idempotency_key=str(uuid.uuid4()))  # one key, kept for every retry
    print("Order", order["id"], order["status"])

Node.js#

For Node.js 18 or later, which has fetch built in. Save it as client.mjs.

JavaScript
import { randomUUID } from "node:crypto";

const API = process.env.TALISMANLEADS_API_URL ?? "https://api.talismanleads.io/v1";
const KEY = process.env.TALISMANLEADS_API_KEY;
const MAX_TRIES = 8;
const sleep = (seconds) => new Promise((done) => setTimeout(done, seconds * 1000));

// Which of the API's limits a call counts against.
function limitOf(method, path) {
  if (method === "GET") return path.endsWith("/results") ? "results" : "reads";
  return path.split("/")[1]; // "orders", "estimates" or "uploads"
}

// Retry-After in seconds: a number, or (by the HTTP standard) a date.
function retryAfter(value) {
  if (!value) return null;
  if (/^\d+$/.test(value.trim())) return Number(value);
  const when = Date.parse(value);
  return Number.isNaN(when) ? null : Math.max(0, (when - Date.now()) / 1000);
}

// Exponential backoff with full jitter: anywhere from 0 to base * 2^attempt, capped.
const backoff = (attempt, base = 2, cap = 60) => Math.random() * Math.min(cap, base * 2 ** attempt);

const resumeAt = new Map(); // limit -> the moment its window starts again

export async function call(method, path, { json, idempotencyKey } = {}) {
  const limit = limitOf(method, path);
  for (let attempt = 0; attempt < MAX_TRIES; attempt++) {
    // Out of calls of this kind this minute: wait for the window first.
    const pause = (resumeAt.get(limit) ?? 0) - Date.now();
    if (pause > 0) await sleep(pause / 1000);

    let r;
    try {
      r = await fetch(API + path, {
        method,
        headers: {
          Authorization: `Bearer ${KEY}`,
          ...(json ? { "Content-Type": "application/json" } : {}),
          ...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}),
        },
        body: json ? JSON.stringify(json) : undefined,
        signal: AbortSignal.timeout(330_000),
      });
    } catch {
      await sleep(backoff(attempt)); // lost answer: same request, same key
      continue;
    }

    // Remember what the headers say, so the next call does not hit the limit.
    const remaining = r.headers.get("RateLimit-Remaining");
    const reset = r.headers.get("RateLimit-Reset");
    if (remaining === "0" && /^\d+$/.test(reset ?? "")) resumeAt.set(limit, Date.now() + Number(reset) * 1000);

    const body = await r.json().catch(() => null); // a gateway's 502 or 504 page is not JSON
    if (r.ok) return body;
    const code = body?.error?.code;

    if (r.status === 429 && code !== "too_many_uploads") {
      // Never sooner than told; a little jitter so clients do not all return at once.
      await sleep((retryAfter(r.headers.get("Retry-After")) ?? backoff(attempt)) + Math.random());
      continue;
    }
    if (r.status >= 500) {
      await sleep(Math.max(code === "order_status_unknown" ? 60 : 0, backoff(attempt)));
      continue;
    }
    // Any other 4xx is a mistake to fix, not a reason to wait.
    throw new Error(`${r.status} ${code}: ${body?.error?.message} (request ${body?.error?.request_id})`);
  }
  throw new Error(`Gave up on ${method} ${path} after ${MAX_TRIES} tries`);
}

if (import.meta.url === `file://${process.argv[1]}`) {
  console.log("Limits in force:", (await call("GET", "/account")).limits);
  const entries = ["+14155550142", "+12125550187"];
  const quote = await call("POST", "/estimates", { json: { checker: "global_carrier_checker", entries } });
  const order = await call("POST", "/orders", {
    json: { checker: "global_carrier_checker", entries, expected_charge: quote.charge },
    idempotencyKey: randomUUID(), // one key, kept for every retry
  });
  console.log("Order", order.id, order.status);
}

We ran both against a stand-in API that answered with an empty window, a 429 whose Retry-After was a date, a 503, a dropped connection, too_many_open_orders, a placed order, a replay, too_many_uploads and a 400. Each waited as told, repeated the order with the key it started with, and stopped at once on the last two.

The 330-second timeout is deliberate: an estimate or order of a large list can take up to five minutes to answer. Share one client (or one queue) between your workers, so they share what the headers say.

Designing a job that stays under the limits#

Batch entries into fewer orders. One order takes up to 100,000 entries in the request, or 10,000,000 as an upload, so never place one order per customer. Collect new sign-ups and send them every 15 minutes or every hour. It saves money too: every order is billed as at least 2,000 entries, so on the Number Carrier Lookup a one-number order costs the same $0.24 as a 2,000-number one. Checking sign-ups this way is covered in How to Check New Sign-Ups' Phones and Emails by API.

Poll less often, and poll the list. Ask for an order's status every 30 seconds or more. With several orders running, one GET /orders?limit=100 returns the newest 100 with their status, instead of one read per order. Stop once an order is completed, partially_completed or failed. How an order moves through its states is in Quote, Order, Follow: How an Asynchronous Verification Job Works.

Estimate once per order. Pass its charge as expected_charge, and do not estimate again on every retry.

Queue your own orders. If a large re-check is split into many orders, send the next when one finishes rather than all at once into too_many_open_orders. Re-Checking a Customer List on a Schedule With the API covers a nightly or monthly run.

Remember the limits are shared. Your sign-up checks, nightly re-check and a colleague's test script all draw on one allowance. If you genuinely need more, contact TalismanLeads with what you are building; the API terms forbid getting around a limit with several accounts.

Frequently asked questions#

What does 429 Too Many Requests mean?#

You sent more requests than the API allows in a period of time. The request changed nothing and charged nothing: wait as Retry-After says, then send it again.

How long should I wait after a 429?#

As long as Retry-After says, plus up to a second of jitter. On the TalismanLeads API that is the rest of the current minute for rate_limited and 60 seconds for too_many_open_orders. With no Retry-After, back off exponentially with jitter.

Is Retry-After always a number of seconds?#

No. The HTTP standard allows seconds or a date. The TalismanLeads API sends seconds, but a general client should read both.

Does retrying an order count against the rate limit?#

Not against the new-order limit, and it never charges twice. All order requests together are held to six times the order limit (at least 60 a minute), which only a broken loop reaches.

Do more API keys give me higher limits?#

No. Limits count per customer across all your keys. GET /v1/account shows yours; contact support to ask for more.

Should I retry every error with backoff?#

No. Retry timeouts, dropped connections and 5xx answers with backoff, and a 429 after Retry-After. Any other 4xx, such as insufficient_balance, repeats until you fix its cause.

The limits in force for every account are on the Rate limits page of the API documentation. Make a key under API keys in your account, and start with GET /v1/account to see your own.

Was this helpful?