Forms and commerce

Check phone numbers, country codes and IP addresses in Shopify

Check the phone number on each new order or customer and write a clean international format and number type back to the customer record.

Why the data matters in Shopify

Stores take phone numbers at checkout in any shape a customer types, and shipping carriers and text updates read that field. A number with a missing country code means a delivery notice that never arrives, and a returns team calling a number that cannot be dialed.

What LookValid checks

LookValid checks for Shopify
ProductWhat it does hereCredits
Phone Numbering-Plan ValidationReturns E.164 and the national and international formats with the country and number type, from numbering-plan data only. It cannot tell whether the line is active.1 credit per valid number
Country Calling CodesLooks up the calling code and national number lengths for a shipping country.1 credit per lookup (an unknown code, country or name is free)
IP IntelligenceReturns location, network owner and risk flags for an address, which can add context to an unusual order.1 credit per lookup

Connect it in four steps

  1. Create a LookValid account and an API key from the dashboard, which a person does once.
  2. Set the key as the LOOKVALID_API_KEY environment variable on the server that receives your store's webhooks, and keep it out of theme code, which shoppers can read. Verify the X-Shopify-Hmac-Sha256 header on each delivery before you trust it.
  3. Take the phone from the orders/create payload and call the function; skip any delivery whose X-Shopify-Webhook-Id you have already handled, so a repeat does not cost a second lookup. On null flag the order for a human look, and on an error log the code and fix and let the order proceed.
  4. Write the E.164 number, type and country into customer fields or tags in your store through your own admin tooling, keeping in mind that Shopify does not guarantee webhook ordering, so key the update on the order id.

A small server function at the https address your store sends orders/create webhooks to, which checks the phone number the order carries. The call is POST https://YOUR_API_HOST/v1/phone and costs 1 credit per valid number.

validateShopifyPhone.mjs
const API_URL = "https://YOUR_API_HOST/v1/phone";
​
export async function validateShopifyPhone(value) {
  const response = await fetch(API_URL, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.LOOKVALID_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "phone": value,
    }),
  });
  const result = await response.json();
  if (!response.ok) throw new Error(`${result.error.code}: ${result.error.fix}`);
  if (!result.found) return null;
  return {
      "phone_e164": result.data?.e164 ?? null,
      "phone_type": result.data?.number_type ?? null,
      "phone_country": result.data?.country ?? null,
  };
}
Where each response field goes in Shopify
Response fieldGoes into
data.e164phone_e164
data.number_typephone_type
data.countryphone_country

The recipe returns nothing when the lookup finds nothing, which costs no credits for this product, and stops with the error code and fix on a failed request.

Without code

You can do this with no server of your own by using an automation platform's generic HTTP request step, started by a new-order trigger. It sends the order phone to LookValid and writes the answer back to the customer, with no dedicated LookValid app involved.

REST and MCPOne shared credit balance

Questions

What does it cost in credits?

The pricing page lists the credits for the phone product. One order is one lookup if you check once per order.

What does the phone check not do?

It checks the number against numbering-plan rules. It cannot tell if the line is active, who carries it or whether a text will arrive.

Where does the key go?

On the server that receives your webhooks, in an environment variable. Never place it in storefront theme code.

Sources

LookValid is run by Meralume Labs. It is not connected to, endorsed by or a partner of any company or product named on this page, and every product name belongs to its owner.

LookValid bills every lookup in credits from one shared balance, so the same key works for each check above.

See Phone Numbering-Plan Validation