API
Render Template
Render a template with dynamic variables
GET
/
v1
/
render
/
{uid}
cURL
curl --request GET \
--url https://api.example.com/v1/render/{uid}import requests
url = "https://api.example.com/v1/render/{uid}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/v1/render/{uid}', 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.example.com/v1/render/{uid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/render/{uid}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/render/{uid}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/render/{uid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"requestId": "req_1234"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"requestId": "req_1234"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "<string>",
"requestId": "req_1234"
}
}This endpoint renders a template with the provided dynamic variables. The response is the rendered image file.
Path Parameters
string
required
The unique identifier of the template to render
Query Parameters
object
An object containing key-value pairs of variable names and their values. The keys should match the variable names defined in the template.
Response
The endpoint returns the rendered image file directly. On success, you’ll receive the image data with the appropriate content type header.Examples
Here’s how to use the render endpoint with different variable types:# Basic text variable
https://api.sendbetter.co/v1/render/template_abc123?text_headline=Welcome
# Multiple variables
https://api.sendbetter.co/v1/render/template_abc123
?text_headline=Welcome
&image_logo=https://example.com/logo.png
# Download rendered image
curl "https://api.sendbetter.co/v1/render/template_abc123?text_headline=Welcome" -o output.png
import requests
# Variables
variables = {
'text_headline': 'Welcome',
'image_logo': 'https://example.com/logo.png'
}
# Build URL with query parameters
template_id = 'template_abc123'
base_url = f'https://api.sendbetter.co/v1/render/{template_id}'
response = requests.get(base_url, params=variables)
# Save the rendered image
with open('output.png', 'wb') as f:
f.write(response.content)
// Variables
const variables = {
text_headline: 'Welcome',
image_logo: 'https://example.com/logo.png'
};
// Build URL with query parameters
const templateId = 'template_abc123';
const url = new URL(`https://api.sendbetter.co/v1/render/${templateId}`);
Object.keys(variables).forEach(key => {
url.searchParams.append(key, variables[key]);
});
// Download the rendered image
fetch(url)
.then(response => response.blob())
.then(blob => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'output.png';
a.click();
});
Error Responses
{
"error": {
"code": "NOT_FOUND",
"message": "Template not found",
"requestId": "req_abc123"
}
}
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid variable value",
"requestId": "req_xyz789"
}
}
⌘I
cURL
curl --request GET \
--url https://api.example.com/v1/render/{uid}import requests
url = "https://api.example.com/v1/render/{uid}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/v1/render/{uid}', 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.example.com/v1/render/{uid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/render/{uid}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v1/render/{uid}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/render/{uid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"requestId": "req_1234"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"requestId": "req_1234"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "<string>",
"requestId": "req_1234"
}
}