Campagnes
Créer une campagne
La campagne naît en brouillon. Les réglages avancés (segment, expéditeur, UTM, test A/B, étalement, fuseau) se font dans l’interface.
POST
/
api
/
v1
/
campaigns
Créer une campagne
curl --request POST \
--url https://{host}/api/v1/campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Offre de Noël",
"subject": "Bonjour {{ subscriber.first_name }}, nos bûches sont là",
"list": "9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12",
"editor": "html",
"content": "<p>Bonjour {{ subscriber.first_name }},</p><p><a href=\"https://exemple.com/noel\">Commander</a></p>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Offre de Noël',
subject: 'Bonjour {{ subscriber.first_name }}, nos bûches sont là',
list: '9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12',
editor: 'html',
content: '<p>Bonjour {{ subscriber.first_name }},</p><p><a href="https://exemple.com/noel">Commander</a></p>'
})
};
fetch('https://{host}/api/v1/campaigns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/v1/campaigns",
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' => 'Offre de Noël',
'subject' => 'Bonjour {{ subscriber.first_name }}, nos bûches sont là',
'list' => '9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12',
'editor' => 'html',
'content' => '<p>Bonjour {{ subscriber.first_name }},</p><p><a href="https://exemple.com/noel">Commander</a></p>'
]),
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;
}import requests
url = "https://{host}/api/v1/campaigns"
payload = {
"name": "Offre de Noël",
"subject": "Bonjour {{ subscriber.first_name }}, nos bûches sont là",
"list": "9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12",
"editor": "html",
"content": "<p>Bonjour {{ subscriber.first_name }},</p><p><a href=\"https://exemple.com/noel\">Commander</a></p>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"subject": "<string>",
"status": "draft",
"list": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"statistics": {
"recipients": 123,
"sent": 123,
"delivered": 123,
"opens": 123,
"unique_opens": 123,
"clicks": 123,
"unique_clicks": 123,
"bounces": 123,
"complaints": 123,
"unsubscribes": 123
},
"created_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "<string>"
}{
"message": "Le champ email doit être une adresse e-mail valide.",
"errors": {}
}Autorisations
Jeton d'API. Aptitude « read » : routes GET seulement. « read + write » : toutes les routes.
En-têtes
Rejouez une écriture sans risque : la même clé rend la première réponse pendant 24 heures (en-tête Idempotent-Replay: true).
Maximum string length:
255Corps
application/json
Visible de l'équipe seulement.
Maximum string length:
255Options disponibles:
blocks, markdown, html, mjml Maximum string length:
255500 000 caractères au plus. Pour « blocks », le document JSON de l'éditeur.
Réponse
La campagne créée.
Show child attributes
Show child attributes
⌘I
Créer une campagne
curl --request POST \
--url https://{host}/api/v1/campaigns \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Offre de Noël",
"subject": "Bonjour {{ subscriber.first_name }}, nos bûches sont là",
"list": "9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12",
"editor": "html",
"content": "<p>Bonjour {{ subscriber.first_name }},</p><p><a href=\"https://exemple.com/noel\">Commander</a></p>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Offre de Noël',
subject: 'Bonjour {{ subscriber.first_name }}, nos bûches sont là',
list: '9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12',
editor: 'html',
content: '<p>Bonjour {{ subscriber.first_name }},</p><p><a href="https://exemple.com/noel">Commander</a></p>'
})
};
fetch('https://{host}/api/v1/campaigns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/v1/campaigns",
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' => 'Offre de Noël',
'subject' => 'Bonjour {{ subscriber.first_name }}, nos bûches sont là',
'list' => '9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12',
'editor' => 'html',
'content' => '<p>Bonjour {{ subscriber.first_name }},</p><p><a href="https://exemple.com/noel">Commander</a></p>'
]),
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;
}import requests
url = "https://{host}/api/v1/campaigns"
payload = {
"name": "Offre de Noël",
"subject": "Bonjour {{ subscriber.first_name }}, nos bûches sont là",
"list": "9d5c2a1e-8f3b-4c7a-9e21-3b8f0c6d4a12",
"editor": "html",
"content": "<p>Bonjour {{ subscriber.first_name }},</p><p><a href=\"https://exemple.com/noel\">Commander</a></p>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"subject": "<string>",
"status": "draft",
"list": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scheduled_at": "2023-11-07T05:31:56Z",
"sent_at": "2023-11-07T05:31:56Z",
"statistics": {
"recipients": 123,
"sent": 123,
"delivered": 123,
"opens": 123,
"unique_opens": 123,
"clicks": 123,
"unique_clicks": 123,
"bounces": 123,
"complaints": 123,
"unsubscribes": 123
},
"created_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "<string>"
}{
"message": "Le champ email doit être une adresse e-mail valide.",
"errors": {}
}