Send a dynamically templated message
curl --request POST \
--url https://api.paubox.com/v1/email/templated_messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"template_name": "detailed_test",
"template_values": "{ \"name\": \"Howard\", \"conditional\":\"true\",\"items\":[\"one\",\"two\",\"three\"] }",
"message": {
"recipients": [
"recipient@host.com",
"Recipient Name <recipient2@host.com>"
],
"bcc": [
"recipient3@host.com",
"Recipient Name <recipient4@host.com>"
],
"headers": {
"subject": "sample email",
"from": "sender@authorized_domain.com",
"reply-to": "Sender Name <sender@authorized_domain.com>"
},
"allowNonTLS": false,
"forceSecureNotification": false,
"attachments": [
{
"fileName": "hello_world.txt",
"contentType": "text/plain",
"content": "SGVsbG8gV29ybGQ"
}
]
}
}
}
'import requests
url = "https://api.paubox.com/v1/email/templated_messages"
payload = { "data": {
"template_name": "detailed_test",
"template_values": "{ \"name\": \"Howard\", \"conditional\":\"true\",\"items\":[\"one\",\"two\",\"three\"] }",
"message": {
"recipients": ["recipient@host.com", "Recipient Name <recipient2@host.com>"],
"bcc": ["recipient3@host.com", "Recipient Name <recipient4@host.com>"],
"headers": {
"subject": "sample email",
"from": "sender@authorized_domain.com",
"reply-to": "Sender Name <sender@authorized_domain.com>"
},
"allowNonTLS": False,
"forceSecureNotification": False,
"attachments": [
{
"fileName": "hello_world.txt",
"contentType": "text/plain",
"content": "SGVsbG8gV29ybGQ"
}
]
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
template_name: 'detailed_test',
template_values: '{ "name": "Howard", "conditional":"true","items":["one","two","three"] }',
message: {
recipients: ['recipient@host.com', 'Recipient Name <recipient2@host.com>'],
bcc: ['recipient3@host.com', 'Recipient Name <recipient4@host.com>'],
headers: {
subject: 'sample email',
from: 'sender@authorized_domain.com',
'reply-to': 'Sender Name <sender@authorized_domain.com>'
},
allowNonTLS: false,
forceSecureNotification: false,
attachments: [
{
fileName: 'hello_world.txt',
contentType: 'text/plain',
content: 'SGVsbG8gV29ybGQ'
}
]
}
}
})
};
fetch('https://api.paubox.com/v1/email/templated_messages', 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.paubox.com/v1/email/templated_messages",
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([
'data' => [
'template_name' => 'detailed_test',
'template_values' => '{ "name": "Howard", "conditional":"true","items":["one","two","three"] }',
'message' => [
'recipients' => [
'recipient@host.com',
'Recipient Name <recipient2@host.com>'
],
'bcc' => [
'recipient3@host.com',
'Recipient Name <recipient4@host.com>'
],
'headers' => [
'subject' => 'sample email',
'from' => 'sender@authorized_domain.com',
'reply-to' => 'Sender Name <sender@authorized_domain.com>'
],
'allowNonTLS' => false,
'forceSecureNotification' => false,
'attachments' => [
[
'fileName' => 'hello_world.txt',
'contentType' => 'text/plain',
'content' => 'SGVsbG8gV29ybGQ'
]
]
]
]
]),
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.paubox.com/v1/email/templated_messages"
payload := strings.NewReader("{\n \"data\": {\n \"template_name\": \"detailed_test\",\n \"template_values\": \"{ \\\"name\\\": \\\"Howard\\\", \\\"conditional\\\":\\\"true\\\",\\\"items\\\":[\\\"one\\\",\\\"two\\\",\\\"three\\\"] }\",\n \"message\": {\n \"recipients\": [\n \"recipient@host.com\",\n \"Recipient Name <recipient2@host.com>\"\n ],\n \"bcc\": [\n \"recipient3@host.com\",\n \"Recipient Name <recipient4@host.com>\"\n ],\n \"headers\": {\n \"subject\": \"sample email\",\n \"from\": \"sender@authorized_domain.com\",\n \"reply-to\": \"Sender Name <sender@authorized_domain.com>\"\n },\n \"allowNonTLS\": false,\n \"forceSecureNotification\": false,\n \"attachments\": [\n {\n \"fileName\": \"hello_world.txt\",\n \"contentType\": \"text/plain\",\n \"content\": \"SGVsbG8gV29ybGQ\"\n }\n ]\n }\n }\n}")
req, _ := http.NewRequest("POST", 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))
}HttpResponse<String> response = Unirest.post("https://api.paubox.com/v1/email/templated_messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"template_name\": \"detailed_test\",\n \"template_values\": \"{ \\\"name\\\": \\\"Howard\\\", \\\"conditional\\\":\\\"true\\\",\\\"items\\\":[\\\"one\\\",\\\"two\\\",\\\"three\\\"] }\",\n \"message\": {\n \"recipients\": [\n \"recipient@host.com\",\n \"Recipient Name <recipient2@host.com>\"\n ],\n \"bcc\": [\n \"recipient3@host.com\",\n \"Recipient Name <recipient4@host.com>\"\n ],\n \"headers\": {\n \"subject\": \"sample email\",\n \"from\": \"sender@authorized_domain.com\",\n \"reply-to\": \"Sender Name <sender@authorized_domain.com>\"\n },\n \"allowNonTLS\": false,\n \"forceSecureNotification\": false,\n \"attachments\": [\n {\n \"fileName\": \"hello_world.txt\",\n \"contentType\": \"text/plain\",\n \"content\": \"SGVsbG8gV29ybGQ\"\n }\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paubox.com/v1/email/templated_messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"template_name\": \"detailed_test\",\n \"template_values\": \"{ \\\"name\\\": \\\"Howard\\\", \\\"conditional\\\":\\\"true\\\",\\\"items\\\":[\\\"one\\\",\\\"two\\\",\\\"three\\\"] }\",\n \"message\": {\n \"recipients\": [\n \"recipient@host.com\",\n \"Recipient Name <recipient2@host.com>\"\n ],\n \"bcc\": [\n \"recipient3@host.com\",\n \"Recipient Name <recipient4@host.com>\"\n ],\n \"headers\": {\n \"subject\": \"sample email\",\n \"from\": \"sender@authorized_domain.com\",\n \"reply-to\": \"Sender Name <sender@authorized_domain.com>\"\n },\n \"allowNonTLS\": false,\n \"forceSecureNotification\": false,\n \"attachments\": [\n {\n \"fileName\": \"hello_world.txt\",\n \"contentType\": \"text/plain\",\n \"content\": \"SGVsbG8gV29ybGQ\"\n }\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"sourceTrackingId": "3d38ab13-0af8-4028-bd45-XXXXXXXXXXXX",
"data": "Service OK"
}{
"errors": [
{
"code": 123,
"title": "<string>",
"details": "<string>"
}
]
}Email API · Dynamic templates
Send a templated message
Send an email using a dynamic template with variable substitution
POST
/
templated_messages
Send a dynamically templated message
curl --request POST \
--url https://api.paubox.com/v1/email/templated_messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"template_name": "detailed_test",
"template_values": "{ \"name\": \"Howard\", \"conditional\":\"true\",\"items\":[\"one\",\"two\",\"three\"] }",
"message": {
"recipients": [
"recipient@host.com",
"Recipient Name <recipient2@host.com>"
],
"bcc": [
"recipient3@host.com",
"Recipient Name <recipient4@host.com>"
],
"headers": {
"subject": "sample email",
"from": "sender@authorized_domain.com",
"reply-to": "Sender Name <sender@authorized_domain.com>"
},
"allowNonTLS": false,
"forceSecureNotification": false,
"attachments": [
{
"fileName": "hello_world.txt",
"contentType": "text/plain",
"content": "SGVsbG8gV29ybGQ"
}
]
}
}
}
'import requests
url = "https://api.paubox.com/v1/email/templated_messages"
payload = { "data": {
"template_name": "detailed_test",
"template_values": "{ \"name\": \"Howard\", \"conditional\":\"true\",\"items\":[\"one\",\"two\",\"three\"] }",
"message": {
"recipients": ["recipient@host.com", "Recipient Name <recipient2@host.com>"],
"bcc": ["recipient3@host.com", "Recipient Name <recipient4@host.com>"],
"headers": {
"subject": "sample email",
"from": "sender@authorized_domain.com",
"reply-to": "Sender Name <sender@authorized_domain.com>"
},
"allowNonTLS": False,
"forceSecureNotification": False,
"attachments": [
{
"fileName": "hello_world.txt",
"contentType": "text/plain",
"content": "SGVsbG8gV29ybGQ"
}
]
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
template_name: 'detailed_test',
template_values: '{ "name": "Howard", "conditional":"true","items":["one","two","three"] }',
message: {
recipients: ['recipient@host.com', 'Recipient Name <recipient2@host.com>'],
bcc: ['recipient3@host.com', 'Recipient Name <recipient4@host.com>'],
headers: {
subject: 'sample email',
from: 'sender@authorized_domain.com',
'reply-to': 'Sender Name <sender@authorized_domain.com>'
},
allowNonTLS: false,
forceSecureNotification: false,
attachments: [
{
fileName: 'hello_world.txt',
contentType: 'text/plain',
content: 'SGVsbG8gV29ybGQ'
}
]
}
}
})
};
fetch('https://api.paubox.com/v1/email/templated_messages', 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.paubox.com/v1/email/templated_messages",
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([
'data' => [
'template_name' => 'detailed_test',
'template_values' => '{ "name": "Howard", "conditional":"true","items":["one","two","three"] }',
'message' => [
'recipients' => [
'recipient@host.com',
'Recipient Name <recipient2@host.com>'
],
'bcc' => [
'recipient3@host.com',
'Recipient Name <recipient4@host.com>'
],
'headers' => [
'subject' => 'sample email',
'from' => 'sender@authorized_domain.com',
'reply-to' => 'Sender Name <sender@authorized_domain.com>'
],
'allowNonTLS' => false,
'forceSecureNotification' => false,
'attachments' => [
[
'fileName' => 'hello_world.txt',
'contentType' => 'text/plain',
'content' => 'SGVsbG8gV29ybGQ'
]
]
]
]
]),
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.paubox.com/v1/email/templated_messages"
payload := strings.NewReader("{\n \"data\": {\n \"template_name\": \"detailed_test\",\n \"template_values\": \"{ \\\"name\\\": \\\"Howard\\\", \\\"conditional\\\":\\\"true\\\",\\\"items\\\":[\\\"one\\\",\\\"two\\\",\\\"three\\\"] }\",\n \"message\": {\n \"recipients\": [\n \"recipient@host.com\",\n \"Recipient Name <recipient2@host.com>\"\n ],\n \"bcc\": [\n \"recipient3@host.com\",\n \"Recipient Name <recipient4@host.com>\"\n ],\n \"headers\": {\n \"subject\": \"sample email\",\n \"from\": \"sender@authorized_domain.com\",\n \"reply-to\": \"Sender Name <sender@authorized_domain.com>\"\n },\n \"allowNonTLS\": false,\n \"forceSecureNotification\": false,\n \"attachments\": [\n {\n \"fileName\": \"hello_world.txt\",\n \"contentType\": \"text/plain\",\n \"content\": \"SGVsbG8gV29ybGQ\"\n }\n ]\n }\n }\n}")
req, _ := http.NewRequest("POST", 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))
}HttpResponse<String> response = Unirest.post("https://api.paubox.com/v1/email/templated_messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"template_name\": \"detailed_test\",\n \"template_values\": \"{ \\\"name\\\": \\\"Howard\\\", \\\"conditional\\\":\\\"true\\\",\\\"items\\\":[\\\"one\\\",\\\"two\\\",\\\"three\\\"] }\",\n \"message\": {\n \"recipients\": [\n \"recipient@host.com\",\n \"Recipient Name <recipient2@host.com>\"\n ],\n \"bcc\": [\n \"recipient3@host.com\",\n \"Recipient Name <recipient4@host.com>\"\n ],\n \"headers\": {\n \"subject\": \"sample email\",\n \"from\": \"sender@authorized_domain.com\",\n \"reply-to\": \"Sender Name <sender@authorized_domain.com>\"\n },\n \"allowNonTLS\": false,\n \"forceSecureNotification\": false,\n \"attachments\": [\n {\n \"fileName\": \"hello_world.txt\",\n \"contentType\": \"text/plain\",\n \"content\": \"SGVsbG8gV29ybGQ\"\n }\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paubox.com/v1/email/templated_messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"template_name\": \"detailed_test\",\n \"template_values\": \"{ \\\"name\\\": \\\"Howard\\\", \\\"conditional\\\":\\\"true\\\",\\\"items\\\":[\\\"one\\\",\\\"two\\\",\\\"three\\\"] }\",\n \"message\": {\n \"recipients\": [\n \"recipient@host.com\",\n \"Recipient Name <recipient2@host.com>\"\n ],\n \"bcc\": [\n \"recipient3@host.com\",\n \"Recipient Name <recipient4@host.com>\"\n ],\n \"headers\": {\n \"subject\": \"sample email\",\n \"from\": \"sender@authorized_domain.com\",\n \"reply-to\": \"Sender Name <sender@authorized_domain.com>\"\n },\n \"allowNonTLS\": false,\n \"forceSecureNotification\": false,\n \"attachments\": [\n {\n \"fileName\": \"hello_world.txt\",\n \"contentType\": \"text/plain\",\n \"content\": \"SGVsbG8gV29ybGQ\"\n }\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"sourceTrackingId": "3d38ab13-0af8-4028-bd45-XXXXXXXXXXXX",
"data": "Service OK"
}{
"errors": [
{
"code": 123,
"title": "<string>",
"details": "<string>"
}
]
}Authorizations
Paubox API uses Bearer token authentication in the Authorization header.
Format: Authorization: Bearer YOUR_API_KEY_HERE
Example: Authorization: Bearer 9e5b092b632445b8f570c62ae54f30fda1044305
The legacy format Authorization: Token token=YOUR_API_KEY_HERE is also supported.
Body
application/json
Show child attributes
Show child attributes
⌘I