You can cache phone number validation results for SMS, but only the parts that change slowly, and only with a time limit. Cache the format and line type for days to weeks, treat a "disconnected" result as shorter-lived, and never cache an opt-out status, which has to be read live before every send.
The tradeoff is cost against freshness. A validation call adds latency and, depending on how your account is set up, can add cost. A stale result can send a text to a number that changed hands or became a landline. This guide shows how to choose the TTL and how to build the cache.
What a validation result tells you
GET /v1/validate/:phone checks a number before you send. The number validation docs list the fields in the response, so we won't restate them here. In practice a result answers some mix of these questions:
| Question | How fast it changes | Cache it? |
|---|---|---|
| Is the format valid? | Never, for the same string | Yes, indefinitely |
| What line type is it (mobile, landline, VoIP)? | Slowly: ports and reassignment | Yes, with a TTL |
| Is the number active? | Faster: numbers get disconnected and recycled | Short TTL |
| Has the contact opted out? | Instantly | No |
The first row needs no network call at all. Normalize to E.164 locally first, as covered in E.164 formatting for SMS APIs, and use a library to reject malformed input before it ever costs a lookup. See validating with libphonenumber before sending.
Why line type goes stale
Line type feels permanent, but it isn't. A person can port a mobile number to a VoIP provider. A landline owner can move the number to a mobile carrier. A disconnected number can be reassigned months later to a stranger who never agreed to anything.
None of these events tells you. The cache simply gets older and less right. That's why a TTL is a risk setting, not just a speed setting.
Choosing a TTL
There's no universal figure. These are starting points you should tune to your own data and risk, and none of them is a benchmark:
| Result | Starting TTL | Reasoning |
|---|---|---|
| Malformed | Forever | Pure function of the string |
| Valid mobile | 7 to 30 days | Changes rarely, and a wrong guess costs little |
| Landline or VoIP | 1 to 7 days | Re-check sooner, since a conversion matters |
| Inactive or disconnected | 1 to 3 days | May be reassigned or reconnected |
| Lookup failed (timeout) | Do not cache | Not a fact about the number |
Match the TTL to the cost of being wrong. A healthcare reminder platform sending to patients may prefer short TTLs, since texting a recycled number is a bigger problem there. See landline validation in healthcare for that tradeoff.
Build the cache
Key by the normalized E.164 string, store the whole response body untouched, and store the fetch time. Avoid picking fields out of the response, because you'd be guessing at the shape.
const cache = new Map(); // swap for Redis in production
const inflight = new Map();
const TTL_MS = { default: 7 * 24 * 3600 * 1000, short: 24 * 3600 * 1000 };
async function fetchValidation(e164) {
const res = await fetch(
`https://api.tryready.com/v1/validate/${encodeURIComponent(e164)}`,
{ headers: { 'X-API-Key': process.env.READY_API_KEY } }
);
if (res.status === 429 || res.status >= 500) throw new Error('retry later');
if (!res.ok) throw new Error(`validate failed with ${res.status}`);
return res.json();
}
export async function validate(e164, { ttlMs = TTL_MS.default } = {}) {
const hit = cache.get(e164);
if (hit && Date.now() - hit.at < ttlMs) return hit.value;
if (inflight.has(e164)) return inflight.get(e164);
const p = fetchValidation(e164)
.then((value) => {
cache.set(e164, { value, at: Date.now() });
return value;
})
.finally(() => inflight.delete(e164));
inflight.set(e164, p);
return p;
} The inflight map matters on a busy platform. When a campaign imports 5,000 contacts and 40 workers ask about the same number at once, one call goes out and the rest share its result. Don't cache failures: a timeout says nothing about the number.
On a 429 or a 5xx, retry with backoff rather than caching an empty answer. Our post on SMS API circuit breakers and timeouts covers that pattern.
Invalidate on evidence
A TTL is a guess. When you have actual evidence, use it:
- A send that fails as undeliverable should evict that number, so the next send re-checks.
- A reply from a contact you'd cached as a landline is a signal to re-check.
- A bulk import from a new source deserves a fresh pass, since the source's own data may be old.
What never goes in the cache
Opt-out status. A STOP can arrive between a cached "fine" and your next send, and a stale answer there is a compliance problem, not a cost saving. Check GET /v1/opt-outs/:phone at send time. It's a different question with a different clock from the one validation answers. Quiet hours work the same way: they depend on the moment of the send, so a 409 QUIET_HOURS_BLOCK is a time rule, not something to cache against a number.
Ready also refuses numbers its own sends have already seen as landlines, free of charge, on every account. Your cache is a way to avoid repeat lookups and not a replacement for that gate.
Cost versus freshness, in numbers
This is an example with assumed numbers. Say a platform validates 100,000 sends a month across 40,000 distinct numbers, with each number appearing 2.5 times on average. With no cache, that's 100,000 lookups. With a 30-day cache, it's roughly 40,000, a 60% cut in calls. A 7-day cache lands somewhere between, depending on how the sends cluster in time. Multiply the calls you save by your own per-lookup cost, as listed on the pricing page, to see what a longer TTL buys against the staleness you accept.
FAQ
How long can I cache a phone number lookup? For a valid mobile number, days to a few weeks is a reasonable starting point. Shorten it for landline, VoIP and inactive results, and never cache an opt-out status.
Should I validate on every send? Usually not. Validate at contact creation or import, then re-validate on a TTL or when something suggests the number changed.
Can I cache failed lookups? No. A timeout or a 5xx says nothing about the number. Retry with backoff instead.
Next step
Normalize locally, cache the response with a TTL per result type, and keep opt-outs live. For the wider picture of validation before sending, read our phone number validation API guide.