Envoyer un SMS
curl --request POST \
--url https://api.wachap.com/v1/sms/send-sms \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_number": "+1234567890",
"message": "Votre message SMS ici"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone_number: '+1234567890', message: 'Votre message SMS ici'})
};
fetch('https://api.wachap.com/v1/sms/send-sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone_number: '+1234567890', message: 'Votre message SMS ici'})
};
fetch('https://api.wachap.com/v1/sms/send-sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/sms/send-sms"
payload = {
"phone_number": "+1234567890",
"message": "Votre message SMS ici"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/sms/send-sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone_number' => '+1234567890',
'message' => 'Votre message SMS ici'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wachap.com/v1/sms/send-sms"
payload := strings.NewReader("{\n \"phone_number\": \"+1234567890\",\n \"message\": \"Votre message SMS ici\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"success": true,
"message": "<string>"
}SMS
Envoyer un SMS
Envoyer un SMS via FCM à l’appareil enregistré
POST
/
sms
/
send-sms
Envoyer un SMS
curl --request POST \
--url https://api.wachap.com/v1/sms/send-sms \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone_number": "+1234567890",
"message": "Votre message SMS ici"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone_number: '+1234567890', message: 'Votre message SMS ici'})
};
fetch('https://api.wachap.com/v1/sms/send-sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone_number: '+1234567890', message: 'Votre message SMS ici'})
};
fetch('https://api.wachap.com/v1/sms/send-sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/sms/send-sms"
payload = {
"phone_number": "+1234567890",
"message": "Votre message SMS ici"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/sms/send-sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone_number' => '+1234567890',
'message' => 'Votre message SMS ici'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wachap.com/v1/sms/send-sms"
payload := strings.NewReader("{\n \"phone_number\": \"+1234567890\",\n \"message\": \"Votre message SMS ici\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"success": true,
"message": "<string>"
}Endpoint
/sms/send-sms
Headers
Bearer token avec votre Secret Key (format:
Bearer sk_...)Body Parameters
Le numéro de téléphone du destinataire (format international, ex: +1234567890).
Le contenu du message SMS à envoyer.
Note
Cette requête envoie le SMS en utilisant Google Firebase Cloud Messaging (FCM) via l’appareil préalablement enregistré sur votre compte.
Exemples de requêtes
curl -X POST https://api.wachap.com/v1/sms/send-sms \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"phone_number": "+1234567890",
"message": "Votre message SMS ici"
}'
const response = await fetch('https://api.wachap.com/v1/sms/send-sms', {
method: 'POST',
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
phone_number: '+1234567890',
message: 'Votre message SMS ici'
})
});
const data = await response.json();
console.log(data);
import requests
url = "https://api.wachap.com/v1/sms/send-sms"
headers = {
"Authorization": "Bearer token",
"Content-Type": "application/json"
}
payload = {
"phone_number": "+1234567890",
"message": "Votre message SMS ici"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$curl = curl_init();
$payload = [
"phone_number" => "+1234567890",
"message" => "Votre message SMS ici"
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/sms/send-sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer token",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Exemple de réponse
{
"success": true,
"message": "SMS envoyé avec succès via FCM",
"data": {
"messageId": "fcm_msg_123abc456def"
}
}
Codes d’erreur
| Code | Description |
|---|---|
401 | INVALID_SECRET_KEY - Clé secrète invalide ou manquante |
400 | MISSING_PARAMETERS - Numéro ou message manquant |
500 | FCM_ERROR - Erreur lors de l’envoi via FCM |
Autorisations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Corps
application/json
⌘I
