Update a template
This endpoint allows you to update an existing template by modifying its layers, properties, or content.
You can update specific layers without affecting the rest of the template, making it efficient for partial updates.
Key features:
- Update only the layers/pages you need to change
- Modify template properties like name, dimensions, and descriptions
- Add new layers to existing pages
- Update text, images, shapes, and other layer properties
- Unchanged layers and pages remain intact
After updating the template, the changes will be reflected in the Editor and any future renders created from this template.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”id string REQUIRED
The template ID of the template you want to update (passed in the URL path).
Query Parameters
Section titled “Query Parameters”replaceLayers boolean OPTIONAL
When set to true, layers not included in the request will be removed from the template.
Default is false (partial update mode - existing layers not in the request remain unchanged).
Use this when you want to completely replace the template’s layers rather than just updating specific ones.
Body Parameters
Section titled “Body Parameters”name string OPTIONAL
The name of the template.
width number OPTIONAL
The width of the template in pixels (max 5000).
height number OPTIONAL
The height of the template in pixels (max 5000).
description string OPTIONAL
A description of the template.
layers array OPTIONAL
An array of layer objects to update.
Only include the layers you want to modify or add.
Each layer must specify the layer property (layer name identifier) and the layer type (image, text, shape).
pages array OPTIONAL
For multi-page templates, an array of page objects containing the layers to update.
Only include the pages and layers you want to modify.
For all the available layer properties, see the Layer Parameters section.
Sample Requests
Section titled “Sample Requests”Update specific layers in a template
Section titled “Update specific layers in a template”Here’s a sample request to update only specific layers:
PUT /v1/template/{id}fetch(`https://api.templated.io/v1/template/${template_id}`, { method: 'PUT', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ "layers": [ { "layer": "event-name", "type": "text", "text": "UPDATED EVENT NAME", "color": "#ff0000" }, { "layer": "background-image", "type": "image", "image_url": "https://images.unsplash.com/photo-new-image-id" } ] })}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));import requests
api_key = 'API_KEY'template_id = 'template_id'url = f'https://api.templated.io/v1/template/{template_id}'
headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
data = { "layers": [ { "layer": "event-name", "type": "text", "text": "UPDATED EVENT NAME", "color": "#ff0000" }, { "layer": "background-image", "type": "image", "image_url": "https://images.unsplash.com/photo-new-image-id" } ]}
response = requests.put(url, json=data, headers=headers)
if response.status_code == 200: print(response.json())else: print('Request failed. Response code:', response.status_code) print(response.text)import java.net.HttpURLConnection;import java.net.URL;import java.io.OutputStream;import java.io.BufferedReader;import java.io.InputStreamReader;
public class UpdateTemplate { public static void main(String[] args) { try { String apiKey = "API_KEY"; String templateId = "template_id"; String url = "https://api.templated.io/v1/template/" + templateId;
String jsonData = """ { "layers": [ { "layer": "event-name", "type": "text", "text": "UPDATED EVENT NAME", "color": "#ff0000" }, { "layer": "background-image", "type": "image", "image_url": "https://images.unsplash.com/photo-new-image-id" } ] } """;
URL apiUrl = new URL(url); HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection(); connection.setRequestMethod("PUT"); connection.setRequestProperty("Authorization", "Bearer " + apiKey); connection.setRequestProperty("Content-Type", "application/json"); connection.setDoOutput(true);
try (OutputStream os = connection.getOutputStream()) { byte[] input = jsonData.getBytes("utf-8"); os.write(input, 0, input.length); }
int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader in = new BufferedReader( new InputStreamReader(connection.getInputStream())); String inputLine; StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); } else { System.out.println("Request failed. Response Code: " + responseCode); } } catch (Exception e) { e.printStackTrace(); } }}<?php$apiKey = 'API_KEY';$templateId = 'template_id';
$data = [ "layers" => [ [ "layer" => "event-name", "type" => "text", "text" => "UPDATED EVENT NAME", "color" => "#ff0000" ], [ "layer" => "background-image", "type" => "image", "image_url" => "https://images.unsplash.com/photo-new-image-id" ] ]];
$url = "https://api.templated.io/v1/template/{$templateId}";
$options = [ 'http' => [ 'header' => "Authorization: Bearer {$apiKey}\r\n" . "Content-Type: application/json\r\n", 'method' => 'PUT', 'content' => json_encode($data) ]];
$context = stream_context_create($options);$result = file_get_contents($url, false, $context);
if ($result === FALSE) { echo "Error updating template";} else { $data = json_decode($result, true); print_r($data);}?>Update template properties and layers
Section titled “Update template properties and layers”You can also update template metadata along with layers:
fetch(`https://api.templated.io/v1/template/${template_id}`, { method: 'PUT', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ "name": "Updated Template Name", "description": "This template has been updated", "width": 1920, "height": 1080, "layers": [ { "layer": "title", "type": "text", "text": "New Title Text", "font_size": "64px", "color": "#ffffff" } ] })}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));import requests
api_key = 'API_KEY'template_id = 'template_id'url = f'https://api.templated.io/v1/template/{template_id}'
headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
data = { "name": "Updated Template Name", "description": "This template has been updated", "width": 1920, "height": 1080, "layers": [ { "layer": "title", "type": "text", "text": "New Title Text", "font_size": "64px", "color": "#ffffff" } ]}
response = requests.put(url, json=data, headers=headers)
if response.status_code == 200: print(response.json())else: print('Request failed. Response code:', response.status_code) print(response.text)Update multi-page template
Section titled “Update multi-page template”For multi-page templates, use the pages array:
fetch(`https://api.templated.io/v1/template/${template_id}`, { method: 'PUT', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ "pages": [ { "page": "page-1", "layers": { "title": { "layer": "title", "type": "text", "text": "Updated Page 1 Title" } } }, { "page": "page-2", "layers": { "subtitle": { "layer": "subtitle", "type": "text", "text": "Updated Page 2 Subtitle" } } } ] })}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));import requests
api_key = 'API_KEY'template_id = 'template_id'url = f'https://api.templated.io/v1/template/{template_id}'
headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
data = { "pages": [ { "page": "page-1", "layers": { "title": { "layer": "title", "type": "text", "text": "Updated Page 1 Title" } } }, { "page": "page-2", "layers": { "subtitle": { "layer": "subtitle", "type": "text", "text": "Updated Page 2 Subtitle" } } } ]}
response = requests.put(url, json=data, headers=headers)
if response.status_code == 200: print(response.json())else: print('Request failed. Response code:', response.status_code) print(response.text)Replace all layers in a template
Section titled “Replace all layers in a template”Use replaceLayers=true when you want to completely replace the template’s layers. Any layers not included in your request will be removed:
PUT /v1/template/{id}?replaceLayers=true// This will replace ALL layers in the template with only the layers specified below// Any existing layers not in this array will be REMOVEDfetch(`https://api.templated.io/v1/template/${template_id}?replaceLayers=true`, { method: 'PUT', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ "layers": [ { "layer": "new-title", "type": "text", "text": "My New Title", "x": 100, "y": 100, "width": 400, "height": 50, "font_size": "48px", "color": "#000000" }, { "layer": "new-image", "type": "image", "image_url": "https://images.unsplash.com/photo-example", "x": 100, "y": 200, "width": 400, "height": 300 } ] })}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));import requests
api_key = 'API_KEY'template_id = 'template_id'# Add ?replaceLayers=true to remove layers not in the requesturl = f'https://api.templated.io/v1/template/{template_id}?replaceLayers=true'
headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
# This will replace ALL layers - any existing layers not listed here will be removeddata = { "layers": [ { "layer": "new-title", "type": "text", "text": "My New Title", "x": 100, "y": 100, "width": 400, "height": 50, "font_size": "48px", "color": "#000000" }, { "layer": "new-image", "type": "image", "image_url": "https://images.unsplash.com/photo-example", "x": 100, "y": 200, "width": 400, "height": 300 } ]}
response = requests.put(url, json=data, headers=headers)
if response.status_code == 200: print(response.json())else: print('Request failed. Response code:', response.status_code) print(response.text)Response
Section titled “Response”The API returns a JSON object with the updated template details:
{ "id": "template-id-123", "name": "Updated Template Name", "description": "This template has been updated", "width": 1920, "height": 1080, "layersCount": 15, "pagesCount": 1, "updatedAt": "2024-01-15T10:30:00Z", "createdAt": "2024-01-01T08:00:00Z"}Error Responses
Section titled “Error Responses”| Status Code | Description |
|---|---|
| 401 | Not authorized - Invalid or missing API key |
| 403 | Forbidden - You don’t have permission to update this template or account is blocked |
| 404 | Not Found - Template not found |
| 500 | Internal Server Error - An unexpected error occurred |