Welcome
With MessageHub HLR API you can maximize the performance of your campaigns and your business communication. Validate mobile number databases, remove invalid entries and receive correct portability information, identifying the operators that the mobile numbers belong to.
The HLR API is based on REST. It uses built-in HTTP authentication and HTTP status codes. All data exchange is done in JSON format.
To test MessageHub HLR API, you will need a valid API account. If you don't have one yet please register your account.
Examples
Authentication Endpoint
https://app.messagehub.nl/apis/auth/
OTP API Endpoint
https://app.messagehub.nl/apis/hlr/v2/
Authentication
Each request must be accompanied by a valid access_token. access_token are generated upon successful authentication. To authenticate
you must send an auth request.
https://app.messagehub.nl/apis/auth/
This request accepts parameters type with value access_token, username and
password.
access_token
If the request succeeded, an authentication object is returned, which includes an access_token and a refresh_token. Otherwise, an error is returned . access_token grants you access to make requests.
Setup the Authorization HTTP header with your access_token. AuthorizationBearer dcec4eb6-035c-41a4-9871-82c5bd3ef379
access_token is valid for 30 minutes, after which it expires. To preserve connection you must either refresh with refresh_token or reset connectio n and request a new access_token.
refresh_token
To refresh connection you must send an auth request.
https://app.messagehub.nl/apis/auth/
Examples
Authentication
POST https://app.messagehub.nl/apis/auth/
POST https://app.messagehub.nl/apis/auth/
Content-Type : application/json
{
"type" : "access_token",
"username" : "myusername",
"password" : "mypassword"
}
{
"status_code" : 200,
"status_message" : "OK",
"payload" : {
"access_token" : "dcec4eb6-035c-41a4-9871-82c5bd3ef379",
"validity_period" : 1800,
"refresh_token" : "d32dc41f-6545-4bdc-a980-79e376bbd641"
}
}
Refresh Connection
POST https://app.messagehub.nl/apis/auth/
Content-Type : application/json
{
"type" : "refresh_token",
"refresh_token" : "d32dc41f-6545-4bdc-a980-79e376bbd641",
}
{
"status_code" : 200,
"status_message" : "OK",
"payload" : {
"access_token" : "0e3f6ecb-7a7e-4d03-a004-d710db8978ab",
"validity_period" : 1800,
"refresh_token" : "ecbb4d30-6da2-4b78-998e-d01025c648f2"
}
}
Lookup A Number
To lookup a number with an HLR lookup, you must send a /{mobile} GET request.
https://app.messagehub.nl/apis/hlr/v2/{mobile}
Replace /{mobile} with the recipient mobile number phone in international E.164 format.
Remember to setup the Authorization HTTP header with your access_token.
Congratulations! You just made your first number lookup using the HLR API.
If the request succeeded, an object is returned, which includes the status of the mobile queried, as well as additional information regarding the mobile. Some information may not be available,
due to restrictions e n forced by national telecommunication authorities and mobile operators. Otherwise, an error is returned.
Examples
Authentication
GET https://app.messagehub.nl/apis/hlr/v2/{mobile}
GET https://app.messagehub.nl/apis/hlr/v2/447778547861
{
"status_code" : 200,
"status_message" : "OK",
"payload" : {
"phone" : "447778547861",
"status" : "valid",
"mcc" : "202",
"mnc" : "005",
"imsi" : "202052500000000",
"msc" : "30942191",
"cost" : "0.0040",
"country" : "United Kingdom(+44)",
"operator" : "Vodafone UK"
}
}
Get Balance
To get your account's balance you must send a balance GET request.
https://app.messagehub.nl/apis/hlr/v2/balance/
Remember to setup the Authorization HTTP header with your access_token.
If the request succeeded, an object is returned, which includes your account balance. Otherwise, an error is returned.
Examples
Get Balance
GET https://app.messagehub.nl/apis/hlr/v2/balance/
GET https://app.messagehub.nl/apis/hlr/v2/balance/
Content-Type : application/json
{
"status_code" : 200,
"status_message" : "OK",
"payload" : {
"balance" : "7845.3500"
}
}
Errors
HLR API uses 2 levels of errors. Conventional HTTP status codes and application error codes.
HLR API raises errors for many reasons (authentication, invalid telephone in URI, network / server errors etc.). Consult the detailed HTTP status codes and application error codes tables for detailed explanation of response codes.
Application Errors
HLR API returns errors in an object.
| CODE numeric | MESSAGE string |
|---|---|
| Application error code identifying error. | A human-readable message providing more details about the error. |
Examples
Errors
{
"status_code" : 404,
"status_message" : "Not found",
"errors" : [
{
"code" : 1007,
"message" : "URI not found"
}
]
}
HTTP Status Codes
| code# | STATUS | MESSAGE |
|---|---|---|
| 200 | OK | Everything worked as expected. |
| 401 | Unauthorized | No valid API key provided. |
| 404 | Not Found | The requested resource doesn't exist. |
| 422 | Unprocessable Request | The request unprocessable, often due to invalid parameters. |
| 500 | Internal Server Error | The service is temporarily unavailable. |
Application Error Codes
| code# | STATUS | MESSAGE |
|---|---|---|
| 1001 | Invalid token type | Invalid parameter. |
| 1002 | Invalid username | Invalid parameter. |
| 1003 | Invalid password | Invalid parameter. |
| 1004 | Invalid authentication credentials | Credentials provided is not correct. |
| 1005 | Invalid refresh token | Invalid parameter. |
| 1006 | Insufficient balance | User balance is not enough in order to process the request. |
| 1007 | URI not found | Request URI not found. |
| 1009 | Invalid access token | Access token is invalid. |
| 1221 | Invalid phone (MSISDN) | Invalid parameter. |
| 1222 | Service is not available | Service is temporarily unavailable. |
| 2002 | Error requesting HLR | Error requesting HLR. Please retry later. |
| 2003 | Invalid phone (MSISDN) | Invalid parameter. |
| 2004 | HLR unavailable | You account does not have permissions to use HLR service. |
| 2005 | Destination not supported. | Destination network is not supported. |
Advanced Status
To explain further why a mobile number is invalid, HLR API returns advanced status messages.
Examples
Advanced Status
GET https://app.messagehub.nl/apis/hlr/v2/{mobile}
GET https://app.messagehub.nl/apis/hlr/v2/447778547861
{
"status_code" : 200,
"status_message" : "OK",
"payload" : {
"phone" : "447778547861",
"status" : "invalid",
"advanced_status" : "ABSENT_SUBSCRIBER_SM"
}
}
Advanced Status Messages
| STATUS | MESSAGE |
|---|---|
|
ABSENT_SUBSCRIBER_SM |
The subscriber is absent. |
|
CALL_BARRED |
The HLR is barred by the queried operator. |
|
DATA_MISSING |
The data is missing. |
|
FACILITY_NOT_SUPPORTED |
The short message facility is not supported. |
|
HLR_ABORT |
Operator’s HLR blocked the HLR request. |
|
HLR_LOCAL_CANCEL |
Operator’s HLR did not respond to the request. |
|
HLR_REJECT |
Operator’s HLR rejected the request. |
|
SYSTEM_FAILURE |
A system failure occurred. |
|
TELE_SERVICE_NOT_PROVISIONED |
The SMS teleservice is not provisioned. |
|
TIMEOUT |
HLR request received not response. |
|
UNEXPECTED_DATA_VALUE |
An unexpected data value was found in the request. |
|
UNKNOWN_SUBSCRIBER |
The subscriber is unknown. |