curl --request POST \
--url https://api.politicalcomms.com/v1/email/lists \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "August donors",
"consent_attestation": {
"source": "webform",
"note": "Donate page opt-in checkbox"
}
}
'import requests
url = "https://api.politicalcomms.com/v1/email/lists"
payload = {
"name": "August donors",
"consent_attestation": {
"source": "webform",
"note": "Donate page opt-in checkbox"
}
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'August donors',
consent_attestation: {source: 'webform', note: 'Donate page opt-in checkbox'}
})
};
fetch('https://api.politicalcomms.com/v1/email/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://api.politicalcomms.com/v1/email/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' => 'August donors',
'consent_attestation' => [
'source' => 'webform',
'note' => 'Donate page opt-in checkbox'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.politicalcomms.com/v1/email/lists"
payload := strings.NewReader("{\n \"name\": \"August donors\",\n \"consent_attestation\": {\n \"source\": \"webform\",\n \"note\": \"Donate page opt-in checkbox\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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))
}HttpResponse<String> response = Unirest.post("https://api.politicalcomms.com/v1/email/lists")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"August donors\",\n \"consent_attestation\": {\n \"source\": \"webform\",\n \"note\": \"Donate page opt-in checkbox\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.politicalcomms.com/v1/email/lists")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"August donors\",\n \"consent_attestation\": {\n \"source\": \"webform\",\n \"note\": \"Donate page opt-in checkbox\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"source_type": "uploaded",
"status": "processing",
"description": "<string>",
"acquired": "<string>",
"sunset_enabled": true,
"validated_at": "2023-11-07T05:31:56Z",
"counts": {
"total": 123,
"sendable": 123,
"bounced": 123,
"complained": 123,
"unsubscribed": 123,
"invalid": 123,
"suppressed_global": 123
},
"last_send_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"email_domain_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}Create Email List
Create an email list. consent_attestation is required: you are recording how the people on this list agreed to hear from you.
Early access. This endpoint returns 403 EMAIL_EARLY_ACCESS until the email product reaches general availability. The contract below is stable and safe to build against.
curl --request POST \
--url https://api.politicalcomms.com/v1/email/lists \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "August donors",
"consent_attestation": {
"source": "webform",
"note": "Donate page opt-in checkbox"
}
}
'import requests
url = "https://api.politicalcomms.com/v1/email/lists"
payload = {
"name": "August donors",
"consent_attestation": {
"source": "webform",
"note": "Donate page opt-in checkbox"
}
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'August donors',
consent_attestation: {source: 'webform', note: 'Donate page opt-in checkbox'}
})
};
fetch('https://api.politicalcomms.com/v1/email/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://api.politicalcomms.com/v1/email/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' => 'August donors',
'consent_attestation' => [
'source' => 'webform',
'note' => 'Donate page opt-in checkbox'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.politicalcomms.com/v1/email/lists"
payload := strings.NewReader("{\n \"name\": \"August donors\",\n \"consent_attestation\": {\n \"source\": \"webform\",\n \"note\": \"Donate page opt-in checkbox\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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))
}HttpResponse<String> response = Unirest.post("https://api.politicalcomms.com/v1/email/lists")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"August donors\",\n \"consent_attestation\": {\n \"source\": \"webform\",\n \"note\": \"Donate page opt-in checkbox\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.politicalcomms.com/v1/email/lists")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"August donors\",\n \"consent_attestation\": {\n \"source\": \"webform\",\n \"note\": \"Donate page opt-in checkbox\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"source_type": "uploaded",
"status": "processing",
"description": "<string>",
"acquired": "<string>",
"sunset_enabled": true,
"validated_at": "2023-11-07T05:31:56Z",
"counts": {
"total": 123,
"sendable": 123,
"bounced": 123,
"complained": 123,
"unsubscribed": 123,
"invalid": 123,
"suppressed_global": 123
},
"last_send_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"email_domain_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}Authorizations
Authenticate every request by passing your API key in the X-API-Key header. Keys are scoped to your organization hierarchy.
Headers
Optional idempotency key: a unique string of 16-200 printable ASCII characters (a UUID is recommended). Retrying the write with the same key within 24 hours returns the stored response of the first call with an X-Idempotent-Replayed: true response header instead of executing it again. Reusing a key with a different request body returns 422 (IDEMPOTENCY_MISMATCH); a duplicate sent while the first call is still running returns 409 with a Retry-After header. Keys are scoped per endpoint and organization.
16 - 200Body
255How the people on this list consented to hear from you.
Show child attributes
Show child attributes
2000Scopes the list to one sending domain. Omit for an organization-wide list any campaign can use.
Set this when the list came from somewhere other than your own sign-up flow. Acquired lists require paid validation before their first send.
255