Pular para o conteúdo principal

Phone number validation - Amplia Reg

Amplia Reg sends the holder text messages, such as issue key 2 when the order is approved, so the order's phone number must be valid. Order creation rejects an invalid phone number. To catch the problem earlier, for example while the customer is still filling in your form, check the number with the validation API before creating the order.

tip

Make sure you have completed the Getting started steps

Any API key can call this API: it requires no specific role.

Validating a number​

In .NET:

bool isValid = await ampliaRegService.ValidatePhoneNumberAsync("+5511999990000");
if (!isValid) {
// Ask the customer to correct the phone number
}

Via API:

GET /api/users/phone-number/validation?phoneNumber=%2B5511999990000

The response body is true if the number is valid and false otherwise.

note

Encode the number in the query string: the + of the international prefix must be sent as %2B, or it is read as a space. The .NET client encodes it for you.

What is checked​

The API applies the same check that order creation applies to the phone and alternativePhone fields of contact. A number that the API accepts is also accepted when the order is created.

  • Country code: the number must include the country code, as in +5511999990000. The leading + is optional, but the country code is not: without it, the first digits of the number are read as the country code, so 11999990000 would be read as a number from country code 1 (United States and Canada) and rejected.
  • Numbering plan: the number must be valid for its country, with the right length and a valid area code and prefix.
  • Paraguay: Paraguayan mobile numbers (+595 9XX XXX XXX) are also accepted when the numbering plan does not recognize them yet.
  • Formatting: spaces, parentheses and hyphens are allowed, as in +55 (11) 99999-0000.

The check does not confirm that the line exists, or that it belongs to the holder.

warning

An empty or missing phoneNumber returns true, because the API only rejects numbers it can tell are wrong. Check for empty values yourself.

Tips​

  • Ask for a mobile number in the phone field. A valid landline passes the check, but the one-time codes that Amplia Reg sends by SMS, for example to let the holder join a videoconference or start a video identification, can only go to a mobile number.
  • Send the number in E.164 format (+5511999990000, digits only after the +). Regular orders store the phone number in this format whatever the input, but preapproved orders store it as sent.

See also​

View as Markdown