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:
{ "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.
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:
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.
