messaging.mapi.mg

General notes

At the moment, if a company wishes to interact and communicate with their customers daily in Madagascar using an SMS, it must enter into a contract with Malagasy operators to benefit from an SMS sending subscription.

This protocol will certainly be expensive for the company because of the time taken to integrate the solutions of each operator which are really different from each other, the tests, the maintenance and also the monthly, half-yearly or annual invoices to pay for each operator.

Thus, we decided to set up MAPI to manage these problems, MAPI will then take care of
the connection to the various Malagasy operators. MAPI will be smart enough to use the operator that will correspond to the recipient’s number, and if any problem occurs with one of the operators, we can automatically switch to another operator to send the SMS.

API detail

Login

  • First, you must have a MAPI client account to be able to perform operations.
    Navigate to https://messaging.mapi.mg/authentication/signup for creating an account.

  • You can login after that.

  • The token obtained from the login has a limited life of 15 minutes (900 seconds) and must be renewed regularly.

curl --location 'https://messaging.mapi.mg/api/authentication/login'
--form "Username=your_username"
--form "Password=your_password"
POST /api/authentication/login HTTP/1.1
Host: messaging.mapi.mg
Content-Length: 248
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Username"

your_username
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Password"

your_password
------WebKitFormBoundary7MA4YWxkTrZu0gW--
import requests

url = "https://messaging.mapi.mg/api/authentication/login"

payload = {
    'Username': 'your_username',
    'Password': 'your_password'

}
files=[
]

headers = {
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("Username","your_username")
.addFormDataPart("Password","your_password")
.build();
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/authentication/login")
.method("POST", body)
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://messaging.mapi.mg/api/authentication/login");
var content = new MultipartFormDataContent();

content.Add(new StringContent("your_username"), "Username");
content.Add(new StringContent("your_password"), "Password");
request.Content = content;

var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();

Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();
data.append('Username', 'your_username');
data.append('Password', 'your_password');

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/authentication/login',
    headers: { 
    ...data.getHeaders()
    },
    data : data
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/authentication/login',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('Username' => 'your_username','Password' => 'your_password'),
    CURLOPT_HTTPHEADER => array(),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "bytes"
    "mime/multipart"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/authentication/login"
    method := "POST"

    payload := &bytes.Buffer{}
    writer := multipart.NewWriter(payload)
    _ = writer.WriteField("Username", "your_username")
    _ = writer.WriteField("Password", "your_password")
    err := writer.Close()
    if err != nil {
    fmt.Println(err)
    return
    }


    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
    fmt.Println(err)
    return
    }

    req.Header.Set("Content-Type", writer.FormDataContentType())
    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 07:14:28 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length250
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJI0005NiJ9.eyJpc3MiOiJodHRwczpcL1vwbWVzc2FnaW5nLm1hcGkubWdcLyIsImlhdCI6MTcyQCAzNDA2OCwiZXhwIjoxNzI1NDM3Nj001ujQc2mlUBF52L0pmZpCXJapDlhQiwaamMXcmlkI15kN30.bvxPol52lJH871XURa2AiknnUdN_bUSogxN3rMRTMPO"
}
Status401 Unauthorized
DateWed, 04 Sep 2024 07:14:46 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length61
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "code": 1,
    "message": "Check login or password"
}

Send single SMS

You can easily send a single SMS.

curl 'https://messaging.mapi.mg/api/msg/send' \
-H 'Authorization: {{mapi_token}}' \
-F 'Recipient="xxxxxxxxxx"' \
-F 'Message="Message you will sent"' \
-F 'Channel="sms"'
POST /api/msg/send HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
Content-Length: 345
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Recipient"

xxxxxxxxxx
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Message"

Message you will sent
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Channel"

sms
------WebKitFormBoundary7MA4YWxkTrZu0gW--
import requests

url = "https://messaging.mapi.mg/api/msg/send"

