# Format Verification

## URL

<mark style="color:green;">`POST`</mark> `https://api.smspartner.fr/v1/lookup`

{% hint style="warning" %}
Limit of 360 requests per minute. If you exceed this limit, you will receive an HTTP 429 response.
{% endhint %}

#### **Required Parameters**

| Name           | Value                                                                                                                                               |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`       | [Your API key](https://my.smspartner.fr/dashboard/api)                                                                                              |
| `phoneNumbers` | Mobile numbers to check. Must be in international format (+336xxxxxxxx). For multiple numbers, separate them with commas. Max: 500 numbers/request. |

#### **Optional Parameters**

| Name      | Value           |
| --------- | --------------- |
| `_format` | `json` or `xml` |

#### Requests

{% tabs %}
{% tab title="PHP" %}

```php
<?php
        // Prepare data for POST request
        $fields = array(
            'apiKey'=> 'YOUR API KEY',
            'phoneNumbers'=> '+336xxxxxxxx'
        );
 
 
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/lookup');
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($fields));
 
        $result = curl_exec($curl);
        curl_close($curl);
 
        // Process your response here
        echo $result;
?>
```

{% endtab %}

{% tab title="VB.net" %}

```vbnet
Imports System.IO
Imports System.Net
 
Module Module1
 
  Sub Main()
 
    Dim base_url As String = "http://api.smspartner.fr/v1/"
    Dim apiKey As String = "VOTRE_APIKEY"
 
    #send sms
    url = base_url & "lookup"
    #note : utiliser une librairie JSON en production, par exemple :
    #https//www.nuget.org/packages/Newtonsoft.Json/
    Dim parameters As String = String.Format(
        "{{""apiKey"":""{0}"",""phoneNumbers"":""{1}""}}",
        apiKey,
        "+33XXXXXXXXX")
    Console.Write(parameters)
    apiRequest("POST", url, parameters)
 
  End Sub
 
  Function apiRequest(method As String, url As String, parameters As String) As String
 
    Dim request As HttpWebRequest
    request = WebRequest.Create(url)
    request.Method = method
    request.Timeout = 10000   # timeout in ms
    request.ContentType = "application/json; charset=utf-8"
    request.ContentLength = 0
 
    #set POST data
    If Not String.IsNullOrEmpty(parameters) Then
      request.ContentLength = parameters.Length
      Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream())
        reqStream.Write(parameters)
      End Using
    End If
 
    #get response
    Dim returnValue As String = Nothing
    Using response As HttpWebResponse = request.GetResponse()
      If response.StatusCode = HttpStatusCode.OK Then
        Using resStream = response.GetResponseStream()
          If resStream IsNot Nothing Then
            Using reader As New StreamReader(resStream)
              returnValue = reader.ReadToEnd()
            End Using
          End If
        End Using
      End If
    End Using
    apiRequest = returnValue
 
  End Function
 
End Module
```

{% endtab %}

{% tab title="Python" %}

```python
# std
import logging
import json
from collections import OrderedDict
 
# 3p
import requests
 
API_KEY = "MY API KEY"
URL = "https://api.smspartner.fr/v1"
 
class SMSPartner():
    def add_stop(self,phone_numbers):
 
		data = OrderedDict([
			("apiKey", API_KEY),
			("phoneNumbers", phone_numbers)
		])
 
		url = URL + "/lookup"
		r = requests.post(url, data=json.dumps(data), verify=False)
 
		r_json = r.json()
		if r_json.get("success") == True:
			print(r_json)
			status = True
		else:
			print(r_json)
			status = False
		return status
