Send Email
API reference for sending emails with Envloped
Send Email
Send transactional emails using the Envloped API.
Endpoint
POST /v1/emailsRequest Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer YOUR_API_KEY |
Content-Type | Yes | application/json |
Request Body
{
"from": "sender@yourdomain.com",
"to": "recipient@example.com",
"subject": "Your subject line",
"html": "<p>Your HTML content</p>",
"text": "Your plain text content",
"replyTo": "replies@yourdomain.com",
"cc": ["cc@example.com"],
"bcc": ["bcc@example.com"],
"headers": {
"X-Custom-Header": "value"
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
from | string | Yes | Sender email address. Must be from a verified domain. |
to | string | string[] | Yes | Recipient email address(es). |
subject | string | Yes | Email subject line. |
html | string | No* | HTML content of the email. |
text | string | No* | Plain text content of the email. |
replyTo | string | No | Reply-to email address. |
cc | string[] | No | CC recipient addresses. |
bcc | string[] | No | BCC recipient addresses. |
headers | object | No | Custom email headers. |
*At least one of html or text is required.
Response
Success (200 OK)
{
"id": "email_abc123xyz",
"status": "sent",
"from": "sender@yourdomain.com",
"to": ["recipient@example.com"],
"subject": "Your subject line",
"createdAt": "2024-01-15T10:30:00Z"
}Response Fields
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the email. |
status | string | Status of the email: sent, queued, or failed. |
from | string | Sender email address. |
to | string[] | Recipient email addresses. |
subject | string | Email subject line. |
createdAt | string | ISO 8601 timestamp of when the email was created. |
Error Responses
400 Bad Request
{
"error": {
"code": "validation_error",
"message": "Invalid request body",
"details": [
{
"field": "to",
"message": "Invalid email address format"
}
]
}
}401 Unauthorized
{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key"
}
}403 Forbidden
{
"error": {
"code": "domain_not_verified",
"message": "The sender domain is not verified"
}
}429 Too Many Requests
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please try again later.",
"retryAfter": 60
}
}Code Examples
cURL
curl -X POST https://api.envloped.com/v1/emails \
-H "Authorization: Bearer en_abc123..." \
-H "Content-Type: application/json" \
-d '{
"from": "hello@yourdomain.com",
"to": "user@example.com",
"subject": "Welcome to our service",
"html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
"text": "Welcome! Thanks for signing up."
}'JavaScript / TypeScript
async function sendEmail() {
const response = await fetch('https://api.envloped.com/v1/emails', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ENVLOPED_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
from: 'hello@yourdomain.com',
to: 'user@example.com',
subject: 'Welcome to our service',
html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
text: 'Welcome! Thanks for signing up.',
}),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.message);
}
return response.json();
}Python
import os
import requests
def send_email():
response = requests.post(
'https://api.envloped.com/v1/emails',
headers={
'Authorization': f'Bearer {os.environ["ENVLOPED_API_KEY"]}',
'Content-Type': 'application/json',
},
json={
'from': 'hello@yourdomain.com',
'to': 'user@example.com',
'subject': 'Welcome to our service',
'html': '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
'text': 'Welcome! Thanks for signing up.',
}
)
response.raise_for_status()
return response.json()Go
package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
)
type EmailRequest struct {
From string `json:"from"`
To string `json:"to"`
Subject string `json:"subject"`
HTML string `json:"html"`
Text string `json:"text"`
}
func sendEmail() (*http.Response, error) {
email := EmailRequest{
From: "hello@yourdomain.com",
To: "user@example.com",
Subject: "Welcome to our service",
HTML: "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
Text: "Welcome! Thanks for signing up.",
}
body, _ := json.Marshal(email)
req, _ := http.NewRequest("POST", "https://api.envloped.com/v1/emails", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("ENVLOPED_API_KEY"))
req.Header.Set("Content-Type", "application/json")
return http.DefaultClient.Do(req)
}Rate Limits
| Plan | Requests per minute | Emails per day |
|---|---|---|
| Free | 10 | 100 |
| Pro | 100 | 10,000 |
| Enterprise | Custom | Custom |
When you exceed rate limits, the API returns a 429 status code with a retryAfter value indicating how many seconds to wait before retrying.