Render a template
curl --request POST \
--url https://api.senderkit.com/v1/templates/{slug}/render \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vars": {
"name": "Ada"
}
}
'import requests
url = "https://api.senderkit.com/v1/templates/{slug}/render"
payload = { "vars": { "name": "Ada" } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({vars: {name: 'Ada'}})
};
fetch('https://api.senderkit.com/v1/templates/{slug}/render', 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://api.senderkit.com/v1/templates/{slug}/render",
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([
'vars' => [
'name' => 'Ada'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.senderkit.com/v1/templates/{slug}/render"
payload := strings.NewReader("{\n \"vars\": {\n \"name\": \"Ada\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.senderkit.com/v1/templates/{slug}/render")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vars\": {\n \"name\": \"Ada\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.senderkit.com/v1/templates/{slug}/render")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vars\": {\n \"name\": \"Ada\"\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {},
"missing": [
"<string>"
]
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}Templates
Render a template
Render the template’s current published version with the supplied variables, without sending. Returns the rendered output for the template’s channel plus any variable paths that were referenced but not provided.
POST
/
v1
/
templates
/
{slug}
/
render
Render a template
curl --request POST \
--url https://api.senderkit.com/v1/templates/{slug}/render \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vars": {
"name": "Ada"
}
}
'import requests
url = "https://api.senderkit.com/v1/templates/{slug}/render"
payload = { "vars": { "name": "Ada" } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({vars: {name: 'Ada'}})
};
fetch('https://api.senderkit.com/v1/templates/{slug}/render', 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://api.senderkit.com/v1/templates/{slug}/render",
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([
'vars' => [
'name' => 'Ada'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.senderkit.com/v1/templates/{slug}/render"
payload := strings.NewReader("{\n \"vars\": {\n \"name\": \"Ada\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.senderkit.com/v1/templates/{slug}/render")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vars\": {\n \"name\": \"Ada\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.senderkit.com/v1/templates/{slug}/render")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vars\": {\n \"name\": \"Ada\"\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {},
"missing": [
"<string>"
]
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}{
"error": {
"code": "invalid_request",
"message": "<string>",
"issues": [
{}
],
"limit": 123
}
}Authorizations
API key with an sk_live_ or sk_test_ prefix.
Path Parameters
Template slug.
Body
application/json
Variable values to interpolate into the template.
Response
Rendered template output.
Available options:
email, sms, push, web-push Rendered fields for the channel. Email -> {subject, preheader, html, text}; SMS -> {body}; push -> {title, body, data, badge, sound}; web push -> {title, body, icon, clickUrl, data, badge}.
Variable paths referenced by the template but not supplied.
⌘I