Skip to content

Send via API

This section helps you integrate with the MX18 Email API and send your first email via a simple POST request.


Pre-requisites

To send an email using MX18’s API, ensure the following:

⚠️ Requests without a valid token or unverified sender domain will be rejected.


API endpoint

Use the following endpoint to send emails via MX18’s Mail Send API:

POST https://api.mx18.com/api/1/mail/send

Authentication is handled via the `Authorization` header:

Authorization: Bearer YOUR_API_TOKEN Content-Type: application/json


Sample request payload

{
  "from": {
    "name": "Your Business Name",
    "email": "info@mails.yourdomain.com"
  },
  "to": [
    {
      "name": "Example Customer",
      "email": "user@example.com",
      "personalizationData": {
        "key1": "value",
        "key2": "value"
      }
    }
  ],
  "cc": [
    {
      "name": "Manager",
      "email": "manager@example.com"
    }
  ],
  "bcc": [
    {
      "name": "Auditor",
      "email": "auditor@example.com"
    }
  ],
  "globalPersonalizationData": {
    "key1": "value",
    "key2": "value"
  },
  "message": {
    "subject": "Test Mail - Here is a subject line",
    "content": [
      {
        "type": "text/html",
        "value": "Hello, this is HTML content. <a href=':key'>Click here</a>"
      },
      {
        "type": "text/plain",
        "value": "This is a plain text version of the email."
      }
    ],
    "attachments": [
      {
        "type": "application/pdf",
        "name": "myfile.pdf",
        "data": "<base64_encoded_string>"
      }
    ],
    "headers": {
      "X-Custom-Header1": "CustomValue",
      "X-Custom-Header2": "MX18 API"
    }
  },
  "customArguments": {
    "customerAccountNumber": "55555",
    "activationAttempt": "1"
    }
}

Success response

{
"transactionId": "abc123xyz456",
"status": "Accepted",
"message": "Email request has been accepted for delivery."
}

Field reference

Top-level fields

Field Description
from Sender's name and email address
replyTo Optional reply address
to, cc, bcc Arrays of recipient objects
globalPersonalizationData Fallback dynamic values for template personalization
customArguments Parameters tied with the recipient objects and returned with webhooks schema in the real time

Recipient-level personalization

Field Description
personalizationData Dynamic values unique to each recipient

Message object

Field Description
subject Subject line of the email
content Array of content blocks (text/plain, text/html, etc.)
attachments List of attachment objects
headers Custom headers to include with the email

Attachment object fields

Field Description
type MIME type (e.g., application/pdf)
file_name Filename displayed to the recipient
disposition Either attachment or inline
data Base64-encoded file content

Need help?

If you encounter issues while using the API:

  • Double-check your API token and domain verification status

  • Use a valid email format for all recipients

  • Contact our support team at support@mx18.com

For next steps, explore: