NewBulkSMSIraq is now an official Meta Tech Partner for WhatsApp in Iraq.Read the news
Guides

Iraqi Phone Number Format and SMS Length: A Developer Guide

How Iraqi mobile numbers are built, how to turn anything a user types into the 9647XXXXXXXXX format our API expects, and how to count SMS parts before you send, with tested JavaScript, PHP and Python code.

Bulk SMS Iraq logoBulk SMS Iraq teamErbil, Kurdistan Region 12 min readUpdated
Iraqi phone numbers being normalised to 9647 format next to an SMS character counter
On this page
  1. How Iraqi mobile numbers are structured
  2. The number format our API expects
  3. Normalising phone numbers from forms
  4. SMS encoding and length
  5. Counting SMS parts before sending
  6. WhatsApp and Telegram OTP: no parts to count
  7. Checklist before you go live

An Iraqi mobile number is the country code 964 followed by a 10-digit national number that starts with 7. Users type it locally as 0770 123 4567, but our API expects the clean international form without + or 00: 9647701234567. An SMS holds 160 GSM-7 characters or 70 Unicode characters (Arabic, Kurdish, emoji) per part, and longer messages are charged per part.

Below: the number structure, a normaliser for everything users type into a form (including Arabic and Persian digits) and an SMS part counter, in JavaScript, PHP and Python. Every snippet was run against the sample inputs in the tables.

How Iraqi mobile numbers are structured

Every Iraqi mobile number has the same three pieces: the country code 964, a network prefix that starts with 7, and seven more digits. Inside Iraq people dial a leading 0 instead of the country code, so the same number appears in two shapes:

  • Local: 11 digits, 0770 123 4567. This is what most users type.
  • International: +964 770 123 4567 or 00964 770 123 4567.
  • Clean API form: 13 digits, 9647701234567. No +, no 00, no leading 0, no spaces.

The digits after the 0 show which network issued the number. These are the ranges listed on our SMS coverage page:

NetworkLocal prefixClean form starts with
Asiacell0770–0778, 0760964770–964778, 964760
Zain Iraq0780–0790964780–964790
Korek Telecom0750–0751964750, 964751

Customers can move their number between networks, so the prefix is a strong hint, not proof. Since SMS to Zain is priced higher than to Asiacell and Korek, use the prefix to estimate a budget and read the actual cost from the API response.

The API checks the number for you.Numbers outside these ranges are rejected with error 1216 before anything is sent, so you are not charged for them. Your own validation is there to give users a clear message on the form, not to protect your balance.

The number format our API expects

The recipient field takes the international format without + or 00, for example 9647701234567, and the same rule applies abroad (447700900123 for the UK). All parameters are in the API documentation; the API integration page shows the overall flow.

Normalise once, on the server, and store the result as text, for example VARCHAR(15), never as an integer. A unique index on the clean form stops the same customer from appearing twice as 0770… and +964770….

Normalising phone numbers from forms

A phone field on an Iraqi website receives many versions of the same number. A good normaliser accepts all of these:

  • 0770 123 4567, 0770-123-4567 and 07701234567
  • +964 770 123 4567 and 00964 770 123 4567
  • +964 (0) 770 123 4567, with the local 0 kept after the country code
  • 7701234567, where a spreadsheet dropped the leading 0
  • ٠٧٧٠١٢٣٤٥٦٧ (Arabic-Indic digits) and ۰۷۷۰۱۲۳۴۵۶۷ (Persian digits), which many Arabic and Kurdish keyboards produce

The order of the steps matters:

  1. Convert the digits firstMap ٠–٩ (U+0660–U+0669) and ۰–۹ (U+06F0–U+06F9) to 0–9. If you strip non-digits before this step, JavaScript and PHP silently delete the Arabic digits.
  2. Keep ASCII digits onlyRemove +, spaces, dashes, brackets and anything else.
  3. Fix the prefixRemove a leading 00. Turn 9640 into 964. Replace a leading 0 with 964. Put 964 in front of a number that starts with 7.
  4. Validate the resultAccept only ^9647\d{9}$: 13 digits starting with 9647. Anything else gets a clear error on the form.

JavaScript (Node.js and the browser)

// Normalise an Iraqi mobile number to 9647XXXXXXXXX (13 digits), or return null.
function normalizeIraqiMobile(input) {
  let n = String(input ?? '')
    .replace(/[\u0660-\u0669]/g, (d) => String(d.charCodeAt(0) - 0x0660)) // Arabic-Indic ٠-٩
    .replace(/[\u06F0-\u06F9]/g, (d) => String(d.charCodeAt(0) - 0x06F0)) // Persian ۰-۹
    .replace(/\D+/g, '');                                                 // drop +, spaces, dashes, brackets

  if (n.startsWith('00')) n = n.slice(2);             // 00964... -> 964...
  if (n.startsWith('9640')) n = '964' + n.slice(4);   // +964 0770... -> 964770...
  else if (n.startsWith('0')) n = '964' + n.slice(1); // 0770... -> 964770...
  else if (n.startsWith('7')) n = '964' + n;          // 770... -> 964770...

  return /^9647\d{9}$/.test(n) ? n : null;
}

