Ajouter des contacts à une liste
curl --request POST \
--url https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contacts": [
{}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({contacts: [{}]})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json', 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({contacts: [{}]})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json"
payload = { "contacts": [{}] }
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/contact-groups/{id}/add-contacts-json",
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([
'contacts' => [
[
]
]
]),
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/contact-groups/{id}/add-contacts-json"
payload := strings.NewReader("{\n \"contacts\": [\n {}\n ]\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))
}Listes de contacts
Ajouter des contacts
Ajoutez des contacts directement à une liste existante via JSON
POST
/
contact-groups
/
{id}
/
add-contacts-json
Ajouter des contacts à une liste
curl --request POST \
--url https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contacts": [
{}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({contacts: [{}]})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json', 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({contacts: [{}]})
};
fetch('https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/contact-groups/{id}/add-contacts-json"
payload = { "contacts": [{}] }
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/contact-groups/{id}/add-contacts-json",
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([
'contacts' => [
[
]
]
]),
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/contact-groups/{id}/add-contacts-json"
payload := strings.NewReader("{\n \"contacts\": [\n {}\n ]\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))
}Endpoint
Headers
string
requis
Bearer token avec votre Secret Key (format:
Bearer sk_...)URL Parameters
string
requis
L’identifiant de la liste
Body Parameters
array
requis
Liste des contacts à ajouter (voir structure ci-dessous)
Structure d’un contact
| Champ | Type | Requis | Description |
|---|---|---|---|
phone | string | Oui | Numéro de téléphone au format international |
name | string | Non | Nom du contact |
... | any | Non | Autres champs personnalisés |
Exemples de requêtes
curl -X POST https://api.wachap.com/v1/contact-groups/65f1234567890abcdef12345/add-contacts-json \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"contacts": [
{
"phone": "+2290112345678",
"name": "John Doe",
"city": "Abidjan"
},
{
"phone": "+33612345678",
"name": "Marie Dupont",
"city": "Paris"
}
]
}'
const response = await fetch('https://api.wachap.com/v1/contact-groups/65f1234567890abcdef12345/add-contacts-json', {
method: 'POST',
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
contacts: [
{ phone: '+2290112345678', name: 'John Doe' }
]
})
});
const data = await response.json();
console.log(data);
Exemple de réponse
{
"success": true,
"addedContacts": 2
}
Notes importantes
- Les contacts sont ajoutés à la fin de la liste existante
- Les doublons ne sont pas automatiquement filtrés
- Tous les contacts doivent avoir un champ
phone - Le statut de la liste sera mis à jour à
ready
Codes d’erreur
| Code | Description |
|---|---|
400 | INVALID_CONTACTS - contacts doit être un tableau non vide |
401 | INVALID_SECRET_KEY - Clé secrète invalide |
404 | Liste non trouvée |
500 | ADD_CONTACTS_ERROR - Erreur lors de l’ajout |
