Phone numbers
Parse, check, format and find phone numbers of every country, with the type of line (mobile, fixed line, toll free). A number written without + needs the country code. Typical uses: clean the phone numbers of a contact file, store numbers in E.164 format before sending SMS.
phone parsephone parsephone formatphone formatphone is_validphone is_validphone typephone typephone findphone findphone find

phone parse <number>


Description

    Read a number written with + (or tel:+...). Result: {input, valid, possible, possible_reason, e164, international, national, rfc3966, country_code, national_number, region, type, extension}. valid means that the number is in a range given to an operator by its country; possible only checks the length. type is fixed_line, mobile, fixed_line_or_mobile (the plan does not tell them apart, as in the US), toll_free, premium_rate, shared_cost, voip, personal_number, pager, uan, voicemail or unknown

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
admin
phone parse "+262 692 12 34 56"
mentdb
{"input": "+262 692 12 34 56", "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+262692123456", "international": "+262 692 12 34 56", "national": "0692 12 34 56", "rfc3966": "tel:+262-692-12-34-56", "country_code": 262, "national_number": "692123456", "region": "RE", "type": "mobile", "extension": null}
With an extension
admin
phone parse "+1 (650) 253-0000 ext. 1234"
mentdb
{"input": "+1 (650) 253-0000 ext. 1234", "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+16502530000", "international": "+1 650-253-0000 ext. 1234", "national": "(650) 253-0000 ext. 1234", "rfc3966": "tel:+1-650-253-0000;ext=1234", "country_code": 1, "national_number": "6502530000", "region": "US", "type": "fixed_line_or_mobile", "extension": "1234"}
A number with no + and no region cannot be read
admin
phone parse "0142685300"
mentdb
ERROR: Sorry, an error appears (the parameter 'number' cannot be read as a phone number: unknown country calling code, or no + and no region given (here '0142685300')).

phone parse <number> <region>


Description

    Read a number as written in a region. Result: {input, valid, possible, possible_reason, e164, international, national, rfc3966, country_code, national_number, region, type, extension}. valid means that the number is in a range given to an operator by its country; possible only checks the length. type is fixed_line, mobile, fixed_line_or_mobile (the plan does not tell them apart, as in the US), toll_free, premium_rate, shared_cost, voip, personal_number, pager, uan, voicemail or unknown

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
    region:   The country code of 2 letters used for a number written without +, ex: FR, RE, US, GB. Empty: the number must start with + - String - required
admin
phone parse "01 42 68 53 00" "FR"
mentdb
{"input": "01 42 68 53 00", "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+33142685300", "international": "+33 1 42 68 53 00", "national": "01 42 68 53 00", "rfc3966": "tel:+33-1-42-68-53-00", "country_code": 33, "national_number": "142685300", "region": "FR", "type": "fixed_line", "extension": null}
A call from France to London (00 is the international prefix of FR)
admin
phone parse "00 44 20 7946 0958" "FR"
mentdb
{"input": "00 44 20 7946 0958", "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+442079460958", "international": "+44 20 7946 0958", "national": "020 7946 0958", "rfc3966": "tel:+44-20-7946-0958", "country_code": 44, "national_number": "2079460958", "region": "GB", "type": "fixed_line", "extension": null}
Right length but not a valid range
admin
phone parse "07 00 00 00 00" "FR"
mentdb
{"input": "07 00 00 00 00", "valid": false, "possible": true, "possible_reason": "is_possible", "e164": "+33700000000", "international": "+33 7 00 00 00 00", "national": "07 00 00 00 00", "rfc3966": "tel:+33-7-00-00-00-00", "country_code": 33, "national_number": "700000000", "region": "FR", "type": "unknown", "extension": null}
Used in use cases (1 recipe)

    Data quality analyst › Bring the phone numbers of a customer file to E.164 and keep the mobiles for SMS
Often used with

    phone find  ·  phone is_valid  ·  phone type

phone format <number> <format>


Description

    Write a number in a format: E164 (+33142685300), INTERNATIONAL (+33 1 42 68 53 00), NATIONAL (01 42 68 53 00) or RFC3966 (tel:+33-1-42-68-53-00); case does not matter

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
    format:   E164, INTERNATIONAL, NATIONAL or RFC3966 - String - required
admin
phone format "+14155550132" "NATIONAL"
mentdb
(415) 555-0132
A tel: link
admin
phone format "+33142685300" "RFC3966"
mentdb
tel:+33-1-42-68-53-00

phone format <number> <format> <region>


Description

    Write a number of a region in a format

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
    format:   E164, INTERNATIONAL, NATIONAL or RFC3966 - String - required
    region:   The country code of 2 letters used for a number written without +, ex: FR, RE, US, GB. Empty: the number must start with + - String - required
admin
phone format "0692 12 34 56" "E164" "RE"
mentdb
+262692123456
International form
admin
phone format "030 12345678" "international" "DE"
mentdb
+49 30 12345678

phone is_valid <number>


Description

    1 when the number is valid (in a range given to an operator), else 0; a text that is not a number gives 0

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
admin
phone is_valid "+33 1 42 68 53 00"
mentdb
1
Too short
admin
phone is_valid "+33 1 42"
mentdb
0

phone is_valid <number> <region>


Description

    Validity of a number written in a region

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
    region:   The country code of 2 letters used for a number written without +, ex: FR, RE, US, GB. Empty: the number must start with + - String - required
