Skip to content

Send transactional campaign (with template)

Send a transactional campaign message using a predefined template. You can override the template’s content by providing ‘text’, ‘html’, or ‘headers’.

HTTP method: POST

https://api.sender.net/v2/message/{id}/send


ParameterTypeDescription
idstring requiredID of the transactional campaign to send.
toobject requiredRecipient object containing ‘email’ (required) and optional ‘name’. This replaces ‘recipient_email’, which is still supported for backward compatibility.
variablesobjectA key-value list of dynamic variables to personalize the content.
attachmentsobjectA list of files to attach, where keys are filenames and values are publicly accessible URLs.
textstringOptional plain-text version of the email. Overrides the template’s text content.
htmlstringOptional HTML version of the email. Overrides the template’s HTML content.
headersobjectOptional headers to include (e.g., custom X- headers or charset). Overrides template headers if provided.

const url = new URL("https://api.sender.net/v2/message/{id}/send");
let headers = {
"Authorization": "Bearer [your-token]",
"Content-Type": "application/json",
"Accept": "application/json",
};
let bodyContent = {
"to": {
"email": "[email protected]",
"name": "Sender Support"
},
"variables": {
"firstname": "Sender",
"lastname": "Support"
},
"attachments": {
"FILE_NAME_1": "https://ATTACHMENT_URL/",
"FILE_NAME_2": "https://ATTACHMENT_URL/"
},
"text": "Hello from Sender",
"html": "Hello from <b>Sender</b>.",
"headers": {
"X-smth-custom": "custom_value_1",
"charset": "utf-8"
}
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(bodyContent)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Example Response
{
"success": true,
"message": "Email sent",
"emailId": "ep2W4y-7pn8o21-YPpLY9PR5Jy9-x7GYQ"
}