Skip to main content

Update template

This method edits a template. Only the fields you pass are changed.

URL
https://dashboard.skry.be/api/templates/update-template.php

PARAMETERS(POST)

  1. api_key your API key.
  2. template_id the numeric id of the template, as returned by Get templates.
  3. name the new name of the template. (optional)
  4. html_text the new HTML of the template. (optional)
  5. plain_text the plain-text version. (optional)
  6. from_name the From name to save with the template. (optional)
  7. from_email the From email to save with the template. Its domain must be one of the brand's allowed sending domains. (optional)
  8. reply_to the Reply-to address to save with the template. (optional)
  9. editor the editor the app opens the template in: html or dragdrop. (optional)

RESPONSE (JSON)

Success: the updated template, without its HTML.

{
"id": 12,
"name": "Monthly newsletter",
"from_name": "Acme",
"from_email": "news@acme.com",
"reply_to": "hello@acme.com",
"editor": "html"
}
  • id the template's numeric id
  • name the template's name
  • from_name, from_email, reply_to the sender details saved with the template (empty strings if not set)
  • editor which editor the app opens the template in: html (the code editor) or dragdrop

Error: No data passed

Error: API key not passed

Error: Invalid API key

Error: Brand does not exist

Error: Template ID not passed

Error: Template does not exist

Error: Nothing to update

Error: A field is too long: <field> (at most <n> characters)

Error: Template name cannot be empty

Error: HTML cannot be empty

Error: Invalid from_email

Error: Unauthorised From email domain

Error: Invalid reply_to

Error: editor must be html or dragdrop

Error: Unable to update template

name can be up to 500 characters, and from_name, from_email and reply_to up to 100 each. When a field is too long, the error names it, eg. A field is too long: from_name (at most 100 characters).

Unauthorised From email domain means from_email isn't on one of the brand's allowed sending domains (the same check the app makes when you save a template).

Brand does not exist is returned when the key isn't tied to a brand, for example the main account's key.

Passing a field as an empty string clears it, except name and html_text, which can't be empty, and editor, which must be html or dragdrop.

EXAMPLES

Example request in JavaScript with fetch API
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("api_key", "<YOUR_API_KEY>");
urlencoded.append("template_id", "12");
urlencoded.append("name", "Monthly newsletter (v2)");

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};

fetch("https://dashboard.skry.be/api/templates/update-template.php", requestOptions)
.then(response => response.text())
// Success is JSON; errors are plain text
.then(text => {
try { console.log(JSON.parse(text)); }
catch (e) { console.log('error', text); }
})
.catch(error => console.log('error', error));
Example request in JavaScript with axios
const axios = require('axios');
const qs = require('qs');
let data = qs.stringify({
'api_key': '<YOUR_API_KEY>',
'template_id': '12',
'name': 'Monthly newsletter (v2)'
});

let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://dashboard.skry.be/api/templates/update-template.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data : data
};

axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});