Run it in the browser to show errors while the user types, but always run it again on the server before you call the API. On the input, type="tel" and autocomplete="tel" bring up the phone keypad and allow autofill.

PHP

This version is a drop-in replacement for the function in our PHP and Laravel OTP guide, with Arabic and Persian digit support added. It needs PHP 8.0 or later for str_starts_with().

function normalize_iraqi_mobile(string $input): ?string
{
    // Arabic-Indic (٠-٩) and Persian (۰-۹) digits to ASCII 0-9
    $n = str_replace(
        ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩', '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'],
        ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
        $input
    );
    $n = preg_replace('/\D+/', '', $n);        // drop +, spaces, dashes, brackets

    if (str_starts_with($n, '00')) {
        $n = substr($n, 2);                    // 00964... -> 964...
    }
    if (str_starts_with($n, '9640')) {
        $n = '964' . substr($n, 4);            // +964 0770... -> 964770...
    } elseif (str_starts_with($n, '0')) {
        $n = '964' . substr($n, 1);            // 0770... -> 964770...
    } elseif (str_starts_with($n, '7')) {
        $n = '964' . $n;                       // 770... -> 964770...
    }

    return preg_match('/^9647\d{9}$/', $n) === 1 ? $n : null;
}

Python

In Python, \d matches any Unicode digit, including ٧ and ۷, so the code uses [0-9] instead. Otherwise a number with Arabic digits could pass validation and reach the API unconverted. The str | None hint needs Python 3.10 or later.

import re

# Arabic-Indic (٠-٩) and Persian (۰-۹) digits to ASCII 0-9
DIGITS = str.maketrans("٠١٢٣٤٥٦٧٨٩۰۱۲۳۴۵۶۷۸۹", "01234567890123456789")


def normalize_iraqi_mobile(value: str) -> str | None:
    """Return the number as 9647XXXXXXXXX (13 digits), or None."""
    n = re.sub(r"[^0-9]", "", str(value).translate(DIGITS))  # ASCII digits only

    if n.startswith("00"):
        n = n[2:]              # 00964... -> 964...
    if n.startswith("9640"):
        n = "964" + n[4:]      # +964 0770... -> 964770...
    elif n.startswith("0"):
        n = "964" + n[1:]      # 0770... -> 964770...
    elif n.startswith("7"):
        n = "964" + n          # 770... -> 964770...

    return n if re.fullmatch(r"9647[0-9]{9}", n) else None

Example inputs and results

All three functions return the same result for each of these inputs. These rows come from the test run:

User inputNormalisedWhy
0770 123 45679647701234567Spaces removed, leading 0 replaced
+964 770 123 45679647701234567Plus sign and spaces removed
00964-770-123-4567964770123456700 and dashes removed
+964 (0) 750 123 45679647501234567Extra 0 after 964 removed
78012345679647801234567Lost leading 0; 964 added
0760-123-45-679647601234567Dashes removed, leading 0 replaced
٠٧٧٠١٢٣٤٥٦٧9647701234567Arabic-Indic digits converted
۰۷۵۰ ۱۲۳ ۴۵۶۷9647501234567Persian digits converted
+٩٦٤ ٧٨٠ ١٢٣ ٤٥٦٧9647801234567Arabic digits with country code
0770 123 456rejectedOne digit too short
066 123 4567rejectedNot a mobile number (no 7 after the 0)
+44 7700 900123rejectedNot an Iraqi number

The same normalise-then-check order works for bulk lists, as our bulk SMS campaign guide shows for spreadsheets.

SMS encoding and length

The SMS standard has two common encodings, and the text of your message decides which one is used. These are standard SMS rules, the same on every network:

EncodingUsed for1 partPer part when longer2 parts3 parts
GSM-7Plain English and basic Latin text160153306459
UCS-2 (Unicode)Arabic, Kurdish, emoji, any non-GSM character7067134201

A long message travels as several parts, each with a small header that tells the phone how to join them. That header is why a part holds 153 or 67 characters instead of 160 or 70. Each part is charged as one SMS.

Characters that force Unicode

