Skip to main content

Turning an Existing JSON Edit into a Reusable Template

P
Written by Peace Aisosa

If you already have a working JSON edit and want to turn it into a reusable Template (so you can render it repeatedly with different merge data), there are two ways to do it: visually in the Studio, or directly via the API.

Option 1: Using the Studio (no code)

This is the quickest way if you'd rather work visually.

  • In the left sidebar, under STUDIO, click My Templates.

  • Click the + Blank button in the top right. This opens a new blank project in the Studio editor.

  • In the editor, click the View JSON icon (the </> symbol) in the left-hand toolbar.

  • The JSON Editor panel opens. Select everything currently in there and paste your own JSON edit over it.

  • Give your template a name using the name field at the top left. The template saves automatically, and a tick will appear beside it confirming the save.

  • Your template now appears under My Templates, with its Template ID shown beneath the name. Copy that ID using the icon next to it, and use it to render the template via the API whenever you need.

Option 2: Using the API

Send a POST request to the templates endpoint, with your edit wrapped in a template field alongside a name:


Bash

curl -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"name": "My Template",
"template": {
"timeline": { ... },
"output": { "format": "mp4", "size": { "width": 1080, "height": 1920 } }
}
}' \
https://api.shotstack.io/edit/v1/templates

Use v1 for production or stage for sandbox. The response returns a template ID.


To render it later, POST that ID to the render endpoint, along with any merge fields you want to swap in:


Bash

curl -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"id": "YOUR_TEMPLATE_ID",
"merge": [
{ "find": "NAME", "replace": "World" }
]
}' \
https://api.shotstack.io/edit/v1/templates/render

Merge fields are optional. If your JSON contains placeholders written in double curly braces, like {{ NAME }}, the merge array replaces them at render time, which is what makes a template reusable.


Full documentation here: Templates.

Did this answer your question?