Modifier une campagne
curl --request PUT \
--url https://api.wachap.com/v1/campaigns/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"messageType": "<string>",
"messageContent": {},
"variations": [
{
"id": "<string>",
"content": "<string>",
"mediaUrl": "<string>",
"buttons": [
{
"id": "confirm",
"text": "Confirmer",
"type": "reply"
}
],
"footerText": "<string>"
}
],
"delayBetweenMessages": 123,
"scheduled": true,
"scheduledDate": "<string>"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
messageType: '<string>',
messageContent: {},
variations: [
{
id: '<string>',
content: '<string>',
mediaUrl: '<string>',
buttons: [{id: 'confirm', text: 'Confirmer', type: 'reply'}],
footerText: '<string>'
}
],
delayBetweenMessages: 123,
scheduled: true,
scheduledDate: '<string>'
})
};
fetch('https://api.wachap.com/v1/campaigns/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
messageType: '<string>',
messageContent: {},
variations: [
{
id: '<string>',
content: '<string>',
mediaUrl: '<string>',
buttons: [{id: 'confirm', text: 'Confirmer', type: 'reply'}],
footerText: '<string>'
}
],
delayBetweenMessages: 123,
scheduled: true,
scheduledDate: '<string>'
})
};
fetch('https://api.wachap.com/v1/campaigns/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/campaigns/{id}"
payload = {
"name": "<string>",
"messageType": "<string>",
"messageContent": {},
"variations": [
{
"id": "<string>",
"content": "<string>",
"mediaUrl": "<string>",
"buttons": [
{
"id": "confirm",
"text": "Confirmer",
"type": "reply"
}
],
"footerText": "<string>"
}
],
"delayBetweenMessages": 123,
"scheduled": True,
"scheduledDate": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/campaigns/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'messageType' => '<string>',
'messageContent' => [
],
'variations' => [
[
'id' => '<string>',
'content' => '<string>',
'mediaUrl' => '<string>',
'buttons' => [
[
'id' => 'confirm',
'text' => 'Confirmer',
'type' => 'reply'
]
],
'footerText' => '<string>'
]
],
'delayBetweenMessages' => 123,
'scheduled' => true,
'scheduledDate' => '<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/campaigns/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"messageType\": \"<string>\",\n \"messageContent\": {},\n \"variations\": [\n {\n \"id\": \"<string>\",\n \"content\": \"<string>\",\n \"mediaUrl\": \"<string>\",\n \"buttons\": [\n {\n \"id\": \"confirm\",\n \"text\": \"Confirmer\",\n \"type\": \"reply\"\n }\n ],\n \"footerText\": \"<string>\"\n }\n ],\n \"delayBetweenMessages\": 123,\n \"scheduled\": true,\n \"scheduledDate\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", 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))
}Campagnes
Modifier une campagne
Mettez à jour les paramètres d’une campagne existante
PUT
/
campaigns
/
{id}
Modifier une campagne
curl --request PUT \
--url https://api.wachap.com/v1/campaigns/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"messageType": "<string>",
"messageContent": {},
"variations": [
{
"id": "<string>",
"content": "<string>",
"mediaUrl": "<string>",
"buttons": [
{
"id": "confirm",
"text": "Confirmer",
"type": "reply"
}
],
"footerText": "<string>"
}
],
"delayBetweenMessages": 123,
"scheduled": true,
"scheduledDate": "<string>"
}
'const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
messageType: '<string>',
messageContent: {},
variations: [
{
id: '<string>',
content: '<string>',
mediaUrl: '<string>',
buttons: [{id: 'confirm', text: 'Confirmer', type: 'reply'}],
footerText: '<string>'
}
],
delayBetweenMessages: 123,
scheduled: true,
scheduledDate: '<string>'
})
};
fetch('https://api.wachap.com/v1/campaigns/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
messageType: '<string>',
messageContent: {},
variations: [
{
id: '<string>',
content: '<string>',
mediaUrl: '<string>',
buttons: [{id: 'confirm', text: 'Confirmer', type: 'reply'}],
footerText: '<string>'
}
],
delayBetweenMessages: 123,
scheduled: true,
scheduledDate: '<string>'
})
};
fetch('https://api.wachap.com/v1/campaigns/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/campaigns/{id}"
payload = {
"name": "<string>",
"messageType": "<string>",
"messageContent": {},
"variations": [
{
"id": "<string>",
"content": "<string>",
"mediaUrl": "<string>",
"buttons": [
{
"id": "confirm",
"text": "Confirmer",
"type": "reply"
}
],
"footerText": "<string>"
}
],
"delayBetweenMessages": 123,
"scheduled": True,
"scheduledDate": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/campaigns/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'messageType' => '<string>',
'messageContent' => [
],
'variations' => [
[
'id' => '<string>',
'content' => '<string>',
'mediaUrl' => '<string>',
'buttons' => [
[
'id' => 'confirm',
'text' => 'Confirmer',
'type' => 'reply'
]
],
'footerText' => '<string>'
]
],
'delayBetweenMessages' => 123,
'scheduled' => true,
'scheduledDate' => '<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/campaigns/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"messageType\": \"<string>\",\n \"messageContent\": {},\n \"variations\": [\n {\n \"id\": \"<string>\",\n \"content\": \"<string>\",\n \"mediaUrl\": \"<string>\",\n \"buttons\": [\n {\n \"id\": \"confirm\",\n \"text\": \"Confirmer\",\n \"type\": \"reply\"\n }\n ],\n \"footerText\": \"<string>\"\n }\n ],\n \"delayBetweenMessages\": 123,\n \"scheduled\": true,\n \"scheduledDate\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", 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))
}Modifier une campagne
Mettez à jour les paramètres d’une campagne existante.Endpoint
/v1/campaigns/:id
Headers
Bearer token avec votre Secret Key (format:
Bearer sk_...)URL Parameters
L’identifiant de la campagne
Body Parameters
Tous les paramètres sont optionnels. Seuls les champs fournis seront mis à jour.Nouveau nom de la campagne
Nouveau contenu du message
Nouvelles variations de message. Chaque variation
text, image, video ou document peut inclure buttons et footerText.Nouveau délai entre messages (ms)
Activer/désactiver la programmation
Nouvelle date de programmation
Restrictions
- ❌ Vous ne pouvez pas modifier une campagne avec le statut
running. - ❌ Vous ne pouvez pas modifier une campagne avec le statut
completed. - ✅ Vous pouvez modifier une campagne
draftoupaused.
- Mettez-la en pause.
- Modifiez les paramètres.
- Reprenez-la.
Exemples de requêtes
curl -X PUT https://api.wachap.com/v1/campaigns/campaign_abc123 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"name": "Campagne Modifiée",
"variations": [
{
"id": "var_1",
"type": "text",
"content": "Souhaitez-vous confirmer ?",
"buttons": [
{"id": "yes", "text": "Oui", "type": "reply"},
{"id": "no", "text": "Non", "type": "reply"}
],
"footerText": "WaChap"
}
],
"delayBetweenMessages": 3000
}'
buttons: [] et omettez footerText.
Exemple de réponse
{
"success": true,
"message": "Campagne mise à jour avec succès",
"campaign": {
"id": "campaign_abc123",
"name": "Campagne Modifiée",
"delayBetweenMessages": 3000,
"updatedAt": "2024-01-16T10:00:00.000Z"
}
}
Codes d’erreur
| Code | Description |
|---|---|
401 | INVALID_SECRET_KEY - Clé secrète invalide |
404 | CAMPAIGN_NOT_FOUND - Campagne non trouvée |
409 | CAMPAIGN_RUNNING - Impossible de modifier une campagne en cours |
409 | CAMPAIGN_COMPLETED - Impossible de modifier une campagne terminée |
Autorisations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Paramètres de chemin
Corps
application/json
Réponse
OK
⌘I
