Reference
Phone numbers
Which numbers OTP.ps sends to, the formats it accepts, and how to normalize them yourself.
OTP.ps sends to Palestinian mobile numbers on Jawwal (059) and Ooredoo (056) only. It always sends on the Palestinian country code +970.
Accepted formats
The API reads every common way of writing a number. All of these are the same number, +970599123456:
| Written as | Notes |
|---|---|
0599123456 | Local, 10 digits |
599123456 | Without the leading 0 |
+970599123456, 00970599123456, 970599123456 | Palestinian code |
+972599123456, 00972599123456 | The Israeli code, often used for the same Jawwal/Ooredoo numbers; sent on +970 |
059-912-3456, +970 59 912 3456, (059) 912 3456 | Spaces, dashes and brackets are ignored |
٠٥٩٩١٢٣٤٥٦ | Arabic-Indic digits (and Persian digits) |
Refused numbers
| Number | Error |
|---|---|
Other mobiles, e.g. 052…, 054…, 050… (Israeli operators) | 422 unsupported_network |
Landlines (02…, 04…, 08…, 09…), wrong length, letters | 422 invalid_phone |
Normalizing on your side
You can send the number exactly as the customer typed it. If you want to validate it in your form first, or store it in one format, use the same rules as the API: take the digits, drop 00, then a 970 or 972 prefix on a 12-digit number, then a leading 0 on a 10-digit number; what remains must be 9 digits starting with 59 or 56.
export function normalizePhone(raw: string): string | null {
let d = raw
.replace(/[٠-٩]/g, (c) => String(c.charCodeAt(0) - 0x0660))
.replace(/[۰-۹]/g, (c) => String(c.charCodeAt(0) - 0x06f0))
.replace(/\D/g, "");
if (d.startsWith("00")) d = d.slice(2);
if (d.length === 12 && (d.startsWith("970") || d.startsWith("972"))) d = d.slice(3);
if (d.length === 10 && d.startsWith("0")) d = d.slice(1);
return /^5[96]\d{7}$/.test(d) ? `+970${d}` : null;
}The same function is in the TypeScript example and the WooCommerce plugin (PHP).
In your form
- Use
type="tel",inputmode="tel"andautocomplete="tel", anddir="ltr"on the input even on an Arabic (RTL) page. - Placeholder:
059X XXX XXX. - Tell the customer that only Jawwal and Ooredoo numbers can receive codes.
- The API answers show the number masked (
0599 ••• 456); keep the full number on your server.