One character outside the GSM-7 alphabet switches the whole message to Unicode, and the limit drops from 160 to 70. The usual causes:

  • Arabic and Kurdish letters, and Arabic-Indic digits. A message in Arabic or Sorani is always Unicode, even if it contains a Latin brand name or link.
  • Curly quotes and apostrophes (’ ‘ “ ”), long dashes (– —) and the ellipsis character (…), which word processors and phone keyboards insert automatically.
  • Emoji. Most emoji also take two of the 70 slots, because Unicode SMS is counted in UTF-16 code units and an emoji needs two.
  • Many accented letters, such as á, ç or ï. GSM-7 includes only a few, such as é, è, ü and ñ.
  • Invisible characters, such as a non-breaking space or a zero-width non-joiner copied from a document.

GSM extension characters count double

Some characters exist in GSM-7 only through an escape code, so each one uses two of the 160 positions: € [ ] { } ^ ~ | \. The message stays GSM-7, but it gets shorter. For example, Total: 25€ [paid] is 17 characters but 20 units.

Templates with brackets or euro signs are longer than they look.A placeholder written as {name} or [code] costs four units for its brackets alone if it is sent as written. Check the final text after placeholders are filled, not the template.

Counting SMS parts before sending

The counter checks every character against the GSM-7 alphabet, counting extension characters as two. If any character does not fit, it counts the message in UTF-16 code units instead. Then it applies the 160/153 or 70/67 rule. Show the result next to your message editor so authors see the cost before they save.

JavaScript

// GSM-7 basic characters (1 unit each) and extension characters (2 units each)
const GSM_BASIC = new Set(
  '@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&\'()*+,-./0123456789:;<=>?' +
  '¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà'
);
const GSM_EXTENDED = new Set('\f^{}\\[~]|€');

function countSmsParts(text) {
  let units = 0;
  let gsm = true;
  for (const ch of text) {
    if (GSM_BASIC.has(ch)) units += 1;
    else if (GSM_EXTENDED.has(ch)) units += 2;
    else { gsm = false; break; }
  }
  if (!gsm) units = text.length; // UCS-2: UTF-16 code units, an emoji counts as 2

  const [single, multi] = gsm ? [160, 153] : [70, 67];
  const parts = units <= single ? 1 : Math.ceil(units / multi);
  return { encoding: gsm ? 'GSM-7' : 'UCS-2', units, parts };
}

PHP

This uses the mbstring extension, which most PHP installs include, and mb_str_split() from PHP 7.4.

// GSM-7 basic characters (1 unit each) and extension characters (2 units each)
const GSM_BASIC = "@£\$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?"
    . '¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà';
const GSM_EXTENDED = "\f^{}\\[~]|€";

function count_sms_parts(string $text): array
{
    $basic    = array_flip(mb_str_split(GSM_BASIC));
    $extended = array_flip(mb_str_split(GSM_EXTENDED));
    $units    = 0;
    $gsm      = true;

    foreach (mb_str_split($text) as $ch) {
        if (isset($basic[$ch])) {
            $units += 1;
        } elseif (isset($extended[$ch])) {
            $units += 2;
        } else {
            $gsm = false;
            break;
        }
    }
    if (! $gsm) {
        // UCS-2: UTF-16 code units, an emoji counts as 2
        $units = intdiv(strlen(mb_convert_encoding($text, 'UTF-16LE', 'UTF-8')), 2);
    }

    [$single, $multi] = $gsm ? [160, 153] : [70, 67];

    return [
        'encoding' => $gsm ? 'GSM-7' : 'UCS-2',
        'units'    => $units,
        'parts'    => $units <= $single ? 1 : (int) ceil($units / $multi),
    ];
}

Python

import math

# GSM-7 basic characters (1 unit each) and extension characters (2 units each)
GSM_BASIC = set(
    "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?"
    "¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà"
)
GSM_EXTENDED = set("\f^{}\\[~]|€")


def count_sms_parts(text: str) -> dict:
    if all(ch in GSM_BASIC or ch in GSM_EXTENDED for ch in text):
        encoding, single, multi = "GSM-7", 160, 153
        units = sum(2 if ch in GSM_EXTENDED else 1 for ch in text)
    else:
        encoding, single, multi = "UCS-2", 70, 67
        units = len(text.encode("utf-16-le")) // 2  # an emoji counts as 2

    parts = 1 if units <= single else math.ceil(units / multi)
    return {"encoding": encoding, "units": units, "parts": parts}

Example messages and results

MessageEncodingUnitsParts
Your YourApp code is 482915GSM-7271
160 × aGSM-71601
161 × aGSM-71612
307 × aGSM-73073
Total: 25€ [paid]GSM-7201
81 × €GSM-71622
Don’t share this code (curly apostrophe)UCS-2211
Your code is 482915 plus a space and one lock emojiUCS-2221
رمز التحقق الخاص بك هو 482915UCS-2291
کۆدی دڵنیایی تۆ: 482915UCS-2231
71 Arabic lettersUCS-2712
135 Arabic lettersUCS-21353