payload = {'Recipient': 'xxxxxxxxxx',
'Message': 'Message you will sent',
'Channel': 'sms'}
files=[

]
headers = {
    'Authorization': '{{mapi_token}}'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("Recipient","xxxxxxxxxx")
.addFormDataPart("Message","Message you will sent")
.addFormDataPart("Channel","sms")
.build();
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/msg/send")
.method("POST", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://messaging.mapi.mg/api/msg/send");
request.Headers.Add("Authorization", "{{mapi_token}}");
var content = new MultipartFormDataContent();
content.Add(new StringContent("xxxxxxxxxx"), "Recipient");
content.Add(new StringContent("Message you will sent"), "Message");
content.Add(new StringContent("sms"), "Channel");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();
data.append('Recipient', 'xxxxxxxxxx');
data.append('Message', 'Message you will sent');
data.append('Channel', 'sms');

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/msg/send',
    headers: { 
    'Authorization': '{{mapi_token}}', 
    ...data.getHeaders()
    },
    data : data
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/msg/send',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('Recipient' => 'xxxxxxxxxx','Message' => 'Message you will sent','Channel' => 'sms'),
    CURLOPT_HTTPHEADER => array(
    'Authorization: {{mapi_token}}'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "bytes"
    "mime/multipart"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/msg/send"
    method := "POST"

    payload := &bytes.Buffer{}
    writer := multipart.NewWriter(payload)
    _ = writer.WriteField("Recipient", "xxxxxxxxxx")
    _ = writer.WriteField("Message", "Message you will sent")
    _ = writer.WriteField("Channel", "sms")
    err := writer.Close()
    if err != nil {
    fmt.Println(err)
    return
    }


    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")

    req.Header.Set("Content-Type", writer.FormDataContentType())
    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 08:12:24 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length92
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "dryRun": false,
    "result": "Sent message 'Message you will sent' to 03xxxxxxxx"
}
Status409 Conflict
DateWed, 04 Sep 2024 08:13:14 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length115
Keep-Alivetimeout=500, max=98
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "dryRun": false,
    "result": "Receiver number: Le numéro de téléphone est malformé"
}
Status401 Unauthorized
DateWed, 04 Sep 2024 08:14:27 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}

Send bulk sms with different messages

Sending bulk SMS is possible, from an Excel file. The accepted format types are: xls, xlsx and csv.

The file structure is:

  • The first column of the Excel file must contain the last name (optional).

  • The second column must contain the first
    name (optional).

  • The third column must contain the telephone number and is required.

  • The fourth column is for remarks and is optional.

  • The personalized message in the last columnEndFragment

curl --location 'https://messaging.mapi.mg/api/msg/sendBulkSms' \
--header 'Authorization: {{mapi_token}}' \
--header 'Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn' \
--form 'File=@"postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9"'
POST /api/msg/sendBulkSms HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn
Content-Length: 241
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="File"; filename="postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9"
Content-Type: 

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--
import requests

url = "https://messaging.mapi.mg/api/msg/sendBulkSms"

payload = {}

files=[
    ('File',('1ef669c1-c2fc-4a00-ae04-071a9b002bd9',open('postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9','rb'),'application/octet-stream'))
]

headers = {
    'Authorization': '{{mapi_token}}',
    'Cookie': 'PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("File","postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9")))
.build();
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/msg/sendBulkSms")
.method("POST", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://messaging.mapi.mg/api/msg/sendBulkSms");

request.Headers.Add("Authorization", "{{mapi_token}}");
request.Headers.Add("Cookie", "PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn");
var content = new MultipartFormDataContent();

content.Add(new StreamContent(File.OpenRead("postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9")), "File", "postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9");
request.Content = content;

var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();

Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');

const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('File', fs.createReadStream('postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9'));

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/msg/sendBulkSms',
    headers: { 
    'Authorization': '{{mapi_token}}', 
    'Cookie': 'PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn', 
    ...data.getHeaders()
    },
    data : data
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/msg/sendBulkSms',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('File'=> new CURLFILE('postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9')),
    CURLOPT_HTTPHEADER => array(
    'Authorization: {{mapi_token}}',
    'Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "bytes"
    "mime/multipart"
    "os"
    "path/filepath"
    "io"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/msg/sendBulkSms"
    method := "POST"

    payload := &bytes.Buffer{}
    writer := multipart.NewWriter(payload)
    file, errFile1 := os.Open("postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9")
    defer file.Close()
    part1,
            errFile1 := writer.CreateFormFile("File",filepath.Base("postman-cloud:///1ef669c1-c2fc-4a00-ae04-071a9b002bd9"))
    _, errFile1 = io.Copy(part1, file)
    if errFile1 != nil {
    fmt.Println(errFile1)
    return
    }
    err := writer.Close()
    if err != nil {
    fmt.Println(err)
    return
    }


    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")
    req.Header.Add("Cookie", "PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn")

    req.Header.Set("Content-Type", writer.FormDataContentType())
    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 08:16:57 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length58
Keep-Alivetimeout=500, max=97
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "dryRun": false,
    "result": "xx messages sent."
}
Status401 Unauthorized
DateWed, 04 Sep 2024 08:16:24 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}
Status422 Unprocessable Entity
DateWed, 04 Sep 2024 08:18:10 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length76
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "File is missing, check the arguments and retry."
}
Status0
DateWed, 04 Sep 2024 08:19:08 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length140
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
Status409 Conflict
DateWed, 04 Sep 2024 08:28:30 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length125
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "dryRun": false,
    "result": "Plus aucun SMS disponible. Consultez la section OFFRE pour recharger votre compte."
}

