WhatsApp phone number format and wa_id explained
How to write the to field for the CRPRO Hub, why the country code matters, how wa_id differs from the phone number and which one to store.
Most delivery problems that look mysterious start with a phone number written slightly wrong. A missing country code, a stray zero or a number that gets rewritten by the platform can all send a message nowhere, or to the wrong person. This tutorial explains how to format the recipient number for the CRPRO Hub, what Meta does with it, and how to use the wa_id that comes back to identify a contact reliably.
How should the to field be written when calling the Hub?
Short answer: country calling code followed by the national number, digits only, for example 5521999999999. The Hub removes non-digit characters and then requires 8 to 15 digits, with the first digit not zero.
The Hub's schema trims the value, strips every character that is not a digit and validates what remains against the pattern of a leading digit from 1 to 9 followed by 7 to 14 more digits. So +55 21 99999-9999 is accepted and treated as 5521999999999, while a number that starts with 0, or that has fewer than 8 or more than 15 digits, is refused with 400 INVALID_MESSAGE. The documented form is digits only, and sending clean digits keeps your own logs and idempotency keys consistent.
curl -X POST https://crprohub.com/api/v1/channels/CHANNEL_UUID/messages \
-H "Authorization: Bearer hub_pk_EXAMPLE_NOT_REAL" \
-H "Idempotency-Key: hello-5521999999999-1" \
-H "Content-Type: application/json" \
-d '{ "to": "5521999999999", "type": "text", "text": { "body": "Hello" } }'Why is the country code essential?
Short answer: without it the number is ambiguous, and Meta may interpret it using the country code of your own business number.
Meta's documentation recommends including both the plus sign and the country calling code. If you leave out the plus sign, the platform prepends your business number's country calling code, which can lead to undelivered or misdelivered messages. Its example shows the effect: a number written as (631) 555-1234 can be delivered to a different country's number than the one intended. The Hub's digit-only form avoids the plus sign question, but only if the country code is already in the digits. A national number such as 21999999999 passes the Hub's length check and is still wrong.
| Input | What the Hub does | Result |
|---|---|---|
| +55 21 99999-9999 | Strips to 5521999999999 | Valid |
| 5521999999999 | Unchanged | Valid, preferred |
| 021999999999 | Starts with 0 | Refused, 400 |
| 21999999999 | Valid length, no country code | Accepted by the Hub, may be undeliverable |
The last row is the dangerous one, because nothing rejects it. Normalise numbers where they enter your system, with a library such as libphonenumber, and require the country code at that moment.
// Minimal normaliser: needs the default country calling code for local numbers
function toWaNumber(raw, defaultCountryCode = '55') {
let digits = String(raw).replace(/\D/g, '')
if (digits.startsWith('00')) digits = digits.slice(2) // 0055... style
else if (String(raw).trim().startsWith('+')) { /* already international */ }
else if (digits.startsWith('0')) digits = defaultCountryCode + digits.slice(1)
else if (digits.length <= 11) digits = defaultCountryCode + digits // adjust to your market
if (!/^[1-9][0-9]{7,14}$/.test(digits)) throw new RangeError(`not a valid number: ${raw}`)
return digits
}This helper is a starting point, not a full parser: national dialling rules differ by country, so a proper library is safer for a multi-country product.
What is wa_id and how does it differ from the phone number?
Short answer: wa_id is the WhatsApp identifier of a user, in digits with the country code. It usually looks like the phone number, but Meta states the two may not match, so treat wa_id as the identity.
Meta's send response contains a contacts array with two fields: input, the number as you sent it, and wa_id, the WhatsApp user's id. Its sample shows +16505551234 as input and 16505551234 as wa_id. The documentation says they may not match and tells you to use wa_id as the user's identifier and input as the phone number. For Brazil and Mexico it adds that the Cloud API may modify the extra prefix, which it describes as standard behaviour and not a bug.
Where does the wa_id appear in the Hub?
Short answer: on inbound events. The message.received payload has data.from and data.contact.wa_id. The Hub's 202 send response carries only a message_id and a status.
The Hub's inbound event includes the sender's number in data.from, a contact object with wa_id and name, and a contacts array in Meta's shape, as described in the webhooks reference. The synchronous response to a send does not repeat the wa_id that Meta returned, so for a first message to a number you only learn the canonical id when the customer replies. Always reply using the from value of the inbound event, not the number you typed originally.
// On message.received: this is the canonical key for the contact
const waId = event.data.contact?.wa_id ?? event.data.from
await contacts.upsert({ channelId: event.channel_id, waId, name: event.data.contact?.name })
// When replying, reuse the id the platform gave you
await send({ to: event.data.from, type: 'text', text: { body: 'Thanks, we got it.' } })How can a list of numbers be validated before a large send?
Short answer: normalise and validate offline, quarantine the failures and send only the clean set.
A job that loops over thousands of contacts and calls the API for each one turns every formatting mistake into a 400 response and a wasted request against the 120 requests per minute limit. Validate first, with the same function you use at sign-up, and write rejected rows to a report that a person can fix. Deduplicate on the normalised digits too, since +55 21 99999-9999 and 5521999999999 are the same recipient and would otherwise receive two messages. Remember that the 60 messages per minute per channel limit still governs the actual sending, so a clean list is only half of a safe bulk job.
How should contact numbers be stored?
Short answer: keep the number you were given, the normalised digits you send and the wa_id from the first inbound event as separate fields, and match on wa_id once you have it.
- original: exactly what the person typed, for support and audit.
- e164_digits: the normalised value you pass in to.
- wa_id: the identifier from inbound events; the stable key per channel.
- Matching: look up by wa_id first, then by normalised digits for contacts that have not written yet.
This model absorbs the cases where the platform rewrites a prefix, because the inbound id always wins. It also keeps outbound-only contacts working until they reply. The first request is shown in the quickstart.
Which phone number mistakes show up most often?
Short answer: missing country code, leading zero, spreadsheet damage and treating the typed number as the identity.
Spreadsheets deserve a special mention. A column of phone numbers opened in a spreadsheet application can lose a leading plus sign, be converted to scientific notation or lose digits. Import data as text, and spot-check the longest numbers. After that come the human errors: a trunk zero left in after the country code, spaces from copy and paste and a country code pasted twice. A validation step at the point of entry catches nearly all of them and is much cheaper than discovering undelivered messages later.
- Import phone columns as text.
- Remove a trunk zero when the country code is present.
- Strip spaces, hyphens and parentheses before storing.
- Reject numbers outside 8 to 15 digits.
- Use wa_id from inbound events as the identity once it exists.
Frequently asked questions
Does the Hub accept a plus sign in the to field?
The Hub strips non-digit characters before validating, so +5521999999999 is read as 5521999999999. The documented form is digits only, which is what you should send.
Why is a message delivered to someone else or not at all?
Most often the country code was missing and the platform assumed the one from your own business number. Normalise to a full international number before sending.
Is wa_id always the same as the phone number?
No. Meta says they may not match, and for Brazil and Mexico the API may modify the extra prefix. Use wa_id as the user's identity and the phone number as the phone number.
Where does the wa_id come from when only outbound messages exist?
The Hub's send response does not include it. It appears on the inbound event once the customer writes, in data.contact.wa_id.
Fontes
Documentação oficial da Meta, conferida em 31 de outubro de 2026.