Skip to content
ClearPostcode

Guide

Address validation at checkout

Ask for the postcode first, check it live as the customer types, then offer the addresses on it to pick from, with a manual entry fallback. Never block an order on the lookup alone. It cuts typos and failed deliveries and speeds checkout up.

By Bez · Reviewed 24 November 2026

The pattern that converts

  • Postcode first: one short field, upper-cased as they type.
  • Check it live: a valid, known postcode gets a tick; an unknown one gets a gentle 'check this'.
  • Pick the address: show the addresses on that postcode (PAF) or let them type the first line.
  • Always allow manual entry: new-build streets can be missing for weeks.

The calls

The postcode check runs in the browser with a publishable key locked to your domain. It's free up to 10,000 postcode lookups a month.

const r = await fetch("https://api.clearpostcode.co.uk/v1/postcodes/" + encodeURIComponent(pc) + "/validate", {
  headers: { "x-api-key": "cp_pub_..." }
});
const { data } = await r.json();
if (data.valid) showTick();
else if (data.format_valid) askToCheck();
else showFormatHint();

Messages that keep the sale

ResultSay
Valid and liveA quiet tick. Nothing else.
Valid format, not found"We can't find that postcode. Please check it, or carry on if it's a new build."
Terminated"That postcode has changed. Did you mean {replaced_by}?"
Bad format"UK postcodes look like SW1A 1AA."

Mistakes to avoid

  • Blocking the order when a lookup fails.
  • Billing yourself for every keystroke: pick a provider that charges on results.
  • Putting a secret key in the page: use a publishable, domain-locked key.

Questions

Do I need PAF to validate at checkout?

To check the postcode, no: open data does it, free. To offer a list of addresses to pick from, yes.

Will validation slow checkout down?

No. The lookup takes milliseconds on our side; the network round trip is most of the wait, and the call runs while the customer types.