Send unique SMS to multiple recipients

We can also send the same SMS to a list of recipients grouped together in an excel file. The accepted format types are: xls, xlsx and csv.

Put the recipients’ numbers in the first column of the file.

curl --location 'https://messaging.mapi.mg/api/msg/sendUniqueSmsToRecipients' \
--header 'Authorization: {{mapi_token}}' \
--header 'Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn' \
--form 'File=@"postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad"' \
--form 'Message="Your message"'
POST /api/msg/sendUniqueSmsToRecipients HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn
Content-Length: 342
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="File"; filename="postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad"
Content-Type: 

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Message"

Your message
------WebKitFormBoundary7MA4YWxkTrZu0gW--
import requests

url = "https://messaging.mapi.mg/api/msg/sendUniqueSmsToRecipients"

payload = {'Message': 'Your message'}

files=[
    ('File',('1ef669b7-c7b1-45a0-b04e-db103e78f5ad',open('postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad','rb'),'application/octet-stream'))
]

headers = {
    'Authorization': '{{mapi_token}}',
    'Cookie': 'PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("File","postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad")))
.addFormDataPart("Message","Your message")
.build();
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/msg/sendUniqueSmsToRecipients")
.method("POST", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://messaging.mapi.mg/api/msg/sendUniqueSmsToRecipients");

request.Headers.Add("Authorization", "{{mapi_token}}");
request.Headers.Add("Cookie", "PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn");

var content = new MultipartFormDataContent();

content.Add(new StreamContent(File.OpenRead("postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad")), "File", "postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad");
content.Add(new StringContent("Your message"), "Message");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();

Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('File', fs.createReadStream('postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad'));
data.append('Message', 'Your message');

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/msg/sendUniqueSmsToRecipients',
    headers: { 
    'Authorization': '{{mapi_token}}', 
    'Cookie': 'PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn', 
    ...data.getHeaders()
    },
    data : data
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/msg/sendUniqueSmsToRecipients',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('File'=> new CURLFILE('postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad'),'Message' => 'Your message'),
    CURLOPT_HTTPHEADER => array(
    'Authorization: {{mapi_token}}',
    'Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "bytes"
    "mime/multipart"
    "os"
    "path/filepath"
    "io"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/msg/sendUniqueSmsToRecipients"
    method := "POST"

    payload := &bytes.Buffer{}
    writer := multipart.NewWriter(payload)
    file, errFile1 := os.Open("postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad")
    defer file.Close()
    part1,
            errFile1 := writer.CreateFormFile("File",filepath.Base("postman-cloud:///1ef669b7-c7b1-45a0-b04e-db103e78f5ad"))
    _, errFile1 = io.Copy(part1, file)
    if errFile1 != nil {
    fmt.Println(errFile1)
    return
    }
    _ = writer.WriteField("Message", "Your message")
    err := writer.Close()
    if err != nil {
    fmt.Println(err)
    return
    }


    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")
    req.Header.Add("Cookie", "PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn")

    req.Header.Set("Content-Type", writer.FormDataContentType())
    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 08:24:09 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length58
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "dryRun": false,
    "result": "xx messages sent."
}
Status401 Unauthorized
DateWed, 04 Sep 2024 08:23:18 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}
Status422 Unprocessable Entity
DateWed, 04 Sep 2024 08:25:06 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length140
Keep-Alivetimeout=500, max=98
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "result": "Echec du téléversement.Le type de fichier que vous tentez d'envoyer n'est pas autorisé."
}
Status409 Conflict
DateWed, 04 Sep 2024 08:28:30 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length125
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "dryRun": false,
    "result": "Plus aucun SMS disponible. Consultez la section OFFRE pour recharger votre compte."
}
Status422 Unprocessable Entity
DateWed, 04 Sep 2024 08:30:41 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length76
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "File is missing, check the arguments and retry."
}
Status422 Unprocessable Entity
DateWed, 04 Sep 2024 08:31:48 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length47
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Message is missing"
}