Check the count against the API

Your counter is an estimate. The number that is billed comes back from POST /v5/sms/send in data.sms_count, together with data.cost. This is the response shown in the documentation:

{
  "status":  "success",
  "message": "Your message was accepted",
  "id":      "6745f1c2a9e3b",
  "data": {
    "status":    "accepted",
    "from":      "YourBrand",
    "to":        "9647701234567",
    "sms_type":  "plain",
    "sms_count": 1,
    "cost":      0.09
  }
}

Here both functions work together in Node.js: the number is normalised, long messages are refused before they cost money, and the parts charged are returned. Log that value next to your own count; if they differ, check the message for hidden characters.

// Node.js 18+ (built-in fetch). Keep the API key in an environment variable.
async function sendSms(phone, message) {
  const recipient = normalizeIraqiMobile(phone);
  if (!recipient) throw new Error('Please enter a valid Iraqi mobile number.');

  const { encoding, parts } = countSmsParts(message);
  if (parts > 2) throw new Error(`Message is ${parts} ${encoding} parts. Please shorten it.`);

  const res = await fetch('https://gateway.standingtech.com/api/v5/sms/send', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.BSI_API_KEY}`,
      'Content-Type': 'application/json',
      Accept: 'application/json',
    },
    body: JSON.stringify({ recipient, sender_id: 'YourBrand', message }),
  });

  const data = await res.json();
  if (data.status !== 'success') {
    throw new Error(`API error ${data.error?.code}: ${data.error?.message}`);
  }
  return data.data.sms_count; // parts actually charged
}

Parts multiply the price. On the Standard plan, one part costs 165 IQD ($0.10) on Asiacell and Korek and 400 IQD ($0.24) on Zain. A 100-character Arabic message is two parts, so it costs 330 IQD ($0.20) or 800 IQD ($0.48) per recipient. Our SMS templates show short Arabic and Kurdish wording that fits in one part.

WhatsApp and Telegram OTP: no parts to count

Parts are an SMS concept. A verification code sent on WhatsApp or Telegram costs one price per message, whatever its length or language: 17 IQD ($0.01) on the Startup plan and 33 IQD ($0.02) on the Standard plan. An Arabic or Kurdish code costs the same as an English one.

With "message": "auto" on /v5/otp/send, the API writes the message itself in the language you set in lang, so you do not count anything. If WhatsApp cannot deliver and the code falls back to SMS, you pay only the SMS price, and the failed WhatsApp attempt is never charged. The PHP and Laravel guide shows that flow in full.

Validation alone does not stop SMS pumping, where fake sign-ups request codes for many valid numbers to drain your balance. The API rate-limits each number, and our OTP Firewall stops this traffic before it is sent.

Checklist before you go live

  • Normalise on the server. Browser checks only help users.
  • Store the 13-digit form as text. One column, one format, one unique index.
  • Convert digits before stripping. Test your form with an Arabic and a Kurdish keyboard, not only an English one.
  • Count parts on the final text. Fill placeholders first, then count, and replace curly quotes in English messages.
  • Compare with sms_count. Log the parts charged and check messages where your estimate was lower.

To try it with real messages, create an account, top up a small balance and send to your own number first.

Building SMS or OTP for Iraqi users? Our developers in Erbil can check your number handling and message lengths on WhatsApp.

Contact us

Frequently asked questions

What is the correct format for an Iraqi mobile number in the API?

International format without + or 00: 964 followed by the 10-digit number without its leading 0, for example 9647701234567. That is 13 digits starting with 9647.

How do I convert 0770 123 4567 to international format?

Remove spaces and other symbols, drop the leading 0 and put 964 in front: 0770 123 4567 becomes 9647701234567. The functions in this guide also handle +964, 00964, a stray 0 after 964 and Arabic or Persian digits.

How many characters fit in one Arabic or Kurdish SMS?

70 characters, because Arabic and Kurdish letters are sent as Unicode. A longer message is split into parts of 67 characters, and each part is charged.

Why did my English SMS count as Unicode?

It contains at least one character outside the GSM-7 alphabet, usually a curly apostrophe, smart quotes, a long dash or an emoji pasted from another app. Replace them with plain characters and the limit goes back to 160.

Do WhatsApp and Telegram OTP messages have a length limit like SMS?

They are not split into SMS parts. Each WhatsApp or Telegram code costs one price per message, from 17 IQD ($0.01) on the Startup plan, whatever the language.

Share:

Ready to send your first code?

Get an API key today. Our team in Erbil helps you go live, in English, Arabic or Kurdish.