Get Notification Template Preview
Returns an HTML preview for a specified notification template.
Request
Query parameters
| Parameter | Type | Description |
|---|---|---|
group |
String |
Group of this notification. The system has an |
templateType |
String |
Type of the notification template. System has the following template types: |
type |
String |
Notification type – |
content |
String |
Notification text. |
isSubject |
Boolean |
Whether the text is the email subject. |
Request body
Request body contains the notification text, as well as settings that define the appearance of the generated notification preview.
{
"group": "auth",
"templateType": "email",
"type": "single",
"content": "Hello,\nTo restore your password, follow the link below:\n\n{{emailLink}}",
"isSubject": false
}
Response
Returns an HTML markup of the notification template that’s shown in the web interface.
The preview markup is wrapped in the JSON object and is stored in its preview field.
{
"preview": "<p>Hello,\nTo restore your password, follow the link below:</p>\n"
}
This notification template looks like this in the web interface:
Example
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/notification-templates/preview
curl -X PATCH $url -u $login:$password \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"group": "auth",
"templateType": "email",
"type": "single",
"content": "Hello,\nTo restore your password, follow the link below:\n\n{{emailLink}}",
"isSubject": false
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/notification-templates/preview";
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);
let data = JSON.stringify({
"group": "auth",
"templateType": "email",
"type": "single",
"content": "Hello,\nTo restore your password, follow the link below:\n\n{{emailLink}}",
"isSubject": false
});
let requestOptions = {
method: "PATCH",
headers: headers,
body: data
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
const http = require("http");
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/notification-templates/preview";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "PATCH",
"hostname": saymonHostname,
"headers": {
"Authorization": auth,
"Content-Type": "application/json"
},
"path": path
};
let req = http.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
let data = JSON.stringify({
"group": "auth",
"templateType": "email",
"type": "single",
"content": "Hello,\nTo restore your password, follow the link below:\n\n{{emailLink}}",
"isSubject": false
});
req.write(data);
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/notification-templates/preview"
body = {
"group": "auth",
"templateType": "email",
"type": "single",
"content": "Hello,\nTo restore your password, follow the link below:\n\n{{emailLink}}",
"isSubject": false
}
response = requests.request("PATCH", url, json=body, auth=(login, password))
print(response.text)