List of SMS

You can get the list of messages you sent.

curl --location 'https://messaging.mapi.mg/api/msg?limit=2&offset=0' \
--header 'Authorization: {{mapi_token}}' \
--header 'Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
GET /api/msg?limit=2&offset=0 HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn
import requests

url = "https://messaging.mapi.mg/api/msg?limit=2&offset=0"

payload = {}
headers = {
    'Authorization': '{{mapi_token}}',
    'Cookie': 'PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/msg?limit=2&offset=0")
.method("GET", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://messaging.mapi.mg/api/msg?limit=2&offset=0");

request.Headers.Add("Authorization", "{{mapi_token}}");
request.Headers.Add("Cookie", "PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn");

var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();

Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');

let config = {
    method: 'get',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/msg?limit=2&offset=0',
    headers: { 
    'Authorization': '{{mapi_token}}', 
    'Cookie': 'PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
    }
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();
                                    
curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/msg?limit=2&offset=0',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
    'Authorization: {{mapi_token}}',
    'Cookie: PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/msg?limit=2&offset=0"
    method := "GET"

    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, nil)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")
    req.Header.Add("Cookie", "PHPSESSID=kv3agkrjhtm8b6imfcp8inbthn")

    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 08:34:05 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length431
Keep-Alivetimeout=500, max=98
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "result": [
        {
            "IdMessage": "1",
            "IdCampaign": null,
            "Name": null,
            "Telephone": "+261320000000",
            "Message": "Message you will sent",
            "SendStatus": "SENT",
            "GeneratedAt": "2024-04-04 11:12:26",
            "NumberOfSms": "1"
        },
        {
            "IdMessage": "2",
            "IdCampaign": null,
            "Name": null,
            "Telephone": "+261340000000",
            "Message": "Ceci est un test",
            "SendStatus": "NOT_SENT",
            "GeneratedAt": "2023-12-05 09:06:30",
            "NumberOfSms": "1"
        }
    ],
    "totalCount": 720
}
Status401 Unauthorized
DateWed, 04 Sep 2024 08:33:27 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Set-CookiePHPSESSID=kv3agkrjhtm8b6imfcp8inbthn; path=/
Content-Length64
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}

Send OTP

You can easily request an OTP.

curl --location 'https://messaging.mapi.mg/api/otp/verify' \
--form 'Recipient="03xxxxxxxx"' \
--form 'Code="xxxxxx"'
POST /api/otp/request HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
Content-Length: 235
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Recipient"

03xxxxxxxx
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Channel"

sms
------WebKitFormBoundary7MA4YWxkTrZu0gW--
import requests

url = "https://messaging.mapi.mg/api/otp/verify"

payload = {
    'Recipient': '03xxxxxxxx',
    'Code': 'xxxxxx'
}

files=[
]

headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("Recipient","03xxxxxxxx")
.addFormDataPart("Channel","sms")
.build();
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/otp/request")
.method("POST", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://messaging.mapi.mg/api/otp/verify");
var content = new MultipartFormDataContent();
content.Add(new StringContent("03xxxxxxxx"), "Recipient");
content.Add(new StringContent("xxxxxx"), "Code");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');
    const FormData = require('form-data');
    let data = new FormData();
    data.append('Recipient', '03xxxxxxxx');
    data.append('Code', 'xxxxxx');

    let config = {
        method: 'post',
        maxBodyLength: Infinity,
        url: 'https://messaging.mapi.mg/api/otp/verify',
        headers: { 
        ...data.getHeaders()
        },
        data : data
    };

    axios.request(config)
    .then((response) => {
        console.log(JSON.stringify(response.data));
    })
    .catch((error) => {
        console.log(error);
    });
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/otp/verify',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('Recipient' => '03xxxxxxxx','Code' => 'xxxxxx'),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "bytes"
    "mime/multipart"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/otp/verify"
    method := "POST"

    payload := &bytes.Buffer{}
    writer := multipart.NewWriter(payload)
    _ = writer.WriteField("Recipient", "03xxxxxxxx")
    _ = writer.WriteField("Code", "xxxxxx")
    err := writer.Close()
    if err != nil {
    fmt.Println(err)
    return
    }


    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Set("Content-Type", writer.FormDataContentType())
    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 09:08:13 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length213
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "dryRun": false,
    "code": "000000",
    "message": {
        "success": "Le message pour +261xxxxxxx a été soumis avec succès auprès de l'opérateur.",
        "SubmissionId": "xxxxxxxxxxxxxxxxxxxx"
    }
}
Status401 Unauthorized
DateWed, 04 Sep 2024 09:09:13 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=98
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}

Verify OTP

curl --location 'https://messaging.mapi.mg/api/otp/request' \
--header 'Authorization: {{mapi_token}}' \
--form 'Recipient="03xxxxxxxx"' \
--form 'Channel="sms"'
POST /api/otp/request HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
Content-Length: 235
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Recipient"

03xxxxxxxx
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="Channel"

sms
------WebKitFormBoundary7MA4YWxkTrZu0gW--
import requests

url = "https://messaging.mapi.mg/api/otp/request"

payload = {
    'Recipient': '03xxxxxxxx',
    'Channel': 'sms'
}

files=[
]

headers = {
    'Authorization': '{{mapi_token}}'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("Recipient","03xxxxxxxx")
.addFormDataPart("Code","xxxxxx")
.build();
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/otp/verify")
.method("POST", body)
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://messaging.mapi.mg/api/otp/request");
request.Headers.Add("Authorization", "{{mapi_token}}");
var content = new MultipartFormDataContent();
content.Add(new StringContent("03xxxxxxxx"), "Recipient");
content.Add(new StringContent("sms"), "Channel");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');
const FormData = require('form-data');
let data = new FormData();
data.append('Recipient', '03xxxxxxxx');
data.append('Channel', 'sms');

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/otp/request',
    headers: { 
    'Authorization': '{{mapi_token}}', 
    ...data.getHeaders()
    },
    data : data
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/otp/request',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('Recipient' => '03xxxxxxxx','Channel' => 'sms'),
    CURLOPT_HTTPHEADER => array(
    'Authorization: {{mapi_token}}'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "bytes"
    "mime/multipart"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/otp/request"
    method := "POST"

    payload := &bytes.Buffer{}
    writer := multipart.NewWriter(payload)
    _ = writer.WriteField("Recipient", "03xxxxxxxx")
    _ = writer.WriteField("Channel", "sms")
    err := writer.Close()
    if err != nil {
    fmt.Println(err)
    return
    }


    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")

    req.Header.Set("Content-Type", writer.FormDataContentType())
    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 09:15:03 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length44
Keep-Alivetimeout=500, max=97
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "message": "Code is verified"
}
Status422 Unprocessable Entity
DateWed, 04 Sep 2024 09:15:14 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length55
Keep-Alivetimeout=500, max=96
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "code": 5,
    "message": "Code already used"
}
Status422 Unprocessable Entity
DateWed, 04 Sep 2024 09:15:30 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length52
Keep-Alivetimeout=500, max=95
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "code": 4,
    "message": "Code not found"
}
Status401 Unauthorized
DateWed, 04 Sep 2024 09:15:44 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=94
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}

List of OTP

curl --location 'https://messaging.mapi.mg/api/otp?limit=10&offset=0' \
--header 'Authorization: {{mapi_token}}'
GET /api/otp?limit=10&offset=0 HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
import requests

url = "https://messaging.mapi.mg/api/otp?limit=10&offset=0"

