Créer une liste de contacts
curl --request POST \
--url https://api.wachap.com/v1/contact-groups/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"csvUrl": "<string>",
"contacts": [
{
"phone": "<string>",
"name": "<string>",
"city": "<string>"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
csvUrl: '<string>',
contacts: [{phone: '<string>', name: '<string>', city: '<string>'}]
})
};
fetch('https://api.wachap.com/v1/contact-groups/create', 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({
name: '<string>',
csvUrl: '<string>',
contacts: [{phone: '<string>', name: '<string>', city: '<string>'}]
})
};
fetch('https://api.wachap.com/v1/contact-groups/create', 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/create"
payload = {
"name": "<string>",
"csvUrl": "<string>",
"contacts": [
{
"phone": "<string>",
"name": "<string>",
"city": "<string>"
}
]
}
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/create",
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([
'name' => '<string>',
'csvUrl' => '<string>',
'contacts' => [
[
'phone' => '<string>',
'name' => '<string>',
'city' => '<string>'
]
]
]),
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/create"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"csvUrl\": \"<string>\",\n \"contacts\": [\n {\n \"phone\": \"<string>\",\n \"name\": \"<string>\",\n \"city\": \"<string>\"\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
Créer une liste
Créez une nouvelle liste de contacts pour organiser vos contacts et les réutiliser dans plusieurs campagnes.
POST
/
contact-groups
/
create
Créer une liste de contacts
curl --request POST \
--url https://api.wachap.com/v1/contact-groups/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"csvUrl": "<string>",
"contacts": [
{
"phone": "<string>",
"name": "<string>",
"city": "<string>"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
csvUrl: '<string>',
contacts: [{phone: '<string>', name: '<string>', city: '<string>'}]
})
};
fetch('https://api.wachap.com/v1/contact-groups/create', 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({
name: '<string>',
csvUrl: '<string>',
contacts: [{phone: '<string>', name: '<string>', city: '<string>'}]
})
};
fetch('https://api.wachap.com/v1/contact-groups/create', 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/create"
payload = {
"name": "<string>",
"csvUrl": "<string>",
"contacts": [
{
"phone": "<string>",
"name": "<string>",
"city": "<string>"
}
]
}
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/create",
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([
'name' => '<string>',
'csvUrl' => '<string>',
'contacts' => [
[
'phone' => '<string>',
'name' => '<string>',
'city' => '<string>'
]
]
]),
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/create"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"csvUrl\": \"<string>\",\n \"contacts\": [\n {\n \"phone\": \"<string>\",\n \"name\": \"<string>\",\n \"city\": \"<string>\"\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
/v1/contact-groups/create
Headers
Bearer token avec votre Secret Key (format:
Bearer sk_...)Body Parameters
Nom de la liste de contacts
URL d’un fichier CSV à importer
Liste de contacts à ajouter directement (format JSON). Voir structure ci-dessous.
Structure d’un contact (si fourni via JSON)
| 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
# Création via JSON direct
curl -X POST https://api.wachap.com/v1/contact-groups/create \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"name": "Clients Premium",
"contacts": [
{
"phone": "+2290112345678",
"name": "John Doe",
"city": "Abidjan"
},
{
"phone": "+33612345678",
"name": "Marie Dupont",
"city": "Paris"
}
]
}'
# Création via URL CSV
curl -X POST https://api.wachap.com/v1/contact-groups/create \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"name": "Import CSV",
"csvUrl": "https://example.com/contacts.csv"
}'
const response = await fetch('https://api.wachap.com/v1/contact-groups/create', {
method: 'POST',
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Clients Premium',
contacts: [
{ phone: '+2290112345678', name: 'John Doe' }
]
})
});
const data = await response.json();
console.log(data);
import requests
url = "https://api.wachap.com/v1/contact-groups/create"
headers = {
"Authorization": "Bearer token",
"Content-Type": "application/json"
}
payload = {
"name": "Clients Premium",
"contacts": [
{ "phone": "+2290112345678", "name": "John Doe" }
]
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$curl = curl_init();
$payload = [
"name" => "Clients Premium",
"contacts" => [
["phone" => "+2290112345678", "name" => "John Doe"]
]
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/contact-groups/create",
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,
"listId": "65f1234567890abcdef12345",
"contactGroup": {
"$id": "65f1234567890abcdef12345",
"userId": "user_xxx",
"name": "Clients Premium",
"csvUrl": null,
"status": "ready",
"createdAt": "2024-03-15T10:00:00.000Z",
"updatedAt": "2024-03-15T10:00:00.000Z"
}
}
Statuts possibles
| Statut | Description |
|---|---|
ready | Liste prête à être utilisée |
importing | Import CSV en cours |
Codes d’erreur
| Code | Description |
|---|---|
400 | MISSING_NAME - Le nom de la liste est requis |
401 | INVALID_SECRET_KEY - Clé secrète invalide |
500 | CREATE_CONTACT_GROUP_ERROR - Erreur lors de la création |
⌘I
