curl --request POST \
--url https://console.sendlayer.com/api/v1/email \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"From": {
"name": "Paulie Paloma",
"email": "paulie@example.com"
},
"To": [
{
"name": "Pattie Paloma",
"email": "pattie@exampledomain.com"
}
],
"Subject": "This is the email subject",
"ContentType": "HTML",
"HTMLContent": "<html><body><p>This is a test email sent with the <a href=\\\"https://sendlayer.com\\\">SendLayer</a> API!</p></body></html>",
"CC": [
{
"name": "Pattie Paloma CC",
"email": "pattie.cc@exampledomain.com"
}
],
"BCC": [
{
"name": "Pattie Paloma BCC",
"email": "pattie.bcc@exampledomain.com"
}
],
"ReplyTo": [
{
"name": "Pattie Paloma ReplyTo",
"email": "pattie.reply@exampledomain.com"
}
],
"Tags": [
"newsletter, daily"
],
"Headers": {
"X-Mailer": "test mailer",
"X-Test": "test header"
},
"Attachments": [
{
"Content": "BASE 64 ENCODED STRING",
"Type": "image/png",
"Filename": "test.png",
"Disposition": "attachment",
"ContentId": 0
}
]
}
'import requests
url = "https://console.sendlayer.com/api/v1/email"
payload = {
"From": {
"name": "Paulie Paloma",
"email": "paulie@example.com"
},
"To": [
{
"name": "Pattie Paloma",
"email": "pattie@exampledomain.com"
}
],
"Subject": "This is the email subject",
"ContentType": "HTML",
"HTMLContent": "<html><body><p>This is a test email sent with the <a href=\\"https://sendlayer.com\\">SendLayer</a> API!</p></body></html>",
"CC": [
{
"name": "Pattie Paloma CC",
"email": "pattie.cc@exampledomain.com"
}
],
"BCC": [
{
"name": "Pattie Paloma BCC",
"email": "pattie.bcc@exampledomain.com"
}
],
"ReplyTo": [
{
"name": "Pattie Paloma ReplyTo",
"email": "pattie.reply@exampledomain.com"
}
],
"Tags": ["newsletter, daily"],
"Headers": {
"X-Mailer": "test mailer",
"X-Test": "test header"
},
"Attachments": [
{
"Content": "BASE 64 ENCODED STRING",
"Type": "image/png",
"Filename": "test.png",
"Disposition": "attachment",
"ContentId": 0
}
]
}
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({
From: {name: 'Paulie Paloma', email: 'paulie@example.com'},
To: [{name: 'Pattie Paloma', email: 'pattie@exampledomain.com'}],
Subject: 'This is the email subject',
ContentType: 'HTML',
HTMLContent: '<html><body><p>This is a test email sent with the <a href=\"https://sendlayer.com\">SendLayer</a> API!</p></body></html>',
CC: [{name: 'Pattie Paloma CC', email: 'pattie.cc@exampledomain.com'}],
BCC: [{name: 'Pattie Paloma BCC', email: 'pattie.bcc@exampledomain.com'}],
ReplyTo: [{name: 'Pattie Paloma ReplyTo', email: 'pattie.reply@exampledomain.com'}],
Tags: ['newsletter, daily'],
Headers: {'X-Mailer': 'test mailer', 'X-Test': 'test header'},
Attachments: [
{
Content: 'BASE 64 ENCODED STRING',
Type: 'image/png',
Filename: 'test.png',
Disposition: 'attachment',
ContentId: 0
}
]
})
};
fetch('https://console.sendlayer.com/api/v1/email', 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://console.sendlayer.com/api/v1/email",
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([
'From' => [
'name' => 'Paulie Paloma',
'email' => 'paulie@example.com'
],
'To' => [
[
'name' => 'Pattie Paloma',
'email' => 'pattie@exampledomain.com'
]
],
'Subject' => 'This is the email subject',
'ContentType' => 'HTML',
'HTMLContent' => '<html><body><p>This is a test email sent with the <a href=\\"https://sendlayer.com\\">SendLayer</a> API!</p></body></html>',
'CC' => [
[
'name' => 'Pattie Paloma CC',
'email' => 'pattie.cc@exampledomain.com'
]
],
'BCC' => [
[
'name' => 'Pattie Paloma BCC',
'email' => 'pattie.bcc@exampledomain.com'
]
],
'ReplyTo' => [
[
'name' => 'Pattie Paloma ReplyTo',
'email' => 'pattie.reply@exampledomain.com'
]
],
'Tags' => [
'newsletter, daily'
],
'Headers' => [
'X-Mailer' => 'test mailer',
'X-Test' => 'test header'
],
'Attachments' => [
[
'Content' => 'BASE 64 ENCODED STRING',
'Type' => 'image/png',
'Filename' => 'test.png',
'Disposition' => 'attachment',
'ContentId' => 0
]
]
]),
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://console.sendlayer.com/api/v1/email"
payload := strings.NewReader("{\n \"From\": {\n \"name\": \"Paulie Paloma\",\n \"email\": \"paulie@example.com\"\n },\n \"To\": [\n {\n \"name\": \"Pattie Paloma\",\n \"email\": \"pattie@exampledomain.com\"\n }\n ],\n \"Subject\": \"This is the email subject\",\n \"ContentType\": \"HTML\",\n \"HTMLContent\": \"<html><body><p>This is a test email sent with the <a href=\\\\\\\"https://sendlayer.com\\\\\\\">SendLayer</a> API!</p></body></html>\",\n \"CC\": [\n {\n \"name\": \"Pattie Paloma CC\",\n \"email\": \"pattie.cc@exampledomain.com\"\n }\n ],\n \"BCC\": [\n {\n \"name\": \"Pattie Paloma BCC\",\n \"email\": \"pattie.bcc@exampledomain.com\"\n }\n ],\n \"ReplyTo\": [\n {\n \"name\": \"Pattie Paloma ReplyTo\",\n \"email\": \"pattie.reply@exampledomain.com\"\n }\n ],\n \"Tags\": [\n \"newsletter, daily\"\n ],\n \"Headers\": {\n \"X-Mailer\": \"test mailer\",\n \"X-Test\": \"test header\"\n },\n \"Attachments\": [\n {\n \"Content\": \"BASE 64 ENCODED STRING\",\n \"Type\": \"image/png\",\n \"Filename\": \"test.png\",\n \"Disposition\": \"attachment\",\n \"ContentId\": 0\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://console.sendlayer.com/api/v1/email")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"From\": {\n \"name\": \"Paulie Paloma\",\n \"email\": \"paulie@example.com\"\n },\n \"To\": [\n {\n \"name\": \"Pattie Paloma\",\n \"email\": \"pattie@exampledomain.com\"\n }\n ],\n \"Subject\": \"This is the email subject\",\n \"ContentType\": \"HTML\",\n \"HTMLContent\": \"<html><body><p>This is a test email sent with the <a href=\\\\\\\"https://sendlayer.com\\\\\\\">SendLayer</a> API!</p></body></html>\",\n \"CC\": [\n {\n \"name\": \"Pattie Paloma CC\",\n \"email\": \"pattie.cc@exampledomain.com\"\n }\n ],\n \"BCC\": [\n {\n \"name\": \"Pattie Paloma BCC\",\n \"email\": \"pattie.bcc@exampledomain.com\"\n }\n ],\n \"ReplyTo\": [\n {\n \"name\": \"Pattie Paloma ReplyTo\",\n \"email\": \"pattie.reply@exampledomain.com\"\n }\n ],\n \"Tags\": [\n \"newsletter, daily\"\n ],\n \"Headers\": {\n \"X-Mailer\": \"test mailer\",\n \"X-Test\": \"test header\"\n },\n \"Attachments\": [\n {\n \"Content\": \"BASE 64 ENCODED STRING\",\n \"Type\": \"image/png\",\n \"Filename\": \"test.png\",\n \"Disposition\": \"attachment\",\n \"ContentId\": 0\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.sendlayer.com/api/v1/email")
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 \"From\": {\n \"name\": \"Paulie Paloma\",\n \"email\": \"paulie@example.com\"\n },\n \"To\": [\n {\n \"name\": \"Pattie Paloma\",\n \"email\": \"pattie@exampledomain.com\"\n }\n ],\n \"Subject\": \"This is the email subject\",\n \"ContentType\": \"HTML\",\n \"HTMLContent\": \"<html><body><p>This is a test email sent with the <a href=\\\\\\\"https://sendlayer.com\\\\\\\">SendLayer</a> API!</p></body></html>\",\n \"CC\": [\n {\n \"name\": \"Pattie Paloma CC\",\n \"email\": \"pattie.cc@exampledomain.com\"\n }\n ],\n \"BCC\": [\n {\n \"name\": \"Pattie Paloma BCC\",\n \"email\": \"pattie.bcc@exampledomain.com\"\n }\n ],\n \"ReplyTo\": [\n {\n \"name\": \"Pattie Paloma ReplyTo\",\n \"email\": \"pattie.reply@exampledomain.com\"\n }\n ],\n \"Tags\": [\n \"newsletter, daily\"\n ],\n \"Headers\": {\n \"X-Mailer\": \"test mailer\",\n \"X-Test\": \"test header\"\n },\n \"Attachments\": [\n {\n \"Content\": \"BASE 64 ENCODED STRING\",\n \"Type\": \"image/png\",\n \"Filename\": \"test.png\",\n \"Disposition\": \"attachment\",\n \"ContentId\": 0\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"MessageID": "8912e59e-ec88-bcd6-45dd-0012fe223ab6"
}Send Email
curl --request POST \
--url https://console.sendlayer.com/api/v1/email \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"From": {
"name": "Paulie Paloma",
"email": "paulie@example.com"
},
"To": [
{
"name": "Pattie Paloma",
"email": "pattie@exampledomain.com"
}
],
"Subject": "This is the email subject",
"ContentType": "HTML",
"HTMLContent": "<html><body><p>This is a test email sent with the <a href=\\\"https://sendlayer.com\\\">SendLayer</a> API!</p></body></html>",
"CC": [
{
"name": "Pattie Paloma CC",
"email": "pattie.cc@exampledomain.com"
}
],
"BCC": [
{
"name": "Pattie Paloma BCC",
"email": "pattie.bcc@exampledomain.com"
}
],
"ReplyTo": [
{
"name": "Pattie Paloma ReplyTo",
"email": "pattie.reply@exampledomain.com"
}
],
"Tags": [
"newsletter, daily"
],
"Headers": {
"X-Mailer": "test mailer",
"X-Test": "test header"
},
"Attachments": [
{
"Content": "BASE 64 ENCODED STRING",
"Type": "image/png",
"Filename": "test.png",
"Disposition": "attachment",
"ContentId": 0
}
]
}
'import requests
url = "https://console.sendlayer.com/api/v1/email"
payload = {
"From": {
"name": "Paulie Paloma",
"email": "paulie@example.com"
},
"To": [
{
"name": "Pattie Paloma",
"email": "pattie@exampledomain.com"
}
],
"Subject": "This is the email subject",
"ContentType": "HTML",
"HTMLContent": "<html><body><p>This is a test email sent with the <a href=\\"https://sendlayer.com\\">SendLayer</a> API!</p></body></html>",
"CC": [
{
"name": "Pattie Paloma CC",
"email": "pattie.cc@exampledomain.com"
}
],
"BCC": [
{
"name": "Pattie Paloma BCC",
"email": "pattie.bcc@exampledomain.com"
}
],
"ReplyTo": [
{
"name": "Pattie Paloma ReplyTo",
"email": "pattie.reply@exampledomain.com"
}
],
"Tags": ["newsletter, daily"],
"Headers": {
"X-Mailer": "test mailer",
"X-Test": "test header"
},
"Attachments": [
{
"Content": "BASE 64 ENCODED STRING",
"Type": "image/png",
"Filename": "test.png",
"Disposition": "attachment",
"ContentId": 0
}
]
}
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({
From: {name: 'Paulie Paloma', email: 'paulie@example.com'},
To: [{name: 'Pattie Paloma', email: 'pattie@exampledomain.com'}],
Subject: 'This is the email subject',
ContentType: 'HTML',
HTMLContent: '<html><body><p>This is a test email sent with the <a href=\"https://sendlayer.com\">SendLayer</a> API!</p></body></html>',
CC: [{name: 'Pattie Paloma CC', email: 'pattie.cc@exampledomain.com'}],
BCC: [{name: 'Pattie Paloma BCC', email: 'pattie.bcc@exampledomain.com'}],
ReplyTo: [{name: 'Pattie Paloma ReplyTo', email: 'pattie.reply@exampledomain.com'}],
Tags: ['newsletter, daily'],
Headers: {'X-Mailer': 'test mailer', 'X-Test': 'test header'},
Attachments: [
{
Content: 'BASE 64 ENCODED STRING',
Type: 'image/png',
Filename: 'test.png',
Disposition: 'attachment',
ContentId: 0
}
]
})
};
fetch('https://console.sendlayer.com/api/v1/email', 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://console.sendlayer.com/api/v1/email",
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([
'From' => [
'name' => 'Paulie Paloma',
'email' => 'paulie@example.com'
],
'To' => [
[
'name' => 'Pattie Paloma',
'email' => 'pattie@exampledomain.com'
]
],
'Subject' => 'This is the email subject',
'ContentType' => 'HTML',
'HTMLContent' => '<html><body><p>This is a test email sent with the <a href=\\"https://sendlayer.com\\">SendLayer</a> API!</p></body></html>',
'CC' => [
[
'name' => 'Pattie Paloma CC',
'email' => 'pattie.cc@exampledomain.com'
]
],
'BCC' => [
[
'name' => 'Pattie Paloma BCC',
'email' => 'pattie.bcc@exampledomain.com'
]
],
'ReplyTo' => [
[
'name' => 'Pattie Paloma ReplyTo',
'email' => 'pattie.reply@exampledomain.com'
]
],
'Tags' => [
'newsletter, daily'
],
'Headers' => [
'X-Mailer' => 'test mailer',
'X-Test' => 'test header'
],
'Attachments' => [
[
'Content' => 'BASE 64 ENCODED STRING',
'Type' => 'image/png',
'Filename' => 'test.png',
'Disposition' => 'attachment',
'ContentId' => 0
]
]
]),
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://console.sendlayer.com/api/v1/email"
payload := strings.NewReader("{\n \"From\": {\n \"name\": \"Paulie Paloma\",\n \"email\": \"paulie@example.com\"\n },\n \"To\": [\n {\n \"name\": \"Pattie Paloma\",\n \"email\": \"pattie@exampledomain.com\"\n }\n ],\n \"Subject\": \"This is the email subject\",\n \"ContentType\": \"HTML\",\n \"HTMLContent\": \"<html><body><p>This is a test email sent with the <a href=\\\\\\\"https://sendlayer.com\\\\\\\">SendLayer</a> API!</p></body></html>\",\n \"CC\": [\n {\n \"name\": \"Pattie Paloma CC\",\n \"email\": \"pattie.cc@exampledomain.com\"\n }\n ],\n \"BCC\": [\n {\n \"name\": \"Pattie Paloma BCC\",\n \"email\": \"pattie.bcc@exampledomain.com\"\n }\n ],\n \"ReplyTo\": [\n {\n \"name\": \"Pattie Paloma ReplyTo\",\n \"email\": \"pattie.reply@exampledomain.com\"\n }\n ],\n \"Tags\": [\n \"newsletter, daily\"\n ],\n \"Headers\": {\n \"X-Mailer\": \"test mailer\",\n \"X-Test\": \"test header\"\n },\n \"Attachments\": [\n {\n \"Content\": \"BASE 64 ENCODED STRING\",\n \"Type\": \"image/png\",\n \"Filename\": \"test.png\",\n \"Disposition\": \"attachment\",\n \"ContentId\": 0\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://console.sendlayer.com/api/v1/email")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"From\": {\n \"name\": \"Paulie Paloma\",\n \"email\": \"paulie@example.com\"\n },\n \"To\": [\n {\n \"name\": \"Pattie Paloma\",\n \"email\": \"pattie@exampledomain.com\"\n }\n ],\n \"Subject\": \"This is the email subject\",\n \"ContentType\": \"HTML\",\n \"HTMLContent\": \"<html><body><p>This is a test email sent with the <a href=\\\\\\\"https://sendlayer.com\\\\\\\">SendLayer</a> API!</p></body></html>\",\n \"CC\": [\n {\n \"name\": \"Pattie Paloma CC\",\n \"email\": \"pattie.cc@exampledomain.com\"\n }\n ],\n \"BCC\": [\n {\n \"name\": \"Pattie Paloma BCC\",\n \"email\": \"pattie.bcc@exampledomain.com\"\n }\n ],\n \"ReplyTo\": [\n {\n \"name\": \"Pattie Paloma ReplyTo\",\n \"email\": \"pattie.reply@exampledomain.com\"\n }\n ],\n \"Tags\": [\n \"newsletter, daily\"\n ],\n \"Headers\": {\n \"X-Mailer\": \"test mailer\",\n \"X-Test\": \"test header\"\n },\n \"Attachments\": [\n {\n \"Content\": \"BASE 64 ENCODED STRING\",\n \"Type\": \"image/png\",\n \"Filename\": \"test.png\",\n \"Disposition\": \"attachment\",\n \"ContentId\": 0\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.sendlayer.com/api/v1/email")
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 \"From\": {\n \"name\": \"Paulie Paloma\",\n \"email\": \"paulie@example.com\"\n },\n \"To\": [\n {\n \"name\": \"Pattie Paloma\",\n \"email\": \"pattie@exampledomain.com\"\n }\n ],\n \"Subject\": \"This is the email subject\",\n \"ContentType\": \"HTML\",\n \"HTMLContent\": \"<html><body><p>This is a test email sent with the <a href=\\\\\\\"https://sendlayer.com\\\\\\\">SendLayer</a> API!</p></body></html>\",\n \"CC\": [\n {\n \"name\": \"Pattie Paloma CC\",\n \"email\": \"pattie.cc@exampledomain.com\"\n }\n ],\n \"BCC\": [\n {\n \"name\": \"Pattie Paloma BCC\",\n \"email\": \"pattie.bcc@exampledomain.com\"\n }\n ],\n \"ReplyTo\": [\n {\n \"name\": \"Pattie Paloma ReplyTo\",\n \"email\": \"pattie.reply@exampledomain.com\"\n }\n ],\n \"Tags\": [\n \"newsletter, daily\"\n ],\n \"Headers\": {\n \"X-Mailer\": \"test mailer\",\n \"X-Test\": \"test header\"\n },\n \"Attachments\": [\n {\n \"Content\": \"BASE 64 ENCODED STRING\",\n \"Type\": \"image/png\",\n \"Filename\": \"test.png\",\n \"Disposition\": \"attachment\",\n \"ContentId\": 0\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"MessageID": "8912e59e-ec88-bcd6-45dd-0012fe223ab6"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Below is the JSON payload required for sending a single email. Be sure to replace the example email addresses with valid email addresses in the From and To objects.
Note: The From email address must contain your sender domain, which is the domain that you’ve verified in SendLayer. For example, if you’ve authorized example.com you’ll need to use your-email@example.com.
Additionally, you can send emails to multiple recipients by adding more objects to the To, CC,and BCC arrays within the specified limits. See our Getting Started guide for more details.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
"This is the email subject"
"HTML"
"<html><body><p>This is a test email sent with the <a href=\\\"https://sendlayer.com\\\">SendLayer</a> API!</p></body></html>"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
OK
A successfully delivered email returns the MessageID
A successfully delivered email returns the MessageID
"8912e59e-ec88-bcd6-45dd-0012fe223ab6"
Was this page helpful?