payload = {}
headers = {
    'Authorization': '{{mapi_token}}'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/otp?limit=10&offset=0")
.method("GET", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://messaging.mapi.mg/api/otp?limit=10&offset=0");
request.Headers.Add("Authorization", "{{mapi_token}}");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');

let config = {
    method: 'get',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/otp?limit=10&offset=0',
    headers: { 
    'Authorization': '{{mapi_token}}'
    }
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/otp?limit=10&offset=0',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
    'Authorization: {{mapi_token}}'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/otp?limit=10&offset=0"
    method := "GET"

    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, nil)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")

    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 09:19:26 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length475
Keep-Alivetimeout=500, max=97
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "result": [
        {
            "IdOneTimePassword": "1",
            "IdClient": "1",
            "Client": "client",
            "Username": "username",
            "Telephone": "+2613xxxxxxxx",
            "Code": "000000",
            "GeneratedAt": "1725440581",
            "GeneratedAtDateTime": "2023-09-04 11:03:01",
            "ExpiresAt": "1725441481",
            "ExpiresAtDateTime": "2023-09-04 11:18:01",
            "Duration": "900",
            "TimeToLiveHHMMSS": "-00:01:25",
            "TimeToLiveSeconds": "-85",
            "IsExpired": "1",
            "SendStatus": "SENT",
            "IsAlreadyUsed": "1"
        }
    ],
    "totalCount": 3
}
Status401 Unauthorized
DateWed, 04 Sep 2024 09:21:18 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}

Available SMS number

Get the number of SMS you can use.

curl --location --request GET 'https://messaging.mapi.mg/api/smsoffer/available' \
--header 'Authorization: {{mapi_token}}'
GET /api/smsoffer/available HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
import requests

url = "https://messaging.mapi.mg/api/smsoffer/available"

payload = {}
headers = {
    'Authorization': '{{mapi_token}}'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/smsoffer/available")
.method("GET", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://messaging.mapi.mg/api/smsoffer/available");
request.Headers.Add("Authorization", "{{mapi_token}}");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');

let config = {
    method: 'get',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/smsoffer/available',
    headers: { 
    'Authorization': '{{mapi_token}}'
    }
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/smsoffer/available',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
    'Authorization: {{mapi_token}}'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/smsoffer/available"
    method := "GET"

    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, nil)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")

    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 09:22:33 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length33
Keep-Alivetimeout=500, max=100
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "available_sms": 0
}
Status401 Unauthorized
DateWed, 04 Sep 2024 09:22:51 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=99
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}

Logout

curl -X POST -H "Authorization: {{mapi_token}}" "https://messaging.mapi.mg/api/authentication/logout"
POST /api/authentication/logout HTTP/1.1
Host: messaging.mapi.mg
Authorization: {{mapi_token}}
import requests

url = "https://messaging.mapi.mg/api/authentication/logout"

payload = {}
headers = {
    'Authorization': '{{mapi_token}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://messaging.mapi.mg/api/authentication/logout")
.method("POST", body)
.addHeader("Authorization", "{{mapi_token}}")
.build();
Response response = client.newCall(request).execute();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://messaging.mapi.mg/api/authentication/logout");
request.Headers.Add("Authorization", "{{mapi_token}}");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
const axios = require('axios');

let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://messaging.mapi.mg/api/authentication/logout',
    headers: { 
    'Authorization': '{{mapi_token}}'
    }
};

axios.request(config)
.then((response) => {
    console.log(JSON.stringify(response.data));
})
.catch((error) => {
    console.log(error);
});
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://messaging.mapi.mg/api/authentication/logout',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => array(
      'Authorization: {{mapi_token}}'
    ),
  ));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://messaging.mapi.mg/api/authentication/logout"
    method := "POST"

    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, nil)

    if err != nil {
    fmt.Println(err)
    return
    }
    req.Header.Add("Authorization", "{{mapi_token}}")

    res, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    fmt.Println(string(body))
}
Status200 OK
DateWed, 04 Sep 2024 09:23:27 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length51
Keep-Alivetimeout=500, max=98
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": true,
    "message": "Logged out successfully"
}
Status401 Unauthorized
DateWed, 04 Sep 2024 09:23:42 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length47
Keep-Alivetimeout=500, max=97
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Already logged out"
}
Status401 Unauthorized
DateWed, 04 Sep 2024 09:24:18 GMT
ServerApache
ExpiresThu, 19 Nov 1981 08:52:00 GMT
Cache-Controlno-store, no-cache, must-revalidate
Pragmano-cache
Content-Length64
Keep-Alivetimeout=500, max=94
ConnectionKeep-Alive
Content-Typeapplication/json
{
    "status": false,
    "message": "Authentication credentials required"
}