Update an email template

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 templateId = 2; 

let smtpTemplate = new SibApiV3Sdk.UpdateSmtpTemplate();
smtpTemplate.sender = {"name":"John Doe","email":"[email protected]"};
smtpTemplate.templateName = "Updated Example Template";
smtpTemplate.htmlContent = "<html><body><h1>This is my updated transactional email</h1></body></html>";
smtpTemplate.subject = "Example Updated Subject";
smtpTemplate.replyTo = "[email protected]";
smtpTemplate.toField = "[email protected]";
smtpTemplate.isActive = true;
smtpTemplate.attachmentUrl = "https://example.net/upload-file";

apiInstance.updateSmtpTemplate(templateId, smtpTemplate).then(function() {
  console.log('API called successfully.');
}, 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
);
$templateId = 1;
$smtpTemplate = new \SendinBlue\Client\Model\UpdateSmtpTemplate();
$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 {
    $apiInstance->updateSmtpTemplate($templateId, $smtpTemplate);
} catch (Exception $e) {
    echo 'Exception when calling TransactionalEmailsApi->updateSmtpTemplate: ', $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))
template_id = 1
sender = {"name":"John Doe","email":"[email protected]"}
template_name = "Updated Example Template"
html_content = "<html><body><h1>This is my updated transactional email</h1></body></html>"
subject = "Example Updated 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.UpdateSmtpTemplate(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_instance.update_smtp_template(template_id, smtp_template)
except ApiException as e:
    print("Exception when calling SMTPApi->update_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 templateId = 1; 

let smtpTemplate = new SibApiV3Sdk.UpdateSmtpTemplate();

smtpTemplate.sender = {"name":"John Doe","email":"[email protected]"};
smtpTemplate.templateName = "Updated Example Template";
smtpTemplate.htmlContent = "<html><body><h1>This is my updated transactional email</h1></body></html>";
smtpTemplate.subject = "Example Updated Subject";
smtpTemplate.replyTo = "[email protected]";
smtpTemplate.toField = "[email protected]";
smtpTemplate.isActive = true;
smtpTemplate.attachmentUrl = "https://example.net/upload-file";

apiInstance.updateSmtpTemplate(templateId, smtpTemplate).then(function() {
  console.log('API called successfully.');
}, 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();
            Long templateId = 1L;
            UpdateSmtpTemplateSender sender = new UpdateSmtpTemplateSender();
            sender.setEmail("[email protected]");
            sender.setName("John Doe");
            UpdateSmtpTemplate smtpTemplate = new UpdateSmtpTemplate();
            smtpTemplate.setSender(sender);
            smtpTemplate.setTemplateName("Updated Example Template");
            smtpTemplate.setHtmlContent("<html><body><h1>This is my updated transactional email</h1></body></html>");
            smtpTemplate.setSubject("Example Updated Subject");
            smtpTemplate.setReplyTo("[email protected]");
            smtpTemplate.setToField("[email protected]");
            smtpTemplate.setIsActive(true);
            smtpTemplate.setAttachmentUrl("https://example.net/upload-file");
            api.updateSmtpTemplate(templateId, smtpTemplate);
        } 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();
            long? templateId = 235;
            string tag = null;
            string senderName = "John Doe";
            string senderEmail = "[email protected]";
            UpdateSmtpTemplateSender sender = new UpdateSmtpTemplateSender(senderName, senderEmail);
            string templateName = "Updated Example Template";
            string htmlContent = "<html><body><h1>This is my updated transactional email</h1></body></html>";
            string htmlUrl = null;
            string subject = "Example Updated Subject";
            string replyTo = "[email protected]";
            string toField = "[email protected]";
            string attachmentUrl = "https://example.net/upload-file";
            bool? isActive = true;
            try
            {
                var smtpTemplate = new UpdateSmtpTemplate(tag, sender, templateName, htmlContent, htmlUrl, subject, replyTo, toField, attachmentUrl, isActive);
                apiInstance.UpdateSmtpTemplate(templateId, smtpTemplate);
                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)
    templateId := int64(5)
    body := UpdateSmtpTemplate{
        Tag: "My Tag",
        Sender: &UpdateSmtpTemplateSender{
            Name:  "John Doe",
            Email: "[email protected]",
        },
        TemplateName: "TemplateName",
        HtmlContent:  "<html><body><h1>This is my updated transactional email</h1></body></html>",
        Subject:      "Example Updated Subject",
        ReplyTo:      "[email protected]",
    ToField:      "[email protected]",
    IsActive: true,
    }
    resp, err := sib.TransactionalEmailsApi.UpdateSmtpTemplate(ctx, body, templateId)
    if err!=nil{
        fmt.Println("Error in UpdateSmtpTemplate ",err.Error())
        return
    }
    fmt.Println( "UpdateSmtpTemplate, response:",resp)
    return 
}
Language
Authentication
Header
Response
Click Try It! to start a request and see the response here!