Email API
Sending Emails
Email API
Sending Emails
Send emails programmatically through the A1Mail API with just a few lines of code
Request Parameters
The following parameters are used when sending an email:
Parameter | Type | Required | Description |
---|---|---|---|
sender_address | string | Yes | Email address that will appear in the “From” field |
recipient_address | string | Yes | Email address of the recipient |
subject | string | Yes | Subject line of the email |
body | string | Yes | Content of the email (plain text or HTML) |
headers | object | No | Optional email headers as key-value pairs (cc, bcc, etc.) |
Code Examples
Send a Simple Text Email
curl --location 'https://api.a1base.com/v1/emails/{account_id}/send' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-API-Secret: YOUR_API_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"sender_address": "[email protected]",
"recipient_address": "[email protected]",
"subject": "Hello from A1Base",
"body": "This is an example email body.",
"headers": {}
}'
Send an HTML Email
curl --location 'https://api.a1base.com/v1/emails/{account_id}/send' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-API-Secret: YOUR_API_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"sender_address": "[email protected]",
"recipient_address": "[email protected]",
"subject": "Hello from A1Base",
"body": "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><title>A1Mail for AI Agents</title></head><body><p>Hey,<br><br>Welcome to A1Mail!<br>A1Mail is an email API made for AI agents who chat, not spam.<br><br>With A1Mail you can:</p><ul><li>Create new addresses via a simple API</li><li>Send emails effortlessly</li><li>Receive messages instantly via webhooks</li><li>Protect deliverability with built-in spam filters</li><li>Integrate with any AI system</li><li>Enjoy transparent pricing—no hidden fees</li><li>Use your own subdomain for AI agents</li></ul>Find out more at <a href=\"http://www.a1mail.com\">www.a1mail.com</a>.</p></body></html>",
"headers": {
"cc": "[email protected]",
"bcc": "[email protected]"
}
}'
Send a Simple Text Email
curl --location 'https://api.a1base.com/v1/emails/{account_id}/send' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-API-Secret: YOUR_API_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"sender_address": "[email protected]",
"recipient_address": "[email protected]",
"subject": "Hello from A1Base",
"body": "This is an example email body.",
"headers": {}
}'
Send an HTML Email
curl --location 'https://api.a1base.com/v1/emails/{account_id}/send' \
--header 'X-API-Key: YOUR_API_KEY' \
--header 'X-API-Secret: YOUR_API_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"sender_address": "[email protected]",
"recipient_address": "[email protected]",
"subject": "Hello from A1Base",
"body": "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><title>A1Mail for AI Agents</title></head><body><p>Hey,<br><br>Welcome to A1Mail!<br>A1Mail is an email API made for AI agents who chat, not spam.<br><br>With A1Mail you can:</p><ul><li>Create new addresses via a simple API</li><li>Send emails effortlessly</li><li>Receive messages instantly via webhooks</li><li>Protect deliverability with built-in spam filters</li><li>Integrate with any AI system</li><li>Enjoy transparent pricing—no hidden fees</li><li>Use your own subdomain for AI agents</li></ul>Find out more at <a href=\"http://www.a1mail.com\">www.a1mail.com</a>.</p></body></html>",
"headers": {
"cc": "[email protected]",
"bcc": "[email protected]"
}
}'
Send a Simple Text Email
import requests
import json
url = "https://api.a1base.com/v1/emails/{account_id}/send"
headers = {
'X-API-Key': 'YOUR_API_KEY',
'X-API-Secret': 'YOUR_API_SECRET',
'Content-Type': 'application/json'
}
data = {
"sender_address": "[email protected]",
"recipient_address": "[email protected]",
"subject": "Hello from A1Base",
"body": "This is an example email body.",
"headers": {}
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Send an HTML Email
import requests
import json
url = "https://api.a1base.com/v1/emails/{account_id}/send"
headers = {
'X-API-Key': 'YOUR_API_KEY',
'X-API-Secret': 'YOUR_API_SECRET',
'Content-Type': 'application/json'
}
html_body = """<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>A1Mail for AI Agents</title>
</head>
<body>
<p>Hey,<br><br>
Welcome to A1Mail!<br>
A1Mail is an email API made for AI agents who chat, not spam.<br><br>
With A1Mail you can:</p>
<ul>
<li>Create new addresses via a simple API</li>
<li>Send emails effortlessly</li>
<li>Receive messages instantly via webhooks</li>
<li>Protect deliverability with built-in spam filters</li>
<li>Integrate with any AI system</li>
<li>Enjoy transparent pricing—no hidden fees</li>
<li>Use your own subdomain for AI agents</li>
</ul>
<p>Find out more at <a href="http://www.a1mail.com">www.a1mail.com</a>.</p>
</body>
</html>"""
data = {
"sender_address": "[email protected]",
"recipient_address": "[email protected]",
"subject": "Hello from A1Base",
"body": html_body,
"headers": {
"cc": "[email protected]",
"bcc": "[email protected]"
}
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Send a Simple Text Email
const axios = require('axios');
const url = 'https://api.a1base.com/v1/emails/{account_id}/send';
const headers = {
'X-API-Key': 'YOUR_API_KEY',
'X-API-Secret': 'YOUR_API_SECRET',
'Content-Type': 'application/json'
};
const data = {
sender_address: '[email protected]',
recipient_address: '[email protected]',
subject: 'Hello from A1Base',
body: 'This is an example email body.',
headers: {}
};
axios.post(url, data, { headers })
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
Send an HTML Email
const axios = require('axios');
const url = 'https://api.a1base.com/v1/emails/{account_id}/send';
const headers = {
'X-API-Key': 'YOUR_API_KEY',
'X-API-Secret': 'YOUR_API_SECRET',
'Content-Type': 'application/json'
};
const htmlBody = `<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>A1Mail for AI Agents</title>
</head>
<body>
<p>Hey,<br><br>
Welcome to A1Mail!<br>
A1Mail is an email API made for AI agents who chat, not spam.<br><br>
With A1Mail you can:</p>
<ul>
<li>Create new addresses via a simple API</li>
<li>Send emails effortlessly</li>
<li>Receive messages instantly via webhooks</li>
<li>Protect deliverability with built-in spam filters</li>
<li>Integrate with any AI system</li>
<li>Enjoy transparent pricing—no hidden fees</li>
<li>Use your own subdomain for AI agents</li>
</ul>
<p>Find out more at <a href="http://www.a1mail.com">www.a1mail.com</a>.</p>
</body>
</html>`;
const data = {
sender_address: '[email protected]',
recipient_address: '[email protected]',
subject: 'Hello from A1Base',
body: htmlBody,
headers: {
cc: '[email protected]',
bcc: '[email protected]'
}
};
axios.post(url, data, { headers })
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));
We’d love to hear from you!
Don’t hesitate to reach out to [email protected] or [email protected] if there’s any features you’d like to see or prioritised!
On this page