Send emails
curl --request POST \
--url https://api.ahasend.com/v1/email/send \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"from": {
"email": "john@nasa.gov",
"name": "John Smith"
},
"recipients": [
{
"email": "john@nasa.gov",
"name": "John Smith"
}
],
"content": {
"subject": "Sample subject",
"text_body": "Sample email body",
"html_body": "<p>Sample email body</p>",
"attachments": [
{
"data": "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"content_type": "image/gif",
"file_name": "my_image.gif",
"base64": true,
"content_id": "my-image"
}
],
"headers": {
"X-My-Mail-ID": "12345",
"X-Comment-ID": "456789"
}
}
}
'import requests
url = "https://api.ahasend.com/v1/email/send"
payload = {
"from": {
"email": "john@nasa.gov",
"name": "John Smith"
},
"recipients": [
{
"email": "john@nasa.gov",
"name": "John Smith"
}
],
"content": {
"subject": "Sample subject",
"text_body": "Sample email body",
"html_body": "<p>Sample email body</p>",
"attachments": [
{
"data": "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"content_type": "image/gif",
"file_name": "my_image.gif",
"base64": True,
"content_id": "my-image"
}
],
"headers": {
"X-My-Mail-ID": "12345",
"X-Comment-ID": "456789"
}
}
}
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({
from: {email: 'john@nasa.gov', name: 'John Smith'},
recipients: [{email: 'john@nasa.gov', name: 'John Smith'}],
content: {
subject: 'Sample subject',
text_body: 'Sample email body',
html_body: '<p>Sample email body</p>',
attachments: [
{
data: 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
content_type: 'image/gif',
file_name: 'my_image.gif',
base64: true,
content_id: 'my-image'
}
],
headers: {'X-My-Mail-ID': '12345', 'X-Comment-ID': '456789'}
}
})
};
fetch('https://api.ahasend.com/v1/email/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://api.ahasend.com/v1/email/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([
'from' => [
'email' => 'john@nasa.gov',
'name' => 'John Smith'
],
'recipients' => [
[
'email' => 'john@nasa.gov',
'name' => 'John Smith'
]
],
'content' => [
'subject' => 'Sample subject',
'text_body' => 'Sample email body',
'html_body' => '<p>Sample email body</p>',
'attachments' => [
[
'data' => 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
'content_type' => 'image/gif',
'file_name' => 'my_image.gif',
'base64' => true,
'content_id' => 'my-image'
]
],
'headers' => [
'X-My-Mail-ID' => '12345',
'X-Comment-ID' => '456789'
]
]
]),
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.ahasend.com/v1/email/send"
payload := strings.NewReader("{\n \"from\": {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n },\n \"recipients\": [\n {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n }\n ],\n \"content\": {\n \"subject\": \"Sample subject\",\n \"text_body\": \"Sample email body\",\n \"html_body\": \"<p>Sample email body</p>\",\n \"attachments\": [\n {\n \"data\": \"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\",\n \"content_type\": \"image/gif\",\n \"file_name\": \"my_image.gif\",\n \"base64\": true,\n \"content_id\": \"my-image\"\n }\n ],\n \"headers\": {\n \"X-My-Mail-ID\": \"12345\",\n \"X-Comment-ID\": \"456789\"\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.ahasend.com/v1/email/send")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"from\": {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n },\n \"recipients\": [\n {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n }\n ],\n \"content\": {\n \"subject\": \"Sample subject\",\n \"text_body\": \"Sample email body\",\n \"html_body\": \"<p>Sample email body</p>\",\n \"attachments\": [\n {\n \"data\": \"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\",\n \"content_type\": \"image/gif\",\n \"file_name\": \"my_image.gif\",\n \"base64\": true,\n \"content_id\": \"my-image\"\n }\n ],\n \"headers\": {\n \"X-My-Mail-ID\": \"12345\",\n \"X-Comment-ID\": \"456789\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v1/email/send")
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 \"from\": {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n },\n \"recipients\": [\n {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n }\n ],\n \"content\": {\n \"subject\": \"Sample subject\",\n \"text_body\": \"Sample email body\",\n \"html_body\": \"<p>Sample email body</p>\",\n \"attachments\": [\n {\n \"data\": \"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\",\n \"content_type\": \"image/gif\",\n \"file_name\": \"my_image.gif\",\n \"base64\": true,\n \"content_id\": \"my-image\"\n }\n ],\n \"headers\": {\n \"X-My-Mail-ID\": \"12345\",\n \"X-Comment-ID\": \"456789\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"success_count": 1,
"fail_count": 1,
"failed_recipients": [
"john@nasa.gov"
],
"errors": [
"john@nasa.gov: The email account that you tried to reach does not exist."
]
}{
"status": "bad request"
}{
"status": "invalid credentials"
}API v1 (legacy)
Send Email with API v1 (Legacy)
Reference for the legacy AhaSend API v1 POST /v1/email/send endpoint using the X-Api-Key header. API v1 is in maintenance mode; use API v2 for new integrations.
POST
/
v1
/
email
/
send
Send emails
curl --request POST \
--url https://api.ahasend.com/v1/email/send \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"from": {
"email": "john@nasa.gov",
"name": "John Smith"
},
"recipients": [
{
"email": "john@nasa.gov",
"name": "John Smith"
}
],
"content": {
"subject": "Sample subject",
"text_body": "Sample email body",
"html_body": "<p>Sample email body</p>",
"attachments": [
{
"data": "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"content_type": "image/gif",
"file_name": "my_image.gif",
"base64": true,
"content_id": "my-image"
}
],
"headers": {
"X-My-Mail-ID": "12345",
"X-Comment-ID": "456789"
}
}
}
'import requests
url = "https://api.ahasend.com/v1/email/send"
payload = {
"from": {
"email": "john@nasa.gov",
"name": "John Smith"
},
"recipients": [
{
"email": "john@nasa.gov",
"name": "John Smith"
}
],
"content": {
"subject": "Sample subject",
"text_body": "Sample email body",
"html_body": "<p>Sample email body</p>",
"attachments": [
{
"data": "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"content_type": "image/gif",
"file_name": "my_image.gif",
"base64": True,
"content_id": "my-image"
}
],
"headers": {
"X-My-Mail-ID": "12345",
"X-Comment-ID": "456789"
}
}
}
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({
from: {email: 'john@nasa.gov', name: 'John Smith'},
recipients: [{email: 'john@nasa.gov', name: 'John Smith'}],
content: {
subject: 'Sample subject',
text_body: 'Sample email body',
html_body: '<p>Sample email body</p>',
attachments: [
{
data: 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
content_type: 'image/gif',
file_name: 'my_image.gif',
base64: true,
content_id: 'my-image'
}
],
headers: {'X-My-Mail-ID': '12345', 'X-Comment-ID': '456789'}
}
})
};
fetch('https://api.ahasend.com/v1/email/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://api.ahasend.com/v1/email/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([
'from' => [
'email' => 'john@nasa.gov',
'name' => 'John Smith'
],
'recipients' => [
[
'email' => 'john@nasa.gov',
'name' => 'John Smith'
]
],
'content' => [
'subject' => 'Sample subject',
'text_body' => 'Sample email body',
'html_body' => '<p>Sample email body</p>',
'attachments' => [
[
'data' => 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
'content_type' => 'image/gif',
'file_name' => 'my_image.gif',
'base64' => true,
'content_id' => 'my-image'
]
],
'headers' => [
'X-My-Mail-ID' => '12345',
'X-Comment-ID' => '456789'
]
]
]),
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.ahasend.com/v1/email/send"
payload := strings.NewReader("{\n \"from\": {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n },\n \"recipients\": [\n {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n }\n ],\n \"content\": {\n \"subject\": \"Sample subject\",\n \"text_body\": \"Sample email body\",\n \"html_body\": \"<p>Sample email body</p>\",\n \"attachments\": [\n {\n \"data\": \"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\",\n \"content_type\": \"image/gif\",\n \"file_name\": \"my_image.gif\",\n \"base64\": true,\n \"content_id\": \"my-image\"\n }\n ],\n \"headers\": {\n \"X-My-Mail-ID\": \"12345\",\n \"X-Comment-ID\": \"456789\"\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.ahasend.com/v1/email/send")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"from\": {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n },\n \"recipients\": [\n {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n }\n ],\n \"content\": {\n \"subject\": \"Sample subject\",\n \"text_body\": \"Sample email body\",\n \"html_body\": \"<p>Sample email body</p>\",\n \"attachments\": [\n {\n \"data\": \"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\",\n \"content_type\": \"image/gif\",\n \"file_name\": \"my_image.gif\",\n \"base64\": true,\n \"content_id\": \"my-image\"\n }\n ],\n \"headers\": {\n \"X-My-Mail-ID\": \"12345\",\n \"X-Comment-ID\": \"456789\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v1/email/send")
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 \"from\": {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n },\n \"recipients\": [\n {\n \"email\": \"john@nasa.gov\",\n \"name\": \"John Smith\"\n }\n ],\n \"content\": {\n \"subject\": \"Sample subject\",\n \"text_body\": \"Sample email body\",\n \"html_body\": \"<p>Sample email body</p>\",\n \"attachments\": [\n {\n \"data\": \"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\",\n \"content_type\": \"image/gif\",\n \"file_name\": \"my_image.gif\",\n \"base64\": true,\n \"content_id\": \"my-image\"\n }\n ],\n \"headers\": {\n \"X-My-Mail-ID\": \"12345\",\n \"X-Comment-ID\": \"456789\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"success_count": 1,
"fail_count": 1,
"failed_recipients": [
"john@nasa.gov"
],
"errors": [
"john@nasa.gov: The email account that you tried to reach does not exist."
]
}{
"status": "bad request"
}{
"status": "invalid credentials"
}The AhaSend legacy v1 API sends email to up to 100 recipients per request; this reference documents the existing v1 request format.
API v1 provides a simple way to send emails through AhaSend. It’s designed for straightforward email sending without the advanced features available in v2.
API v1 is in maintenance mode. We recommend using API v2 for new integrations as it offers better features, error handling, and will receive ongoing updates.
Get your API key from the Credentials page in your AhaSend dashboard.
Related Guides
- API authentication, Permission scopes, Send-only API keys.
- REST sending guide, SMTP settings, CLI quickstart.
- Node.js SDK, Go SDK, API errors.
- API rate limits.
Authorizations
Headers
Only application/json is supported
Body
application/json
Email object.
Response
Request was accepted. This doesn't necessarily mean immediate delivery or even queueing of the emails for delivery. It just means that the request was well-formed and accepted, but you need to check the response for success_count and fail_count to make sure about the status of your request.
Number of messages that were queued for sending.
Example:
1
Number of messages that failed to be queued for sending.
Example:
1
List of email addresses that the email was not sent to.
Example:
["john@nasa.gov"]
The reason the email failed to be sent to a recipient.
Example:
[
"john@nasa.gov: The email account that you tried to reach does not exist."
]

