curl --request POST \
--url https://webhook.cocoonmail.com/webhook/mail/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email_content": "<string>",
"sender": "<string>",
"subject": "<string>",
"to": [
{
"email": "jsmith@example.com",
"first_name": "<string>",
"last_name": "<string>",
"name": "<string>"
}
]
}
'import requests
url = "https://webhook.cocoonmail.com/webhook/mail/send"
payload = {
"email_content": "<string>",
"sender": "<string>",
"subject": "<string>",
"to": [
{
"email": "jsmith@example.com",
"first_name": "<string>",
"last_name": "<string>",
"name": "<string>"
}
]
}
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({
email_content: '<string>',
sender: '<string>',
subject: '<string>',
to: [
{
email: 'jsmith@example.com',
first_name: '<string>',
last_name: '<string>',
name: '<string>'
}
]
})
};
fetch('https://webhook.cocoonmail.com/webhook/mail/send', 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://webhook.cocoonmail.com/webhook/mail/send",
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([
'email_content' => '<string>',
'sender' => '<string>',
'subject' => '<string>',
'to' => [
[
'email' => 'jsmith@example.com',
'first_name' => '<string>',
'last_name' => '<string>',
'name' => '<string>'
]
]
]),
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://webhook.cocoonmail.com/webhook/mail/send"
payload := strings.NewReader("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\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://webhook.cocoonmail.com/webhook/mail/send")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://webhook.cocoonmail.com/webhook/mail/send")
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 \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/mail/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);using RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/mail/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);{
"success": true,
"failed_recipients": [],
"report": [
{
"to": "email_address",
"message_id": "unique_id"
},
{
"to": "email_address",
"message_id": "unique_id"
},
],
"quotas": {
"MAX_SEND_MAIL_PER_DAY": {
"limit": "usage",
"usage": "usage"
},
"MAX_SEND_MAIL_PER_MONTH_TRANSACTIONAL": {
"limit": "usage",
"usage": "usage"
}
},
"sender": "email_address",
"message": "Transactional mails sent successfully"
}
{
"message": "Bad request"
}
{
"success":false,
"message":"Contact not found"
}
{
"detail": "Authentication credentials were not provided."
}
Send mail
curl --request POST \
--url https://webhook.cocoonmail.com/webhook/mail/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email_content": "<string>",
"sender": "<string>",
"subject": "<string>",
"to": [
{
"email": "jsmith@example.com",
"first_name": "<string>",
"last_name": "<string>",
"name": "<string>"
}
]
}
'import requests
url = "https://webhook.cocoonmail.com/webhook/mail/send"
payload = {
"email_content": "<string>",
"sender": "<string>",
"subject": "<string>",
"to": [
{
"email": "jsmith@example.com",
"first_name": "<string>",
"last_name": "<string>",
"name": "<string>"
}
]
}
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({
email_content: '<string>',
sender: '<string>',
subject: '<string>',
to: [
{
email: 'jsmith@example.com',
first_name: '<string>',
last_name: '<string>',
name: '<string>'
}
]
})
};
fetch('https://webhook.cocoonmail.com/webhook/mail/send', 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://webhook.cocoonmail.com/webhook/mail/send",
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([
'email_content' => '<string>',
'sender' => '<string>',
'subject' => '<string>',
'to' => [
[
'email' => 'jsmith@example.com',
'first_name' => '<string>',
'last_name' => '<string>',
'name' => '<string>'
]
]
]),
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://webhook.cocoonmail.com/webhook/mail/send"
payload := strings.NewReader("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\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://webhook.cocoonmail.com/webhook/mail/send")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://webhook.cocoonmail.com/webhook/mail/send")
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 \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/mail/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);using RestSharp;
var options = new RestClientOptions("https://webhook.cocoonmail.com/webhook/mail/send");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"email_content\": \"<string>\",\n \"sender\": \"<string>\",\n \"subject\": \"<string>\",\n \"to\": [\n {\n \"email\": \"jsmith@example.com\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"name\": \"<string>\"\n }\n ]\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);{
"success": true,
"failed_recipients": [],
"report": [
{
"to": "email_address",
"message_id": "unique_id"
},
{
"to": "email_address",
"message_id": "unique_id"
},
],
"quotas": {
"MAX_SEND_MAIL_PER_DAY": {
"limit": "usage",
"usage": "usage"
},
"MAX_SEND_MAIL_PER_MONTH_TRANSACTIONAL": {
"limit": "usage",
"usage": "usage"
}
},
"sender": "email_address",
"message": "Transactional mails sent successfully"
}
{
"message": "Bad request"
}
{
"success":false,
"message":"Contact not found"
}
{
"detail": "Authentication credentials were not provided."
}
Send transactional mail
Use this endpoint to send transactional email.Request Body
email_content: (Required) The rich HTML or text content of the email.sender: (Required) Email address of the sender.subject: (Required) Subject line of the email.to: (Required) An array of recipient contact objects.
Example Payload
{
"email_content": "<h1>Hello John,</h1><p>Welcome to our service!</p>",
"sender": "sender@example.com",
"subject": "Hello from us",
"to": [
{
"email": "recipient@example.com",
"first_name": "John"
}
],
"tags": ["tag1"]
}
Response fields
| Property | Description |
|---|---|
| 201 | Transactional mails sent successfully |
| 400 | Bad request |
| 401 | Request authentication |
| 403 | Too many bad requests. Temparory block |
| 406 | Missing accept header. For example : Accept: application/json |
| 429 | Too many requests/ Rate limit exceeded |
| 500 | Internal server error |
{
"success": true,
"failed_recipients": [],
"report": [
{
"to": "email_address",
"message_id": "unique_id"
},
{
"to": "email_address",
"message_id": "unique_id"
},
],
"quotas": {
"MAX_SEND_MAIL_PER_DAY": {
"limit": "usage",
"usage": "usage"
},
"MAX_SEND_MAIL_PER_MONTH_TRANSACTIONAL": {
"limit": "usage",
"usage": "usage"
}
},
"sender": "email_address",
"message": "Transactional mails sent successfully"
}
{
"message": "Bad request"
}
{
"success":false,
"message":"Contact not found"
}
{
"detail": "Authentication credentials were not provided."
}
Authorizations
Use your API key with the 'Bearer ' prefix
Body
Email content
From email address
Email subject
Array of recipient objects.
Show child attributes
Show child attributes
Valid email address.
Object containing key-value pairs to replace merge tags in the email template
Show child attributes
Show child attributes
Attachment
Show child attributes
Show child attributes
Remote attachments
Show child attributes
Show child attributes
Add recipient to contact
Date and time when the email should be sent (ISO 8601 format)
Enable tracking of link clicks within the email.
Enable tracking of email opens using tracking pixels.
Send emails even to addresses that previously bounced.
Send emails to recipients even if they have unsubscribed.
Enable view in browser
Include unsubscribe link in the email footer
Email address of the CC recipient.
Array of strings to tag the message with.