📬 Send Email
Use this endpoint to send an email through the SendX API.
Endpoint
POST https://app.sendx.io/rest/email
Header | Value | Description |
---|
Content-Type | application/json | Required |
Authorization | Bearer YOUR_API_KEY | Your SendX API key |
Request Body Schema
{
"from": {
"email": "string (required)"
},
"to": [
{
"email": "string (required)",
"customFields": { "cf1": "string", ... }
}
],
"subject": "string (required)",
"htmlBody": "string (optional)",
"textBody": "string (optional)",
"headers": { "Header-Name": "string", ... },
"trackClicks": true,
"trackOpens": true
}
Example Usage: Send Email
curl -X POST "https://app.sendx.io/rest/email" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"from": {
"email": "support@example.com"
},
"to": [
{
"email": "user@example.com",
"customFields": {
"order_id": "A12345",
"vip": "true"
}
}
],
"subject": "Your SendX Order Confirmation",
"htmlBody": "<p>Hi Jane, your <strong>order {{order_id}}</strong> has been confirmed!</p><p>Unsubscribe <a href=\"{{unsubscribe}}\">here</a>.</p>",
"textBody": "Hi Jane, your order {{order_id}} has been confirmed! Unsubscribe: {{unsubscribe}}",
"headers": {
"X-Campaign": "order-confirmation",
"List-ID": "list-orders"
},
"trackClicks": true,
"trackOpens": true
}'
✅ Successful Response
{
"messageId": "abc123",
"accepted": ["jane.doe@example.com","john.smith@example.com"],
"rejected": []
}
Return fields:
messageId
: Unique ID for the sent email.
accepted
: Recipients to which the email was dispatched.
rejected
: Recipients that failed validation.
🚨 Error Response
{
"error": {
"code": 401,
"message": "Unauthorized: invalid API key"
}
}
Common error details:
400
: Bad Request – missing required fields.
401
: Unauthorized – bad or missing API key.
429
: Too Many Requests – rate limit exceeded.