Guide · updated November 2026

Common Noir SMS API errors and how to handle them

By the Noir SMS team3 min read

Quick answer

API errors use the HTTP status plus a JSON body like {"error": {"code": "...", "message": "..."}}. Switch on the code, not the message. Retry rate_limited (429), provider_error and restocking (502/503) with backoff. Treat no_numbers as "try another country". Fix invalid_api_key (401) and insufficient_balance (402) before retrying. You're never charged for a purchase that returns an error.

A small error-handling layer keeps a panel or bot from showing raw errors to users.

Error codes

HTTPCodeWhat to do
401invalid_api_keyCheck or regenerate the key
402insufficient_balanceTop up; needed shows the price
409price_above_maxRaise max_price or choose another country
400no_numbersNo stock now; try another country
400too_earlyCancel 2 minutes after buying; see waitSeconds
400already_closedThe number was already canceled or expired
400invalid_request / invalid_countryFix the service or country code
403account_suspendedContact support
429rate_limitedWait and retry; limit is 120/min
502/503provider_error / restockingRetry shortly; not charged

A retry pattern

python
import time, requests

RETRY = {"rate_limited", "provider_error", "restocking"}

def buy_with_retry(service, country, max_price, tries=4):
    for i in range(tries):
        r = requests.post(f"{API}/numbers", headers=H, timeout=20,
                          json={"service": service, "country": country, "max_price": max_price})
        if r.status_code == 201:
            return r.json()
        err = r.json()["error"]
        if err["code"] in RETRY:
            time.sleep(2 ** i)       # 1, 2, 4, 8 seconds
            continue
        if err["code"] == "no_numbers":
            return None              # try another country
        raise RuntimeError(f"{err['code']}: {err['message']}")
    return None

resend_refused

When you ask for another SMS with /resend, some carriers refuse. You get resend_refused; the first code is still valid while the number is open.

Use it responsibly

Use the API only for your own legitimate accounts or apps you're authorized to test, and make sure your customers follow the same Acceptable Use Policy.

Frequently asked questions

Am I charged when I get no_numbers?

No. Failed purchases are never charged.

Where do I see my key?

On the API page of your dashboard, where you can also regenerate it.

Services in this guide

Keep reading

Ready to receive your code?

Create a free account, add funds from $5 and get your first verification code in under a minute.