Lists
Create a list
POST
/
api
/
v1
/
lists
Create a list
curl --request POST \
--url https://{host}/api/v1/lists \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Newsletter",
"locale": "fr",
"from_email": "bonjour@exemple.com",
"from_name": "Boulangerie Dupont",
"requires_confirmation": true
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Newsletter',
locale: 'fr',
from_email: 'bonjour@exemple.com',
from_name: 'Boulangerie Dupont',
requires_confirmation: true
})
};
fetch('https://{host}/api/v1/lists', 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/lists",
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' => 'Newsletter',
'locale' => 'fr',
'from_email' => 'bonjour@exemple.com',
'from_name' => 'Boulangerie Dupont',
'requires_confirmation' => true
]),
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/lists"
payload = {
"name": "Newsletter",
"locale": "fr",
"from_email": "bonjour@exemple.com",
"from_name": "Boulangerie Dupont",
"requires_confirmation": True
}
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": "Bakery customers",
"locale": "en",
"from_email": "jsmith@example.com",
"from_name": "<string>",
"requires_confirmation": true,
"subscribed_count": 123,
"created_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "<string>"
}{
"message": "The email field must be a valid email address.",
"errors": {}
}Authorizations
An API token. The "read" ability: GET routes only. "read + write": every route.
Headers
Replay a write safely: the same key gives back the first answer for 24 hours (header Idempotent-Replay: true).
Maximum string length:
255Body
application/json
Response
The list that was created.
Show child attributes
Show child attributes
⌘I
Create a list
curl --request POST \
--url https://{host}/api/v1/lists \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Newsletter",
"locale": "fr",
"from_email": "bonjour@exemple.com",
"from_name": "Boulangerie Dupont",
"requires_confirmation": true
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Newsletter',
locale: 'fr',
from_email: 'bonjour@exemple.com',
from_name: 'Boulangerie Dupont',
requires_confirmation: true
})
};
fetch('https://{host}/api/v1/lists', 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/lists",
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' => 'Newsletter',
'locale' => 'fr',
'from_email' => 'bonjour@exemple.com',
'from_name' => 'Boulangerie Dupont',
'requires_confirmation' => true
]),
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/lists"
payload = {
"name": "Newsletter",
"locale": "fr",
"from_email": "bonjour@exemple.com",
"from_name": "Boulangerie Dupont",
"requires_confirmation": True
}
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": "Bakery customers",
"locale": "en",
"from_email": "jsmith@example.com",
"from_name": "<string>",
"requires_confirmation": true,
"subscribed_count": 123,
"created_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "<string>"
}{
"message": "The email field must be a valid email address.",
"errors": {}
}