Send transactional email (without template)
Send a fully custom transactional email without using a predefined template. You can define all content manually, including subject, HTML, text, variables, headers, and attachments.
Endpoint
Section titled “Endpoint”HTTP method: POST
https://api.sender.net/v2/message/send
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
from | object required | Sender object containing ‘email’ and ‘name’. Both fields are required. |
to | object required | Recipient object containing ‘email’ (required) and optional ‘name’. This replaces ‘recipient_email’, which is still supported for backward compatibility. |
recipient_email | string | Deprecated. Use the ‘to’ object instead. Retained for backward compatibility. |
subject | string required | Subject line of the email. |
text | string | Plain-text version of the email body. |
html | string | HTML version of the email body. |
headers | object | Optional headers to include (e.g., custom X- headers or charset). |
variables | object | A key-value list of dynamic variables to personalize the message content. |
attachments | object | A list of files to attach, where keys are filenames and values are publicly accessible URLs. |
Request Examples
Section titled “Request Examples”const url = new URL("https://api.sender.net/v2/message/send");
let headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",};
let bodyContent = { "from": { "name": "Sender" }, "to": { "name": "Sender Support" }, "subject": "Hello from Sender", "text": "Hello from Sender", "html": "Hello from <b>Sender</b>.", "headers": { "X-smth-custom": "custom_value_1", "charset": "utf-8" }, "variables": { "firstname": "Sender", "lastname": "Support" }, "attachments": { "FILE_NAME_1": "https://ATTACHMENT_URL/", "FILE_NAME_2": "https://ATTACHMENT_URL/" }};
fetch(url, { method: "POST", headers, body: JSON.stringify(bodyContent)}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));$client = new \GuzzleHttp\Client();
$json = [ "from" => { "name" => "Sender" }, "to" => { "name" => "Sender Support" }, "subject" => "Hello from Sender", "text" => "Hello from Sender", "html" => "Hello from <b>Sender</b>.", "headers" => { "X-smth-custom" => "custom_value_1", "charset" => "utf-8" }, "variables" => { "firstname" => "Sender", "lastname" => "Support" }, "attachments" => { "FILE_NAME_1" => "https =>//ATTACHMENT_URL/", "FILE_NAME_2" => "https =>//ATTACHMENT_URL/" }];
$response = $client->post( 'https://api.sender.net/v2/message/send', [ 'headers' => [ 'Authorization' => 'Bearer [your-token]', 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'json' => $json ]);
$body = $response->getBody()->getContents();$data = json_decode($body, true);print_r($data);import requestsimport json
url = "https://api.sender.net/v2/message/send"
headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",}
payload = { "from": { "name": "Sender" }, "to": { "name": "Sender Support" }, "subject": "Hello from Sender", "text": "Hello from Sender", "html": "Hello from <b>Sender</b>.", "headers": { "X-smth-custom": "custom_value_1", "charset": "utf-8" }, "variables": { "firstname": "Sender", "lastname": "Support" }, "attachments": { "FILE_NAME_1": "https://ATTACHMENT_URL/", "FILE_NAME_2": "https://ATTACHMENT_URL/" }}
response = requests.request('POST', url, headers=headers, json=payload)
print(response.json())curl -X POST \"https://api.sender.net/v2/message/send" \-H "Authorization: Bearer [your-token]" \-H "Content-Type: application/json" \-H "Accept: application/json" \-d '{"from":{"email":"[email protected]","name":"Sender"},"to":{"email":"[email protected]","name":"Sender Support"},"subject":"Hello from Sender","text":"Hello from Sender","html":"Hello from <b>Sender</b>.","headers":{"X-smth-custom":"custom_value_1","charset":"utf-8"},"variables":{"firstname":"Sender","lastname":"Support"},"attachments":{"FILE_NAME_1":"https://ATTACHMENT_URL/","FILE_NAME_2":"https://ATTACHMENT_URL/"}}'Response
Section titled “Response”{ "success": true, "message": "Email sent", "emailId": "ep2W4y-7pn8o21-YPpLY9PR5Jy9-x7GYQ"}