Update Template
curl --request POST \
--url https://cloudapi.mailercloud.com/v1/templates/update \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "AXY",
"categoryId": 0,
"html": "string",
"name": "string",
"plainText": "string"
}
'import requests
url = "https://cloudapi.mailercloud.com/v1/templates/update"
payload = {
"id": "AXY",
"categoryId": 0,
"html": "string",
"name": "string",
"plainText": "string"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({id: 'AXY', categoryId: 0, html: 'string', name: 'string', plainText: 'string'})
};
fetch('https://cloudapi.mailercloud.com/v1/templates/update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cloudapi.mailercloud.com/v1/templates/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 'AXY',
'categoryId' => 0,
'html' => 'string',
'name' => 'string',
'plainText' => 'string'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cloudapi.mailercloud.com/v1/templates/update"
payload := strings.NewReader("{\n \"id\": \"AXY\",\n \"categoryId\": 0,\n \"html\": \"string\",\n \"name\": \"string\",\n \"plainText\": \"string\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"message": "updated template successfully"
}{
"error": "html is a required field"
}{
"errors": [
{
"field": "",
"message": "Authorization failed"
}
]
}Update Template
This API allows you to update an existing email template in Mailercloud. You can update a template either by providing its id or by using the templateName — at least one of them is required.
Required Fields:
-
id: The unique ID of the template you want to update. (Required if templateName is not provided.)
-
templateName: The name of the template you want to update. (Required if id is not provided.)
-
name: The new name for the template (maximum 100 characters). The name must be unique.
-
html: The updated HTML content of the template.
Optional Fields:
-
categoryId: Specifies the category ID of the template, you can get it from the Get Template Categories API. It would be 0 by default.
-
plainText: Specifies the plain text content
POST
/
templates
/
update
Update Template
curl --request POST \
--url https://cloudapi.mailercloud.com/v1/templates/update \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "AXY",
"categoryId": 0,
"html": "string",
"name": "string",
"plainText": "string"
}
'import requests
url = "https://cloudapi.mailercloud.com/v1/templates/update"
payload = {
"id": "AXY",
"categoryId": 0,
"html": "string",
"name": "string",
"plainText": "string"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({id: 'AXY', categoryId: 0, html: 'string', name: 'string', plainText: 'string'})
};
fetch('https://cloudapi.mailercloud.com/v1/templates/update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cloudapi.mailercloud.com/v1/templates/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => 'AXY',
'categoryId' => 0,
'html' => 'string',
'name' => 'string',
'plainText' => 'string'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cloudapi.mailercloud.com/v1/templates/update"
payload := strings.NewReader("{\n \"id\": \"AXY\",\n \"categoryId\": 0,\n \"html\": \"string\",\n \"name\": \"string\",\n \"plainText\": \"string\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"message": "updated template successfully"
}{
"error": "html is a required field"
}{
"errors": [
{
"field": "",
"message": "Authorization failed"
}
]
}