The Mailercloud Email API allows you to send emails automatically from your application or website. You can define the sender, recipients, subject, email content, and even add attachments. This is useful for sending automated emails like order confirmations, password resets, or marketing emails.
To use this API, you need an API key for authentication.
POST https://email-api.mailercloud.com/emailContent-Type: application/json
Authorization: YOUR_API_KEY {
"email": {
"from": "[email protected]",
"fromName": "John Doe",
"replyTo": [
"[email protected]",
"[email protected]"
],
"subject": "email subject",
"text": "text body",
"html": "html body",
"recipients": {
"to": [{
"name": "Recipient1",
"email": "abc12345"
}, {
"name": "Recipient2",
"email": "[email protected]"
}],
"cc": [
"[email protected]",
"[email protected]"
],
"bcc": [
"[email protected]",
"[email protected]"
]
},
"attachments": [{
"name": "Attachment1",
"url": "https://link/to/attachment/1"
},{
"name": "Attachment2",
"url": "http://link/to/attachment/2"
}]
},
"metadata": {
"campaignType": "PROMOTIONAL", //Only allow TRANSACTIONAL or PROMOTIONAL
"timestamp": "2018-01-25T10:24:16+0000",
"messageId": "your-message-id", // unique id required
"custom" : {
"key1" : "val1",
"key2" : "val2"
}
},
"version": "1.0" //required
}
{
"email": {
"from": "[email protected]",
"fromName": "John Doe",
"replyTo": [
"[email protected]",
"[email protected]"
],
"subject": "email subject",
"text": "text body",
"html": "html body",
"amp_html" : "amp_body",
"recipients": {
"to": [{
"name": "Recipient1",
"email": "abc12345"
}, {
"name": "Recipient2",
"email": "[email protected]"
}],
"cc": [
"[email protected]",
"[email protected]"
],
"bcc": [
"[email protected]",
"[email protected]"
]
},
"attachments": [{
"name": "Attachment1",
"url": "https://link/to/attachment/1"
},{
"name": "Attachment2",
"url": "http://link/to/attachment/2"
}]
},
"metadata": {
"campaignType": "PROMOTIONAL", //Only allow TRANSACTIONAL or PROMOTIONAL
"timestamp": "2018-01-25T10:24:16+0000",
"messageId": "your-message-id", // unique id required
"custom" : {
"key1" : "val1",
"key2" : "val2"
}
},
"version": "2.0" // required
}Parameter | Type | Description |
email.from | String | Sender’s email address |
email.fromName | String | Sender’s name |
email.replyTo | Array | Reply-to email addresses |
email.subject | String | Email subject |
email.text | String | Plain text version of the email |
email.html | String | HTML version of the email |
email.recipients | Object | Contains recipient information (To, CC, BCC) |
email.attachments | Array | Attach files to your email |
When the email is sent successfully, the API returns:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "SUCCESS",
"statusCode": 1000,
"message": "NA"
}HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "ERROR",
"statusCode": 9002,
"message": "Daily email sending quota is over."
}HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"status": "ERROR",
"statusCode": 9022,
"message": "Unsupported version",
"supportedVersion": "1.0"
}Status Code | Meaning |
1000 | Success |
9001 | Throttling error |
9002 | Message sending quota exceeded |
9003 | Authentication failure |
9004 | Recipient address not specified |
9005 | From field missing |
9006 | Soft bounce (temporarily deferred) |
9007 | Hard bounce |
9008 | Email reported as spam |
9009 | Email unsubscribed |
9010 | Email in suppression list |
9011 | Sender address not verified |
9012 | ESP rejected message |
9013 | Request to ESP expired |
9014 | ESP unavailable |
9015 | IP not whitelisted with ESP |
9016 | Subject field empty |
9017 | Invalid sender address |
9018 | Invalid email address |
9019 | Recipient's mailbox is full |
9020 | Error processing email at Private ESP |
9021 | Mailbox was not found on email server |
9022 | Unsupported or unknown version |
9024 | Authorization failure |
9452 | Message overloading |
9512 | Host email server not found |
9999 | Unknown error occurred |
Custom headers — email.headers, for example List-Unsubscribe or X-Order-Reference
Inbox tracking — metadata.custom.inbox_tracking with metadata.custom.campaign_id
Tags — metadata.custom.tags, up to 10, for filtering messages in the Activity list
Content storage — metadata.custom.store_content: false for sensitive emails such as OTPs
Duplicate protection — reusing a metadata.messageId within 24 hours does not send again and still returns success, so a timed-out request is safe to retry. The message ID is shown in the Activity list.
Tracking — opens are tracked when your sending domain has a tracking domain configured. Click tracking is not available.
For the full field reference, see the Send Email API documentation.
One thing to note: messageId is described in the request-body samples as "unique id required", but it's optional — the server generates one if you leave it out. Worth correcting in both code comments while you're in there.