Send Email Tutorial
Learn how to send your first transactional email from start to finish.
Prerequisites
- An admin account on the platform
- A configured email provider (SMTP, SendGrid, etc.)
- Your project API key
Step 1: Get Your API Key
When you create a project via the admin panel, the platform generates a unique API key. Save it securely — it is shown only once.
Create a projectbash
curl -X POST http://localhost:8000/admin/api/products \
-H "X-Admin-Key: your_admin_key" \
-H "Content-Type: application/json" \
-d '{"name": "My App"}'The response includes your api_key — copy it and store it in an environment variable.
Step 2: Configure an Email Provider
Before you can send emails, configure a provider. Here is an example using SMTP:
Configure SMTP providerbash
curl -X PUT http://localhost:8000/admin/api/products/1/email-config \
-H "X-Admin-Key: your_admin_key" \
-H "Content-Type: application/json" \
-d '{
"provider_type": "smtp",
"email_user": "your@email.com",
"email_pass": "your-app-password",
"smtp_server": "smtp.gmail.com",
"smtp_port": 587
}'Provider options
You can also use SendGrid, Amazon SES, or Resend. See the Providers page for configuration details.
Step 3: Send Your First Email
Now you are ready to send. Make a POST request to the email endpoint:
Send email via cURLbash
curl -X POST http://localhost:8000/api/v1/email/send \
-H "X-API-Key: epk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"to_emails": "user@example.com",
"subject": "Welcome to My App!",
"message_body": "<h1>Hello!</h1><p>Thanks for signing up.</p>",
"is_html": true
}'Expected Response
Responsejson
{
"success": true,
"message": "Email queued successfully",
"data": {
"id": "msg_abc123",
"status": "queued",
"to": "user@example.com",
"subject": "Welcome to My App!"
}
}Step 4: Using JavaScript (Node.js / Browser)
JavaScript examplejavascript
const API_KEY = 'epk_your_api_key'
const response = await fetch('http://localhost:8000/api/v1/email/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': API_KEY,
},
body: JSON.stringify({
to_emails: 'user@example.com',
subject: 'Hello from JS',
message_body: '<p>Sent via fetch!</p>',
is_html: true,
}),
})
const data = await response.json()
console.log(data)Step 5: Using Python
Python examplepython
import requests
API_KEY = 'epk_your_api_key'
response = requests.post(
'http://localhost:8000/api/v1/email/send',
headers={
'Content-Type': 'application/json',
'X-API-Key': API_KEY,
},
json={
'to_emails': 'user@example.com',
'subject': 'Hello from Python',
'message_body': '<p>Sent via requests!</p>',
'is_html': True,
}
)
print(response.json())Step 6: Check Delivery Status
Emails are queued and sent asynchronously. Check the logs to see delivery status:
Get email logsbash
curl -X GET "http://localhost:8000/api/v1/email/logs?page=1&per_page=20" \
-H "X-API-Key: epk_your_api_key"What happens next?
The email enters a persistent job queue. A worker picks it up, delivers it via your configured provider, and updates the log. If delivery fails, the system retries automatically.
Next Steps
- Use templates for dynamic email content
- Add attachments to your emails
- Configure webhooks for real-time delivery notifications