post https://api.brevo.com/v3/smtp/templates
Code Examples
You can use as reference the code below to implement this call in your preferred language.
Check all our official API clients here
const SibApiV3Sdk = require('sib-api-v3-sdk');
let defaultClient = SibApiV3Sdk.ApiClient.instance;
let apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = 'YOUR API KEY';
let apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
let smtpTemplate = new SibApiV3Sdk.CreateSmtpTemplate();
smtpTemplate.sender = {"name":"John Doe","email":"[email protected]"};
smtpTemplate.templateName = "Example Template";
smtpTemplate.htmlContent = "<html><body><h1>This is my first transactional email</h1></body></html>";
smtpTemplate.subject = "New Subject";
smtpTemplate.replyTo = "[email protected]";
smtpTemplate.toField = "[email protected]";
smtpTemplate.isActive = true;
smtpTemplate.attachmentUrl = "https://example.net/upload-file";
apiInstance.createSmtpTemplate(smtpTemplate).then(function(data) {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
console.error(error);
});
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR API KEY');
$apiInstance = new SendinBlue\Client\Api\TransactionalEmailsApi(
new GuzzleHttp\Client(),
$config
);
$smtpTemplate = new \SendinBlue\Client\Model\CreateSmtpTemplate();
$smtpTemplate['sender'] = array('name' => 'Shubham Upadhyay', 'email' => '[email protected]');
$smtpTemplate['templateName'] = 'Example Template';
$smtpTemplate['htmlContent'] = '<html><body><h1>This is my first transactional email</h1></body></html>';
$smtpTemplate['subject'] = 'New Subject';
$smtpTemplate['replyTo'] = '[email protected]';
$smtpTemplate['toField'] = '[email protected]';
$smtpTemplate['isActive'] = true;
$smtpTemplate['attachmentUrl'] = 'https://example.net/upload-file';
try {
$result = $apiInstance->createSmtpTemplate($smtpTemplate);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling TransactionalEmailsApi->createSmtpTemplate: ', $e->getMessage(), PHP_EOL;
}
?>
from __future__ import print_function
import time
import sib_api_v3_sdk
from sib_api_v3_sdk.rest import ApiException
from pprint import pprint
configuration = sib_api_v3_sdk.Configuration()
configuration.api_key['api-key'] = 'YOUR API KEY'
api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
sender = {"name":"John Doe","email":"[email protected]"}
template_name = "Example Template"
html_content = "<html><body><h1>This is my first transactional email</h1></body></html>"
subject = "New Subject"
reply_to = "[email protected]"
to_field = "[email protected]"
is_active = True
attachment_url = "https://example.net/upload-file"
smtp_template = sib_api_v3_sdk.CreateSmtpTemplate(sender=sender, template_name=template_name, html_content=html_content, subject=subject, reply_to=reply_to, to_field=to_field, is_active=is_active, attachment_url=attachment_url)
try:
api_response = api_instance.create_smtp_template(smtp_template)
pprint(api_response)
except ApiException as e:
print("Exception when calling SMTPApi->create_smtp_template: %s\n" % e)
const SibApiV3Sdk = require('sib-api-v3-typescript');
let apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
let apiKey = apiInstance.authentications['apiKey'];
apiKey.apiKey = 'YOUR API KEY';
let smtpTemplate = new SibApiV3Sdk.CreateSmtpTemplate();
smtpTemplate.sender = {"name":"John Doe","email":"[email protected]"};
smtpTemplate.templateName = "Example Template";
smtpTemplate.htmlContent = "<html><body><h1>This is my first transactional email</h1></body></html>";
smtpTemplate.subject = "New Subject";
smtpTemplate.replyTo = "[email protected]";
smtpTemplate.toField = "[email protected]";
smtpTemplate.isActive = true;
smtpTemplate.attachmentUrl = "https://example.net/upload-file";
apiInstance.createSmtpTemplate(smtpTemplate).then(function(data) {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
console.error(error);
});
package sibApi;
import sendinblue.ApiClient;
import sendinblue.Configuration;
import sendinblue.auth.ApiKeyAuth;
import sibModel.*;
public class Program {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: api-key
ApiKeyAuth apiKey = (ApiKeyAuth) defaultClient.getAuthentication("api-key");
apiKey.setApiKey("YOUR API KEY");
try {
TransactionalEmailsApi api = new TransactionalEmailsApi();
CreateSmtpTemplateSender sender = new CreateSmtpTemplateSender();
sender.setEmail("[email protected]");
sender.setName("John Doe");
CreateSmtpTemplate smtpTemplate = new CreateSmtpTemplate();
smtpTemplate.setSender(sender);
smtpTemplate.setTemplateName("Example Template");
smtpTemplate.setHtmlContent("<html><body><h1>This is my first transactional email</h1></body></html>");
smtpTemplate.setSubject("New Subject");
smtpTemplate.setReplyTo("[email protected]");
smtpTemplate.setToField("[email protected]");
smtpTemplate.setIsActive(true);
smtpTemplate.setAttachmentUrl("https://example.net/upload-file");
CreateModel response = api.createSmtpTemplate(smtpTemplate);
System.out.println(response.toString());
} catch (Exception e) {
System.out.println("Exception occurred:- " + e.getMessage());
}
}
}
using sib_api_v3_sdk.Api;
using sib_api_v3_sdk.Client;
using sib_api_v3_sdk.Model;
using System;
using System.Diagnostics;
namespace Sendinblue
{
class Program
{
static void Main(string[] args)
{
Configuration.Default.ApiKey.Add("api-key", "YOUR API KEY");
var apiInstance = new TransactionalEmailsApi();
string tag = null;
string senderName = "John Doe";
string senderEmail = "[email protected]";
string templateName = "Example Template";
string htmlContent = "<html><body><h1>This is my first transactional email</h1></body></html>";
string htmlUrl = null;
string subject = "New Subject";
string replyTo = "[email protected]";
string toField = "[email protected]";
bool? isActive = true;
string attachmentUrl = "https://example.net/upload-file";
CreateSmtpTemplateSender sender = new CreateSmtpTemplateSender(senderName, senderEmail);
try
{
var smtpTemplate = new CreateSmtpTemplate(tag, sender, templateName, htmlContent, htmlUrl, subject, replyTo, toField, attachmentUrl, isActive);
CreateModel result = apiInstance.CreateSmtpTemplate(smtpTemplate); Debug.WriteLine(result.ToJson());
Console.WriteLine(result.ToJson());
Console.ReadLine();
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
Console.WriteLine(e.Message);
Console.ReadLine();
}
}
}
}
package main
import (
"fmt"
"context"
sib_api_v3_sdk "./lib"
)
func main() {
var ctx context.Context
var cli = sib_api_v3_sdk.APIClient{
cfg: sib_api_v3_sdk.NewConfiguration(),
}
//Configure API key authorization: api-key
cli.cfg.AddDefaultHeader("api-key", "YOUR_API_KEY")
sib := sib_api_v3_sdk.NewAPIClient(cli.cfg)
body := CreateSmtpTemplate{
Tag: "myTag",
Sender: &CreateSmtpTemplateSender{
Name: "John Doe",
Email: "[email protected]",
},
TemplateName: "TamplateName",
HtmlContent: "<html><body><h1>This is my first transactional email</h1></body></html>",
Subject: "New Subject",
ReplyTo: "replyto@domain",
ToField: "[email protected]",
AttachmentUrl: "https://example.net/upload-file",
IsActive: false,
}
obj, resp, err := sib.TransactionalEmailsApi.CreateSmtpTemplate(ctx, body)
if err!=nil{
fmt.Println("Error in CreateSmtpTemplate ",err.Error())
return
}
fmt.Println( "CreateSmtpTemplate, response:",resp,"CreateSmtpTemplate Model:",obj)
return
}
# load the gem
require 'sib-api-v3-sdk'
# setup authorization
SibApiV3Sdk.configure do |config|
# Configure API key authorization: api-key
config.api_key['api-key'] = 'YOUR API KEY'
end
api_instance = SibApiV3Sdk::TransactionalEmailsApi.new
smtp_template = SibApiV3Sdk::CreateSmtpTemplate.new
smtp_template = {
'sender'=> {'name'=>'John Doe','email'=>'[email protected]'},
'templateName'=> 'Example Template',
'htmlContent'=> '<html><body><h1>This is my first transactional email</h1></body></html>',
'subject'=> 'New Subject',
'replyTo'=> '[email protected]',
'toField'=> '[email protected]',
'isActive'=> true,
'attachmentUrl'=> 'https://example.net/upload-file'
}
begin
#Create an email template
result = api_instance.create_smtp_template(smtp_template)
p result
rescue SibApiV3Sdk::ApiError => e
puts "Exception when calling TransactionalEmailsApi->create_smtp_template: #{e}"
end