๐Ÿงพ Send Email With Template

Use this endpoint to send transactional emails using a pre-defined template in SendX.

Endpoint

POST https://app.sendx.io/rest/email/template

Headers

HeaderValueDescription
Content-Typeapplication/jsonRequired
AuthorizationBearer YOUR_API_KEYYour SendX API key

Request Body Schema

{
  "from": {
    "email": "string (required)"
  },
  "to": [
    {
      "email": "string (required)",
      "customFields": { "key": "value", ... }
    }
  ],
  "template": "string (required)",
  "headers": { "Header-Name": "string", ... },
  "trackClicks": true,
  "trackOpens": true
}

Example Usage: Send With Template

curl -X POST "https://app.sendx.io/rest/email/template" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "from": {
      "email": "support@example.com"
    },
    "to": [
      {
        "email": "user@example.com",
        "customFields": {
          "first_name": "Jane",
          "order_id": "A12345"
        }
      }
    ],
    "template": "order-confirmation-template",
    "headers": {
      "X-Campaign": "order-confirmation",
      "List-ID": "template-orders"
    },
    "trackClicks": true,
    "trackOpens": true
}'

โœ… Successful Response

{
  "messageId": "template_456def",
  "accepted": ["user@example.com"],
  "rejected": []
}

Return fields:

  • messageId: Unique ID for the sent message.
  • accepted: Recipients the email was successfully queued for.
  • rejected: Recipients that failed validation.

๐Ÿšจ Error Response

{
  "error": {
    "code": 404,
    "message": "Template not found"
  }
}

Common error details:

  • 400: Bad Request โ€“ missing required fields.
  • 401: Unauthorized โ€“ bad or missing API key.
  • 404: Template not found โ€“ check your template name.
  • 429: Too Many Requests โ€“ rate limit exceeded.