curl --request POST \
--url http://localhost:3001/api/v1/emails \
--header 'Content-Type: application/json' \
--header 'idempotency-key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"templateKey": "<string>",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"senderProfileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": "<string>",
"replyTo": "<string>",
"subject": "<string>",
"subscriptionGroupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"cc": "<string>",
"bcc": "<string>",
"data": {},
"tracking": {
"clicks": true
}
}
'import requests
url = "http://localhost:3001/api/v1/emails"
payload = {
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"templateKey": "<string>",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"senderProfileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": "<string>",
"replyTo": "<string>",
"subject": "<string>",
"subscriptionGroupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"cc": "<string>",
"bcc": "<string>",
"data": {},
"tracking": { "clicks": True }
}
headers = {
"idempotency-key": "<idempotency-key>",
"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: {
'idempotency-key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
templateKey: '<string>',
profileId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
senderProfileId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
from: '<string>',
replyTo: '<string>',
subject: '<string>',
subscriptionGroupId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
to: {email: 'jsmith@example.com', externalCustomerId: '<string>'},
cc: '<string>',
bcc: '<string>',
data: {},
tracking: {clicks: true}
})
};
fetch('http://localhost:3001/api/v1/emails', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3001",
CURLOPT_URL => "http://localhost:3001/api/v1/emails",
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([
'templateId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'templateKey' => '<string>',
'profileId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'senderProfileId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'from' => '<string>',
'replyTo' => '<string>',
'subject' => '<string>',
'subscriptionGroupId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'to' => [
'email' => 'jsmith@example.com',
'externalCustomerId' => '<string>'
],
'cc' => '<string>',
'bcc' => '<string>',
'data' => [
],
'tracking' => [
'clicks' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"idempotency-key: <idempotency-key>",
"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 := "http://localhost:3001/api/v1/emails"
payload := strings.NewReader("{\n \"templateId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"templateKey\": \"<string>\",\n \"profileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"senderProfileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"from\": \"<string>\",\n \"replyTo\": \"<string>\",\n \"subject\": \"<string>\",\n \"subscriptionGroupId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"cc\": \"<string>\",\n \"bcc\": \"<string>\",\n \"data\": {},\n \"tracking\": {\n \"clicks\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("idempotency-key", "<idempotency-key>")
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("http://localhost:3001/api/v1/emails")
.header("idempotency-key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"templateId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"templateKey\": \"<string>\",\n \"profileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"senderProfileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"from\": \"<string>\",\n \"replyTo\": \"<string>\",\n \"subject\": \"<string>\",\n \"subscriptionGroupId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"cc\": \"<string>\",\n \"bcc\": \"<string>\",\n \"data\": {},\n \"tracking\": {\n \"clicks\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3001/api/v1/emails")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["idempotency-key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"templateId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"templateKey\": \"<string>\",\n \"profileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"senderProfileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"from\": \"<string>\",\n \"replyTo\": \"<string>\",\n \"subject\": \"<string>\",\n \"subscriptionGroupId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"cc\": \"<string>\",\n \"bcc\": \"<string>\",\n \"data\": {},\n \"tracking\": {\n \"clicks\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "Queued",
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": {
"type": "template",
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"frozenEmailInstanceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"senderProfileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": {
"email": "jsmith@example.com",
"name": "<string>"
},
"replyTo": {
"email": "jsmith@example.com",
"name": "<string>"
},
"subject": "<string>",
"subscriptionGroupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": "jsmith@example.com"
},
"cc": [
{
"email": "jsmith@example.com",
"name": "<string>"
}
],
"messageId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"skippedReason": "ProfileErased",
"failureReason": "WorkerFailed",
"failureMessage": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "RATE_LIMITED",
"message": "Rate limit exceeded. Retry after 12 seconds.",
"details": {
"retryAfterSeconds": 12
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}Send email
Create one EmailSend from either a saved email template or rendered JSX Email content and enqueue delivery. Rendered content must include a request subject.
curl --request POST \
--url http://localhost:3001/api/v1/emails \
--header 'Content-Type: application/json' \
--header 'idempotency-key: <idempotency-key>' \
--header 'x-api-key: <api-key>' \
--data '
{
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"templateKey": "<string>",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"senderProfileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": "<string>",
"replyTo": "<string>",
"subject": "<string>",
"subscriptionGroupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"cc": "<string>",
"bcc": "<string>",
"data": {},
"tracking": {
"clicks": true
}
}
'import requests
url = "http://localhost:3001/api/v1/emails"
payload = {
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"templateKey": "<string>",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"senderProfileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": "<string>",
"replyTo": "<string>",
"subject": "<string>",
"subscriptionGroupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": "jsmith@example.com",
"externalCustomerId": "<string>"
},
"cc": "<string>",
"bcc": "<string>",
"data": {},
"tracking": { "clicks": True }
}
headers = {
"idempotency-key": "<idempotency-key>",
"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: {
'idempotency-key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
templateKey: '<string>',
profileId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
senderProfileId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
from: '<string>',
replyTo: '<string>',
subject: '<string>',
subscriptionGroupId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
to: {email: 'jsmith@example.com', externalCustomerId: '<string>'},
cc: '<string>',
bcc: '<string>',
data: {},
tracking: {clicks: true}
})
};
fetch('http://localhost:3001/api/v1/emails', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3001",
CURLOPT_URL => "http://localhost:3001/api/v1/emails",
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([
'templateId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'templateKey' => '<string>',
'profileId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'senderProfileId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'from' => '<string>',
'replyTo' => '<string>',
'subject' => '<string>',
'subscriptionGroupId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'to' => [
'email' => 'jsmith@example.com',
'externalCustomerId' => '<string>'
],
'cc' => '<string>',
'bcc' => '<string>',
'data' => [
],
'tracking' => [
'clicks' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"idempotency-key: <idempotency-key>",
"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 := "http://localhost:3001/api/v1/emails"
payload := strings.NewReader("{\n \"templateId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"templateKey\": \"<string>\",\n \"profileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"senderProfileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"from\": \"<string>\",\n \"replyTo\": \"<string>\",\n \"subject\": \"<string>\",\n \"subscriptionGroupId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"cc\": \"<string>\",\n \"bcc\": \"<string>\",\n \"data\": {},\n \"tracking\": {\n \"clicks\": true\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("idempotency-key", "<idempotency-key>")
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("http://localhost:3001/api/v1/emails")
.header("idempotency-key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"templateId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"templateKey\": \"<string>\",\n \"profileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"senderProfileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"from\": \"<string>\",\n \"replyTo\": \"<string>\",\n \"subject\": \"<string>\",\n \"subscriptionGroupId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"cc\": \"<string>\",\n \"bcc\": \"<string>\",\n \"data\": {},\n \"tracking\": {\n \"clicks\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3001/api/v1/emails")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["idempotency-key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"templateId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"templateKey\": \"<string>\",\n \"profileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"senderProfileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"from\": \"<string>\",\n \"replyTo\": \"<string>\",\n \"subject\": \"<string>\",\n \"subscriptionGroupId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"to\": {\n \"email\": \"jsmith@example.com\",\n \"externalCustomerId\": \"<string>\"\n },\n \"cc\": \"<string>\",\n \"bcc\": \"<string>\",\n \"data\": {},\n \"tracking\": {\n \"clicks\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "Queued",
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": {
"type": "template",
"templateId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"frozenEmailInstanceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"senderProfileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from": {
"email": "jsmith@example.com",
"name": "<string>"
},
"replyTo": {
"email": "jsmith@example.com",
"name": "<string>"
},
"subject": "<string>",
"subscriptionGroupId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"profileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": {
"email": "jsmith@example.com"
},
"cc": [
{
"email": "jsmith@example.com",
"name": "<string>"
}
],
"messageId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"skippedReason": "ProfileErased",
"failureReason": "WorkerFailed",
"failureMessage": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}{
"errorCode": "RATE_LIMITED",
"message": "Rate limit exceeded. Retry after 12 seconds.",
"details": {
"retryAfterSeconds": 12
}
}{
"errorCode": "TEMPLATE_NAME_EXISTS",
"message": "Template name 'Hello' already exists in this organization.",
"details": {
"issues": [
{
"path": "name",
"code": "duplicate",
"message": "Template name already exists in this organization."
}
]
}
}Headers
Body
Advanced fallback saved Email Template id to snapshot and render. Prefer templateKey for SDK integrations.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Purpose for rendered content. Required for rendered content. transactional sends do not receive a marketing footer; marketing and newsletter sends receive Segmentflow compliance automatically. Saved template sends continue to use the saved Template purpose.
transactional, marketing, newsletter Optional primary recipient Profile id. When to.email is absent, the Profile canonical email is used for delivery.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Optional sender override. Accepts a bare email or "Name email@example.com" and must match a verified SenderProfile email.
1 - 320Optional reply-to override. Accepts a single bare email or "Name email@example.com" and must use a verified sender domain owned by the organization.
1 - 320SubscriptionGroup gate. Required for marketing-class Email Template purposes; if supplied, the send is skipped when the recipient is not subscribed according to the group's OptIn/OptOut policy.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Response
Default Response
Source saved Template id. Null when the send was created from rendered JSX Email content.
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
