Code preference:
Curl
Ruby
Php
Python
Node.js
C#
Java

Transactional email (templates)

Developers can manage their templates using this API. Following are the various operations supported by this API.

This API call will let you send templates created on SendinBlue, through SendinBlue SMTP (transactional mails).

Input Parameter Description
id Id of the template created on SendinBlue account [Mandatory].
to Email address of the recipient(s). You can use pipe ( | ) to separate multiple recipients. Example: “to-example@example.net|to2-example@example.net” [Mandatory].
cc Same as to but for Cc [Optional].
bcc Same as to but for Bcc [Optional].
replyto Email address of the Reply To [Optional].
attr The name of attribute present in your SendinBlue account. It should be sent as an associative array. Example: array(“NAME”=>”name”). You can use commas to separate multiple attributes [Optional].
attachment_url Provide the absolute URL of the attachment. Url not allowed from local machine. File must be hosted somewhere. Example: “http://example.net/upload-file”.
Possible extension values = xlsx, xls, ods, docx, docm, doc, csv, pdf, txt, gif, jpg, jpeg, png, bmp, tif, tiff, rtf, msg, pub & mobi [Optional].
attachment To send attachment/s generated on the fly you have to pass your attachment/s filename & its base64 encoded chunk data as an associative array. Example: array(“YourFileName.Extension”=>”Base64EncodedChunkData”). You can use commas to separate multiple attachments.
Possible extension values = gif, png, bmp, cgm, jpg, jpeg, txt, css, shtml, html, htm, csv, zip, pdf, xml, doc, xls, xlsx, ods, docx, docm, ppt, tar, ez, ics, tif, tiff, and rtf [Optional].
headers The headers will be sent along with the mail headers in original email. Example: array(“Content-Type”=>”text/html; charset=iso-8859-1″). You can use commas to separate multiple headers [Optional].

Example :

Note 1: The ‘attr’ parameter values are for variables to be replaced in the templates. In template this attribute must be provided inside ‘%%’ in capital without spaces (non accented characters are recommended). If the value of this attribute is provided in the request than in the mail it will be replaced with the value in the result. If no such attribute found than no replacement will be done. And if in template for ex: %PASS% is found and value of PASS is not provided in the request, than no replacement will be done. You can also have those variables in the subject, they will also be replaced while sending the email.

Note 2: The attachment with absolute Url OR attachment/s generated on the fly are given priority and sent as an attachment/s with SMTP template. If these run-time attachment/s are not passed, then existing attachment file with SMTP template record added while template create/update is passed as an attachment.

Sample Output :

This API call will let you create a template.

Input Parameter Description
from_name Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for New Shared IP clients, if sender exists].
template_name Name of the Template [Mandatory].
bat Email address for test mail [Optional].
html_content Body of the content. The HTML content field must have more than 10 characters [Mandatory: if html_url is empty].
html_url Url which content is the body of content [Mandatory: if html_content is empty].
subject Subject of the campaign [Mandatory].
from_email Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for New Shared IP clients, if sender exists].
reply_to The reply to email in the campaign emails [Optional].
to_field This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here, these should already exist in SendinBlue account [Optional].
status Status of template. Possible values = 0 (default) & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional].
attachment_url Provide the absolute url of the attachment. Url not allowed from local machine. File must be hosted somewhere [Optional].

Example :

Sample Output :

If successful, it returns the ID of the created Template.

This API call will let you update a template.

Input Parameter Description
id Id of Template to be modified [Mandatory].
from_name Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for New Shared IP clients, if sender exists].
template_name Name of the Template [Optional].
bat Email address for test mail [Optional].
html_content Body of the content. The HTML content field must have more than 10 characters [Optional: if html_url is empty].
html_url Url which content is the body of content [Optional: if html_content is empty].
subject Subject of the campaign [Optional].
from_email Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for New Shared IP clients, if sender exists].
reply_to The reply to email in the campaign emails [Optional].
to_field This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here, these should already exist in SendinBlue account [Optional].
status Status of template. Possible values = 0 & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional].
attachment_url Provide the absolute url of the attachment. Url not allowed from local machine. File must be hosted somewhere [Optional].

Example :

Sample Output :

This API call will let you access your created templates information.

a. To retrieve details of any particular template : get_campaign_v2()

Input Parameter Description
id Unique Id of the template campaign [Mandatory].

Example :

Sample Output :

b. To retrieve details of all templates : get_campaigns_v2()

Input Parameter Description
type Type of campaign. Possible value – template ( case sensitive ) [Optional].
status Status of campaign. Possible values – temp_active, temp_inactive ( case sensitive ) [Optional].
page Maximum number of records per request is 500, if there are more than 500 campaigns then you can use this parameter to get next 500 results [Optional].
page_limit This should be a valid number between 1-1000. If page limit is kept empty or >1000, default is 500 [Optional].

Example :

Sample Output :