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)
api_keyyour API key.template_idthe numeric id of the template, as returned by Get templates.namethe new name of the template. (optional)html_textthe new HTML of the template. (optional)plain_textthe plain-text version. (optional)from_namethe From name to save with the template. (optional)from_emailthe From email to save with the template. Its domain must be one of the brand's allowed sending domains. (optional)reply_tothe Reply-to address to save with the template. (optional)editorthe editor the app opens the template in:htmlordragdrop. (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"
}
idthe template's numeric idnamethe template's namefrom_name,from_email,reply_tothe sender details saved with the template (empty strings if not set)editorwhich editor the app opens the template in:html(the code editor) ordragdrop
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
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));
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);
});