```

{% endtab %}

{% tab title="cURL" %}

```
curl -H  "Content-Type: application/json" -X POST -d '{"apiKey":"xxxxx","phoneNumbers":"xxxx"}' https://api.smspartner.fr/v1/lookup
```

{% endtab %}
{% endtabs %}

#### **Response**

{% tabs %}
{% tab title="json" %}

```json
{
    "success": true,
    "code": 200,
    "lookup": [
        {
            "request": "336XXXXXXXX",
            "success": true,
            "countryCode": "France",
            "prefixCode": 33,
            "phoneNumber": "+336XXXXXXXX",
            "type": "Mobile",
            "network": "",
            "format": {
                "e164": "+336XXXXXXXX",
                "international": "+33 6 XX XX XX XX",
                "national": "06 XX XX XX XX",
                "rfc3966": "tel:+33-6-XX-XX-XX-XX"
            }
        }
    ]
}
```

{% endtab %}

{% tab title="xml" %}

```xml
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <entry>true</entry>
    <entry>200</entry>
    <entry>
        <entry>
            <entry>
                <![CDATA[336XXXXXXXX]]>
            </entry>
            <entry>true</entry>
            <entry>
                <![CDATA[France]]>
            </entry>
            <entry>33</entry>
            <entry>
                <![CDATA[+336XXXXXXXX]]>
            </entry>
            <entry>
                <![CDATA[Mobile]]>
            </entry>
            <entry>
                <![CDATA[]]>
            </entry>
            <entry>
                <entry>
                    <![CDATA[+336XXXXXXXX]]>
                </entry>
                <entry>
                    <![CDATA[+33 6 XX XX XX XX]]>
                </entry>
                <entry>
                    <![CDATA[06 XX XX XX XX]]>
                </entry>
                <entry>
                    <![CDATA[tel:+33-6-XX-XX-XX-XX]]>
                </entry>
            </entry>
        </entry>
    </entry>
</result>
```

{% endtab %}
{% endtabs %}

#### Errors

{% tabs %}
{% tab title="json" %}

```json
{
    "success": false,
    "code": 10,
    "message": "Invalid API key"
}
```

{% endtab %}

{% tab title="xml" %}

```xml
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <entry>false</entry>
    <entry>10</entry>
    <entry>
        <![CDATA[Invalid API key]]>
    </entry>
</result>
```

{% endtab %}
{% endtabs %}

#### **Error Codes**

| Response Code | Message                             |
| ------------- | ----------------------------------- |
| 1             | API key is required                 |
| 2             | Phone number is required            |
| 3             | Numbers must be separated by commas |
| 10            | Invalid API key                     |
| 200           | Everything went fine!               |

#### Example of notification of an HLR request

```php
Array(
    'phone' => '+3300000000',
    'messageId'=>'1234-12344-1234-1234',
    'mccMnc' => '20815',
    'ported'=> 1,
    'errorGrpId'=> 0,
    'errorName'=> 'NO_ERROR ',
    'errorDesc'=>'No Error' ,
    'date'=>'2018-03-05T10:34:52.355+0000'
)
```

**HLR Error Codes**

| Error | Error Name                                                                                                                                                                                                                      |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0     | `NO_ERROR` No error.                                                                                                                                                                                                            |
| 1     | `EC_UNKNOWN_SUBSCRIBER` The number does not exist or has not been assigned to any active subscriber in the operator's user database.                                                                                            |
| 5     | `EC_UNIDENTIFIED_SUBSCRIBER` Unidentified subscriber.                                                                                                                                                                           |
| 6     | `EC_ABSENT_SUBSCRIBER_SM` As there was no response, the subscriber was detected as unavailable. This is often due to the handset being turned off or in a low-signal area.                                                      |
| 7     | `EC_UNKNOWN_EQUIPMENT` The mobile device was not recognized by the EIR (Equipment Identity Register) during verification at the MAP protocol level on the operator’s infrastructure.                                            |
| 8     | `EC_ROAMING_NOT_ALLOWED` The subscriber is currently roaming in another country or using another operator's infrastructure – delivery is not guaranteed due to the lack of roaming agreements between many different operators. |
| 9     | `EC_ILLEGAL_SUBSCRIBER` Illegal subscriber.                                                                                                                                                                                     |
| 12    | `EC_ILLEGAL_EQUIPMENT` Illegal equipment.                                                                                                                                                                                       |
| 13    | `EC_CALL_BARRED` The subscriber is set to DND (Do Not Disturb) and does not receive any service traffic to their number.                                                                                                        |
| 27    | `EC_ABSENT_SUBSCRIBER` The subscriber is offline. This is often due to the handset being turned off.                                                                                                                            |
| 255   | `EC_UNKNOWN_ERROR` Unknown error.                                                                                                                                                                                               |
