Send Template Email
POST /v1/send/template
Sends an email using a predefined template stored in your account.
Retrieve available templates via GET /v1/templates.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”Request body for sending an email using a saved template.
The template must exist in your account. Retrieve available templates via GET /v1/templates.
object
Unique identifier of the template to use
template123List of recipients
object
Recipient display name
Jane SmithRecipient email address
jane@smith.comDynamic variables to inject into the template content.
Available from variable_a_var to variable_z_var.
Use them in your template with {{variable_a_var}} syntax.
object
Use in dynamic content as {{variable_a_var}}
Variable A ValueFiles to attach via URL. The server will download and attach each file. (Max size per file: 10MB)
object
File name as it will appear in the attachment
document.pdfPublicly accessible URL of the file
https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdfFiles to attach via base64-encoded content. (Max size per file: 10MB)
object
File name as it will appear in the attachment
document.pdfBase64-encoded file content
data:(mime type),base64,JVBERi0xLjQKJazc...Responses
Section titled “ Responses ”Email successfully queued
object
trueSuccesfully queued emailUUIDs assigned to each queued email, one per recipient
Example
{ "status": true, "message": "Succesfully queued email", "data": [ "1b9d6e34-634a-4762-8d5a-f9cb9165d432" ]}Unauthorized — invalid or missing API token
object
An http error occurred. If error persists, contact soporte@contacta.mxobject
Example
{ "status": false, "message": "An http error occurred. If error persists, contact soporte@contacta.mx", "data": { "message": "Your key auth is not valid, please check with your administrator", "code": 401 }}Insufficient credits to complete the send
object
An http error occurred. If error persists, contact soporte@contacta.mxobject
Example
{ "status": false, "message": "An http error occurred. If error persists, contact soporte@contacta.mx", "data": { "message": "Not enough credits for make this send, please check and retry", "code": 402 }}Unprocessable entity — validation failed on request body
object
An http error occurred. If error persists, contact soporte@contacta.mxobject
Example
{ "status": false, "message": "An http error occurred. If error persists, contact soporte@contacta.mx", "data": { "message": "Missing required fields, please verify your request", "code": 422 }}One or more recipients are blacklisted (unsubscribed)
object
An http error occurred. If error persists, contact soporte@contacta.mxobject
Example
{ "status": false, "message": "An http error occurred. If error persists, contact soporte@contacta.mx", "data": { "message": "One or more email addresses are blacklisted for unsubscribing, please check.", "code": 451 }}Examples
Section titled “Examples ”Useful for guiding users to view code examples in different developer languages.
curl -X POST "https://api.example.com/v1/send/template" \ -H "Accept: application/json" \ -H "Connection: keep-alive" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <your-token>" \ -d '{"template_id":"template123","to":[{"name":"Jane Smith","email":"jane@smith.com"}],"variables":{"variable_a_var":"Variable A Value"},"attachment":[{"name":"document.pdf","url":"https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf"}],"attachment_buffer":[{"name":"document.pdf","content":"data:(mime type),base64,JVBERi0xLjQKJazc..."}]}' const fetch = require('node-fetch');
fetch("https://api.example.com/v1/send/template", { method: "POST", headers: { "Accept": "application/json", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Bearer <your-token>"}, body: JSON.stringify({ "template_id": "template123", "to": [ { "name": "Jane Smith", "email": "jane@smith.com" } ], "variables": { "variable_a_var": "Variable A Value" }, "attachment": [ { "name": "document.pdf", "url": "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf" } ], "attachment_buffer": [ { "name": "document.pdf", "content": "data:(mime type),base64,JVBERi0xLjQKJazc..." } ]}) }) .then(res => res.json()) .then(console.log) .catch(console.error); <?php $curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => "https://api.example.com/v1/send/template", CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_HTTPHEADER => [ "Accept: application/json", "Connection: keep-alive", "Content-Type: application/json", "Authorization: Bearer <your-token>" ], CURLOPT_POSTFIELDS => json_encode({ "template_id": "template123", "to": [ { "name": "Jane Smith", "email": "jane@smith.com" } ], "variables": { "variable_a_var": "Variable A Value" }, "attachment": [ { "name": "document.pdf", "url": "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf" } ], "attachment_buffer": [ { "name": "document.pdf", "content": "data:(mime type),base64,JVBERi0xLjQKJazc..." } ]}) ]);
$response = curl_exec($curl); curl_close($curl); echo $response; ?> using System.Net.Http; using System.Text; using System.Threading.Tasks;
var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.POST, "https://api.example.com/v1/send/template") { Content = new StringContent("{ \"template_id\": \"template123\", \"to\": [ { \"name\": \"Jane Smith\", \"email\": \"jane@smith.com\" } ], \"variables\": { \"variable_a_var\": \"Variable A Value\" }, \"attachment\": [ { \"name\": \"document.pdf\", \"url\": \"https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf\" } ], \"attachment_buffer\": [ { \"name\": \"document.pdf\", \"content\": \"data:(mime type),base64,JVBERi0xLjQKJazc...\" } ]}", Encoding.UTF8, "application/json") }; request.Headers.Add("Accept", "application/json");request.Headers.Add("Connection", "keep-alive");request.Headers.Add("Content-Type", "application/json");request.Headers.Add("Authorization", "Bearer <your-token>"); var response = await client.SendAsync(request); var responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); import requests import json
url = "https://api.example.com/v1/send/template" headers = { "Accept": "application/json", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Bearer <your-token>" } data = { "template_id": "template123", "to": [ { "name": "Jane Smith", "email": "jane@smith.com" } ], "variables": { "variable_a_var": "Variable A Value" }, "attachment": [ { "name": "document.pdf", "url": "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf" } ], "attachment_buffer": [ { "name": "document.pdf", "content": "data:(mime type),base64,JVBERi0xLjQKJazc..." } ]}
response = requests.post(url, headers=headers, json=data) print(response.text) import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets;
public class ApiExample { public static void main(String[] args) throws Exception { URL url = new URL("https://api.example.com/v1/send/template"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Accept", "application/json"); conn.setRequestProperty("Connection", "keep-alive"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "Bearer <your-token>");
String jsonInputString = "{\"template_id\":\"template123\",\"to\":[{\"name\":\"Jane Smith\",\"email\":\"jane@smith.com\"}],\"variables\":{\"variable_a_var\":\"Variable A Value\"},\"attachment\":[{\"name\":\"document.pdf\",\"url\":\"https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf\"}],\"attachment_buffer\":[{\"name\":\"document.pdf\",\"content\":\"data:(mime type),base64,JVBERi0xLjQKJazc...\"}]}"; try(OutputStream os = conn.getOutputStream()) { byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8); os.write(input, 0, input.length); }
int code = conn.getResponseCode(); System.out.println("Response code: " + code); } }