admin
phone is_valid "06 12 34 56 78" "FR"
mentdb
1
Not a number
admin
phone is_valid "call me" "FR"
mentdb
0
Used in use cases (1 recipe)

    Data quality analyst › Bring the phone numbers of a customer file to E.164 and keep the mobiles for SMS
Often used with

    phone find  ·  phone parse  ·  phone type

phone type <number>


Description

    The type of line: fixed_line, mobile, fixed_line_or_mobile, toll_free, premium_rate, shared_cost, voip, personal_number, pager, uan, voicemail or unknown

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
admin
phone type "+44 7911 123456"
mentdb
mobile
A French toll free number
admin
phone type "+33 800 12 34 56"
mentdb
toll_free

phone type <number> <region>


Description

    The type of a number written in a region

Parameters

    number:   The phone number, in any usual writing (spaces, dots, dashes, brackets, +, 00 after a region, tel: URI, ext. or x for an extension). 250 characters at most - String - required
    region:   The country code of 2 letters used for a number written without +, ex: FR, RE, US, GB. Empty: the number must start with + - String - required
admin
phone type "09 12 34 56 78" "FR"
mentdb
voip
Used in use cases (1 recipe)

    Data quality analyst › Bring the phone numbers of a customer file to E.164 and keep the mobiles for SMS
Often used with

    phone find  ·  phone is_valid  ·  phone parse

phone find <text>


Description

    Find the numbers written with + in a text (1000000 characters at most, searched to the end). Result: a JSON array of {raw (the text found), start, end (positions in the text as given), then the fields of phone parse}

Parameters

    text:   The text - String - required
admin
phone find "Call +33 1 42 68 53 00 or +44 20 7946 0958 before 6 pm."
mentdb
[{"raw": "+33 1 42 68 53 00", "start": 5, "end": 22, "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+33142685300", "international": "+33 1 42 68 53 00", "national": "01 42 68 53 00", "rfc3966": "tel:+33-1-42-68-53-00", "country_code": 33, "national_number": "142685300", "region": "FR", "type": "fixed_line", "extension": null}, {"raw": "+44 20 7946 0958", "start": 26, "end": 42, "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+442079460958", "international": "+44 20 7946 0958", "national": "020 7946 0958", "rfc3966": "tel:+44-20-7946-0958", "country_code": 44, "national_number": "2079460958", "region": "GB", "type": "fixed_line", "extension": null}]

phone find <text> <region>


Description

    Find the numbers of a text written in a region (the national writings are found too)

Parameters

    text:   The text - String - required
    region:   The country code of 2 letters used for a number written without +, ex: FR, RE, US, GB. Empty: the number must start with + - String - required
admin
phone find "Tél. 01 42 68 53 00 - Mobile 06 12 34 56 78 - SIRET 123 456 789 00012" "FR"
mentdb
[{"raw": "01 42 68 53 00", "start": 5, "end": 19, "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+33142685300", "international": "+33 1 42 68 53 00", "national": "01 42 68 53 00", "rfc3966": "tel:+33-1-42-68-53-00", "country_code": 33, "national_number": "142685300", "region": "FR", "type": "fixed_line", "extension": null}, {"raw": "06 12 34 56 78", "start": 29, "end": 43, "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+33612345678", "international": "+33 6 12 34 56 78", "national": "06 12 34 56 78", "rfc3966": "tel:+33-6-12-34-56-78", "country_code": 33, "national_number": "612345678", "region": "FR", "type": "mobile", "extension": null}]

phone find <text> <region> <json_params>


Description

    Find the numbers with options: leniency (valid: only valid numbers; possible: right length only; strict_grouping and exact_grouping: also the digits must be grouped as in the national format), max (1000, 1 to 10000: number of results)

Parameters

    text:   The text - String - required
    region:   The country code of 2 letters used for a number written without +, ex: FR, RE, US, GB. Empty: the number must start with + - String - required
    json_params:   The options, as a JSON object - String - required
admin
phone find "01 42 68 53 00, 01 42 68 53 01" "FR" "{\"max\": 1}"
mentdb
[{"raw": "01 42 68 53 00", "start": 0, "end": 14, "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+33142685300", "international": "+33 1 42 68 53 00", "national": "01 42 68 53 00", "rfc3966": "tel:+33-1-42-68-53-00", "country_code": 33, "national_number": "142685300", "region": "FR", "type": "fixed_line", "extension": null}]
Possible numbers too (07 00 ... is not a valid range)
admin
phone find "Ref 07 00 00 00 00 or 01 42 68 53 00" "FR" "{\"leniency\": \"possible\"}"
mentdb
[{"raw": "07 00 00 00 00", "start": 4, "end": 18, "valid": false, "possible": true, "possible_reason": "is_possible", "e164": "+33700000000", "international": "+33 7 00 00 00 00", "national": "07 00 00 00 00", "rfc3966": "tel:+33-7-00-00-00-00", "country_code": 33, "national_number": "700000000", "region": "FR", "type": "unknown", "extension": null}, {"raw": "01 42 68 53 00", "start": 22, "end": 36, "valid": true, "possible": true, "possible_reason": "is_possible", "e164": "+33142685300", "international": "+33 1 42 68 53 00", "national": "01 42 68 53 00", "rfc3966": "tel:+33-1-42-68-53-00", "country_code": 33, "national_number": "142685300", "region": "FR", "type": "fixed_line", "extension": null}]
Used in use cases (1 recipe)

    Data quality analyst › Bring the phone numbers of a customer file to E.164 and keep the mobiles for SMS
Often used with

    phone is_valid  ·  phone parse  ·  phone type