Number lookup (MNP / ENUM)
Open Numbers and trunks, Numbers, Number lookup (/admin/number-lookup). You need trunks:read to see the page and trunks:write to change it.
Number lookup tells MonoPbx two things about a phone number:
- Which network it is on now. When a number is ported to another carrier it keeps its digits, so its prefix no longer tells you the carrier. A mobile number portability (MNP) lookup answers with the network the number belongs to today.
- What kind of line it is: mobile, landline, VoIP, toll-free, premium rate or pager. This tells you, for example, whether the number can receive SMS.
You can use the answer to send calls to the right trunk for the destination's network (see Outbound rules) and in automations (see In automations).
What you need
MonoPbx does not come with lookup data. Number portability data is sold by lookup providers and number-portability database operators, usually per lookup, and their terms normally forbid sharing it. You need one of:
- An HTTP lookup provider: an MNP, HLR or line-type lookup service with a web API that answers in JSON. Most providers charge for every lookup; check their prices before you switch on routing lookups.
- An ENUM service: a carrier or number-portability ENUM tree that you are allowed to query. MonoPbx reads its NAPTR records. The public
e164.arpatree holds almost no numbers, so it is rarely useful on its own.
Answers are kept for your company only, for Keep answers hours (default one week). A number the source does not know is kept for at most one day. Clear cache forgets every answer.
Set up an HTTP lookup provider
- Choose HTTP lookup provider as the source.
- Enter the Provider URL with
{number}(the number in international format,+included) or{digits}(the same digits without+), for examplehttps://lookup.example.com/v1/numbers/{number}. Onlyhttpsaddresses on the internet are allowed. - Enter the Key header (for example
AuthorizationorX-Api-Key) and the Key exactly as the provider wants it in that header (for exampleBearer ...orBasic ...). The key is stored encrypted and is never shown again. - Tell MonoPbx where the answer is in the provider's JSON with JSON paths, for example
$.line_typeor$.carrier.name. Fill in the ones your provider returns:
| Field | What it reads |
|---|---|
| Line type | The kind of line. Common words (mobile, wireless, landline, fixed, voip, nonFixedVoip, tollFree, ...) are mapped to mobile, landline, VoIP, toll-free, premium rate, pager or unknown. |
| Network id | A code of the network, for example the mobile country and network code (MCC-MNC) or the provider's id. |
| Network name | The network's name. |
| Ported | true or false. |
- Switch on Look numbers up, save, and try a number under Test a number. The test is billed like any lookup.
Set up an ENUM service
- Choose ENUM service (NAPTR) as the source.
- Enter the ENUM suffix of your service, for example
e164enum.example.net. A number such as+12155550123is looked up as3.2.1.0.5.5.5.5.1.2.1.e164enum.example.net. - Enter the DNS servers of the service if it is not reachable through the server's normal DNS (up to four IP addresses, each with an optional port). Private addresses are refused unless the server administrator allows private destinations.
MonoPbx reads two kinds of answer:
E2U+pstnrecords with atel:address. A routing number (rn=) or provider id (spn=) becomes the network;npdiwithout a routing number means the number was not ported.E2U+siprecords with asip:address are shown as the number's SIP address. MonoPbx does not call that address; calls still go out through your trunks.
ENUM answers do not carry a line type, so the line type stays unknown.
Outbound rules by destination
An outbound rule can require the dialled number to be of certain destination line types or on certain destination networks (in the rule's form, below the caller conditions). For example:
- a rule for mobile numbers on one network that uses the trunk of that network's carrier (on-net calls are often cheaper), followed by
- your normal rule for everything else.
Network entries are compared with the network id and the network name of the answer, without regard to case. End an entry with * to match a prefix, for example 33402*.
To make it work, switch on both Look numbers up and Use for outbound routing. Then:
- MonoPbx looks the dialled number up only when an enabled rule has a destination condition, and never for emergency numbers.
- A cached number costs nothing and adds no noticeable delay. A number that is not cached adds up to the Time limit (default 800 ms, at most 2 seconds) to call setup and is billed by your provider. If the answer comes later, it is still cached for the next call.
- If the lookup fails, is too slow or does not know the number, rules with destination conditions are skipped and the call goes to the next matching rule. A lookup problem never blocks a call by itself; keep a rule without destination conditions after them.
- The rule tester looks numbers up the same way, so it shows which rule a real call would take.
In automations
The Look up number (carrier, line type) step looks a number up (a caller, a contact, a form field) and gives:
| Output | Value |
|---|---|
found | the source knew the number |
line_type | mobile, landline, voip, toll_free, premium, pager or unknown |
mobile | true for a mobile line |
sms_capable | true for mobile, false for landline and pager, empty when unknown |
network, network_name | the network it is on now |
ported | true when it was ported, empty when not reported |
source | http, enum, or none when the lookup is off |
Follow it with a Condition or Switch on nodes.<step>.line_type, for example to skip an SMS to a landline and send an e-mail instead. The step works in call flows too: it answers from the cache at once and waits at most the time limit otherwise. When number lookup is switched off, the step answers found: false and line_type: unknown.
API
GET and PATCH /api/v1/number-lookup-settings, POST /api/v1/number-lookup/test, DELETE /api/v1/number-lookup-cache; outbound rules take dest_line_types and dest_networks. See the API reference.