Skip to content

Errors, credits and rate limits

The error format, what each status means, and how to handle 402 and 429.

Last updated

The error format#

Every failure answers JSON with the HTTP status that fits:

json
{ "error": "UPPER_SNAKE_CODE", "message": "..." }

Validation errors add an issues array. Branch on the HTTP status and the error code, never on message, which is for people.

StatusExample errorWhat to do
400VALIDATION_ERRORFix the request; issues names the field (for example a phone outside 6 to 20 characters)
401AUTHENTICATION_FAILEDThe x-api-key was sent but isn't a working key: check it wasn't deleted, turned off or expired
402INSUFFICIENT_CREDITSThe workspace has no credits left; add credits or a plan under Billing
403ACCESS_DENIEDThe key may not make this request, or no key was sent at all
429Too many requests; wait Retry-After seconds and retry
500INTERNAL_SERVER_ERRORRetry with backoff
503The request couldn't be served right now; it says nothing about your request, so send it again

Credits#

Each lookup spends its tier's credits from the workspace of the key: 1 for GET /phone/details; 3 for GET /phone/extra-details and 6 for GET /phone/full-details on a NANP number in the NPA-NXX registry, 1 for any other number. A number that answers valid: false is still a lookup and spends its credits.

402 INSUFFICIENT_CREDITS is a billing signal, not a validation result: don't treat the number as invalid. Top up on the pricing page or turn on auto top-up; see Plans, credit packs and auto top-up.

Rate limits#

The API's authentication guide (opens another site) gives each key's per-minute limit. Past it the API answers 429 with a Retry-After header in seconds. Wait that long, then retry:

ts
async function lookup(phone: string) {
  const url = 'https://api.phone-check.app/phone/details?phone=' + encodeURIComponent(phone);
  const response = await fetch(url, { headers: { 'x-api-key': process.env.API_KEY ?? '' } });
  if (response.status === 429) {
    const seconds = Number(response.headers.get('retry-after') ?? '1');
    await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
    return lookup(phone);
  }
  return response.json();
}

For large lists, the Bulk Checker paces the checks for you.

Was this helpful?

Still need help?