Send transactional email for user domain using a saved template
const url = 'https://smtp-app.kirim.email/api/domains/example.com/message/template';const form = new FormData();form.append('template_guid', '550e8400-e29b-41d4-a716-446655440000');form.append('from_name', 'Company Name');form.append('variables', '{ "name": "John Doe", "product": "Premium Widget" }');form.append('headers', '{ "X-Campaign-ID": "welcome-series" }');form.append('attachments', 'binary');form.append('attachment_options', '{"compress": true, "password": "secret123", "watermark": {"enabled": true, "text": "CONFIDENTIAL"}}');
const options = {method: 'POST', headers: {Authorization: 'Basic <credentials>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://smtp-app.kirim.email/api/domains/example.com/message/template \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: multipart/form-data' \ --form template_guid=550e8400-e29b-41d4-a716-446655440000 \ --form 'from_name=Company Name' \ --form 'variables={ "name": "John Doe", "product": "Premium Widget" }' \ --form 'headers={ "X-Campaign-ID": "welcome-series" }' \ --form attachments=binary \ --form 'attachment_options={"compress": true, "password": "secret123", "watermark": {"enabled": true, "text": "CONFIDENTIAL"}}'Send an email for a domain owned by the authenticated user using a stored template. Supports variable replacement using {{variable}} syntax in both subject and content. Template must belong to the authenticated domain. Supports attachments with the same processing options as non-template message endpoint.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Example
example.comDomain name that must be owned by the authenticated user
Request Bodyrequired
Section titled “Request Bodyrequired”object
UUID of the template to use
Example
550e8400-e29b-41d4-a716-446655440000Example
Example
[]Sender email address. Must belong to the authenticated domain. Defaults to noreply@{domain} if not provided.
Example
Optional sender display name. If not provided, will use the email address only.
Example
Company NameSingle set of variables for all recipients
object
Example
{ "name": "John Doe", "product": "Premium Widget"}Array of variable objects, one per recipient
object
Example
[ { "name": "John", "product": "Widget A" }, { "name": "Jane", "product": "Widget B" }]Reply-to email address. Must share the same top-level domain as the ‘from’ address for security compliance.
Example
Single file attachment
Multiple file attachments
JSON string with attachment processing options. Watermark text is limited to 50 characters.
Example
{"compress": true, "password": "secret123", "watermark": {"enabled": true, "text": "CONFIDENTIAL"}}Responses
Section titled “Responses”Template-based email jobs dispatched
object
Example
{ "success": true, "message": "Template-based email jobs dispatched for 2 recipients in 1 job(s)", "template_guid": "550e8400-e29b-41d4-a716-446655440000", "template_name": "Welcome Email"}Headers
Section titled “Headers”Maximum requests per minute
Remaining requests in current window
Unauthorized - Invalid or missing authentication credentials
object
Example
{ "success": false, "message": "Unauthorized"}Not Found - Domain or template not found
object
Example
{ "success": false, "message": "Domain not found or you do not own this domain."}Validation Error - Invalid input data
object
Field-specific validation errors
object
Example
{ "success": false, "message": "Validation failed."}Too Many Requests - Rate limit exceeded. Retry after the specified time.
object
Example
{ "success": false, "message": "Too many attempts. Please try again later."}Headers
Section titled “Headers”Seconds until rate limit resets
Maximum requests per minute
Remaining requests in current window
Server Error - Unexpected error occurred
object
Example
{ "success": false, "message": "An error occurred while sending the template message. Please try again."}