API key creation is available at: https://app.emailmassivo.com/api.
You can read detailed information about creating an API key in our Knowledge Base
Important: test emails must be sent only to existing email addresses, otherwise the key will be banned.
POST https://api.emailmassivo.com/api/v1/external-mails/send
In the «X-Api-Key» header, you need to pass the API key as a string for authentication.
{
"idempotencyKey": "unique-key-string",
"mail": {
"to": {
"email": "[email protected]",
"name": "string"
},
"from": {
"email": "[email protected]",
"name": "string"
},
"subject": "string",
"previewTitle": "string",
"headers": {
},
"cc": "string",
"bcc": "string",
"html": "string",
"text": "string"
}
}
Important:
For email acceptance, at least one content type is required — html or text. If both fields are missing, the email will be rejected.
{ "filename.extension": "file body encoded in base64"};
If within one hour a repeated request to send an email with completely matching parameters arrives:
Then:
uuid as in the first request, repeated sending does not create a new email;idempotencyKey, passed outside the mail block) emails are considered different when key values differ and will be sent again.We strongly recommend always passing your unique idempotencyKey.
Using a user idempotency key is considered necessary for reliable management of repeated requests.
The automatic repeat detection mechanism without a key exists only for backward compatibility and basic duplicate protection, but does not guarantee the absence of missed or extra sends.
| Status | Description |
|---|---|
| 201 | Email accepted for sending Example: { "uuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6"} |
| 400 | Bad Request — invalid request format |
| 401 | Unauthorized — invalid or missing API key |
| 403 | Forbidden — access denied |
| 422 | Unprocessable Entity — data validation error |
| 429 | Too Many Requests — request limit exceeded |
| 500 | Internal Server Error — internal server error |
POST https://api.emailmassivo.com/api/v1/external-mails/send-by-template
In the «X-Api-Key» header, you need to pass the API key as a string for authentication.
{
"idempotencyKey": "unique-key-string",
"mail": {
"to": {
"email": "[email protected]",
"name": "string"
},
"from": {
"email": "[email protected]",
"name": "string"
},
"subject": "string",
"previewTitle": "string",
"idTemplateMailUser": number,
"params": {
"test": "string",
"test1": "string",
"test2": "string"
}
}
}
$url = 'https://api.emailmassivo.com/api/v1/external-mails/send-by-template';
$data = array(
'idempotencyKey' => 'unique-key-string',
'mail' => array(
'to' => array(
'email' => '[email protected]',
'name' => 'string'
),
'from' => array(
'email' => '[email protected]',
'name' => 'string'
),
'subject' => 'string',
'previewTitle' => 'string',
'idTemplateMailUser' => number,
'params' => array(
'test' => 'string',
'test1' => 'string',
'test2' => 'string'
)
)
);
$headers = array(
'Content-Type' => 'application/json',
'X-Api-Key' => 'YOUR_API_KEY'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
import requests
import json
url = 'https://api.emailmassivo.com/api/v1/external-mails/send-by-template'
data = {
'idempotencyKey': 'unique-key-string',
'mail': {
'to': {
'email': '[email protected]',
'name': 'string'
},
'from': {
'email': '[email protected]',
'name': 'string'
},
'subject': 'string',
'previewTitle': 'string',
'idTemplateMailUser': number,
'params': {
'test': 'string',
'test1': 'string',
'test2': 'string'
}
}
}
headers = {
'Content-Type': 'application/json',
'X-Api-Key': 'YOUR_API_KEY'
}
response = requests.post(url, json=data, headers=headers)
const axios = require('axios');
const url = 'https://api.emailmassivo.com/api/v1/external-mails/send-by-template';
const data = {
idempotencyKey: 'unique-key-string',
mail: {
to: {
email: '[email protected]',
name: 'string'
},
from: {
email: '[email protected]',
name: 'string'
},
subject: 'string',
previewTitle: 'string',
idTemplateMailUser: number,
params: {
test: 'string',
test1: 'string',
test2: 'string'
}
}
};
const headers = {
'Content-Type': 'application/json',
'X-Api-Key': 'YOUR_API_KEY'
};
axios.post(url, data, { headers })
.then(response => {
// API response handling
})
.catch(error => {
// Error handling
});
const url = 'https://api.emailmassivo.com/api/v1/external-mails/send-by-template';
const data = {
idempotencyKey: 'unique-key-string',
mail: {
to: {
email: '[email protected]',
name: 'string'
},
from: {
email: '[email protected]',
name: 'string'
},
subject: 'string',
previewTitle: 'string',
idTemplateMailUser: number,
params: {
test: 'string',
test1: 'string',
test2: 'string'
}
}
};
const headers = {
'Content-Type': 'application/json',
'X-Api-Key': 'YOUR_API_KEY'
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
// API response handling
})
.catch(error => {
// Error handling
});
If the request returns an error: "Invalid API key", replace the API key passing code with:
$headers = array( 'Content-Type: application/json', 'X-Api-Key: YOUR_API_KEY');