Skip to main content

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.arpa tree 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​

  1. Choose HTTP lookup provider as the source.
  2. Enter the Provider URL with {number} (the number in international format, + included) or {digits} (the same digits without +), for example https://lookup.example.com/v1/numbers/{number}. Only https addresses on the internet are allowed.
  3. Enter the Key header (for example Authorization or X-Api-Key) and the Key exactly as the provider wants it in that header (for example Bearer ... or Basic ...). The key is stored encrypted and is never shown again.
  4. Tell MonoPbx where the answer is in the provider's JSON with JSON paths, for example $.line_type or $.carrier.name. Fill in the ones your provider returns:
FieldWhat it reads
Line typeThe 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 idA code of the network, for example the mobile country and network code (MCC-MNC) or the provider's id.
Network nameThe network's name.
Portedtrue or false.
  1. 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​

  1. Choose ENUM service (NAPTR) as the source.
  2. Enter the ENUM suffix of your service, for example e164enum.example.net. A number such as +12155550123 is looked up as 3.2.1.0.5.5.5.5.1.2.1.e164enum.example.net.
  3. 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+pstn records with a tel: address. A routing number (rn=) or provider id (spn=) becomes the network; npdi without a routing number means the number was not ported.
  • E2U+sip records with a sip: 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:

OutputValue
foundthe source knew the number
line_typemobile, landline, voip, toll_free, premium, pager or unknown
mobiletrue for a mobile line
sms_capabletrue for mobile, false for landline and pager, empty when unknown
network, network_namethe network it is on now
portedtrue when it was ported, empty when not reported
sourcehttp, 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.