curl --request POST \
--url https://api.politicalcomms.com/v1/projects/{id}/test \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"test_contacts": [
{
"phone": "+15555550100"
},
{
"phone": "+12074323729",
"merge_values": {
"first_name": "hunter",
"voter_id": "123456"
}
}
]
}
'import requests
url = "https://api.politicalcomms.com/v1/projects/{id}/test"
payload = { "test_contacts": [
{ "phone": "+15555550100" },
{
"phone": "+12074323729",
"merge_values": {
"first_name": "hunter",
"voter_id": "123456"
}
}
] }
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({
test_contacts: [
{phone: '+15555550100'},
{
phone: '+12074323729',
merge_values: {first_name: 'hunter', voter_id: '123456'}
}
]
})
};
fetch('https://api.politicalcomms.com/v1/projects/{id}/test', 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/projects/{id}/test",
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([
'test_contacts' => [
[
'phone' => '+15555550100'
],
[
'phone' => '+12074323729',
'merge_values' => [
'first_name' => 'hunter',
'voter_id' => '123456'
]
]
]
]),
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/projects/{id}/test"
payload := strings.NewReader("{\n \"test_contacts\": [\n {\n \"phone\": \"+15555550100\"\n },\n {\n \"phone\": \"+12074323729\",\n \"merge_values\": {\n \"first_name\": \"hunter\",\n \"voter_id\": \"123456\"\n }\n }\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/projects/{id}/test")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"test_contacts\": [\n {\n \"phone\": \"+15555550100\"\n },\n {\n \"phone\": \"+12074323729\",\n \"merge_values\": {\n \"first_name\": \"hunter\",\n \"voter_id\": \"123456\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.politicalcomms.com/v1/projects/{id}/test")
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 \"test_contacts\": [\n {\n \"phone\": \"+15555550100\"\n },\n {\n \"phone\": \"+12074323729\",\n \"merge_values\": {\n \"first_name\": \"hunter\",\n \"voter_id\": \"123456\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"project_id": "8a3f5c7e-2d91-4b64-ae08-6f1c9d3e7b52",
"status": "awaiting_test",
"test_messages": [
{
"test_message_id": "01J1F8B2ZC4D5E6F7G8H9J0K1M",
"sent_to": "+1555****100"
}
]
}
}Test Project
Send test message(s). Pass test_contacts as an array of 1-50 objects. By default, merge fields in the message template are rendered from a sample contact in the project’s contact list, not from the request; for a survey, every question renders from that same contact. With no list, tags resolve as they would for a recipient with an empty field (inline fallback, then the organization default, then the standard platform default). Any contact in test_contacts can instead supply merge_values: when present, no contact is sampled from the project’s lists for that entry, every merge tag renders from the supplied values, and a tag not supplied (or supplied empty) falls back the same way an empty field would. This also drives survey follow-up question rendering, and works whether or not the project has a contact list attached.
curl --request POST \
--url https://api.politicalcomms.com/v1/projects/{id}/test \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"test_contacts": [
{
"phone": "+15555550100"
},
{
"phone": "+12074323729",
"merge_values": {
"first_name": "hunter",
"voter_id": "123456"
}
}
]
}
'import requests
url = "https://api.politicalcomms.com/v1/projects/{id}/test"
payload = { "test_contacts": [
{ "phone": "+15555550100" },
{
"phone": "+12074323729",
"merge_values": {
"first_name": "hunter",
"voter_id": "123456"
}
}
] }
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({
test_contacts: [
{phone: '+15555550100'},
{
phone: '+12074323729',
merge_values: {first_name: 'hunter', voter_id: '123456'}
}
]
})
};
fetch('https://api.politicalcomms.com/v1/projects/{id}/test', 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/projects/{id}/test",
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([
'test_contacts' => [
[
'phone' => '+15555550100'
],
[
'phone' => '+12074323729',
'merge_values' => [
'first_name' => 'hunter',
'voter_id' => '123456'
]
]
]
]),
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/projects/{id}/test"
payload := strings.NewReader("{\n \"test_contacts\": [\n {\n \"phone\": \"+15555550100\"\n },\n {\n \"phone\": \"+12074323729\",\n \"merge_values\": {\n \"first_name\": \"hunter\",\n \"voter_id\": \"123456\"\n }\n }\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/projects/{id}/test")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"test_contacts\": [\n {\n \"phone\": \"+15555550100\"\n },\n {\n \"phone\": \"+12074323729\",\n \"merge_values\": {\n \"first_name\": \"hunter\",\n \"voter_id\": \"123456\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.politicalcomms.com/v1/projects/{id}/test")
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 \"test_contacts\": [\n {\n \"phone\": \"+15555550100\"\n },\n {\n \"phone\": \"+12074323729\",\n \"merge_values\": {\n \"first_name\": \"hunter\",\n \"voter_id\": \"123456\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"project_id": "8a3f5c7e-2d91-4b64-ae08-6f1c9d3e7b52",
"status": "awaiting_test",
"test_messages": [
{
"test_message_id": "01J1F8B2ZC4D5E6F7G8H9J0K1M",
"sent_to": "+1555****100"
}
]
}
}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 - 200Path Parameters
Resource ID
Body
1 - 50 elementsShow child attributes
Show child attributes
