API & Integration -> Quick Start
Rearrange scenes in a template
This example shows how to modify and reorder the content within a template before rendering.
Step 1Create a template
Some situations may require you to edit a template based on a dynamic number of elements. Take for example this slideshow video where the user can put in however many photos they want, and the template adjusts accordingly.With the right template structure, you can set up a single template that is compatible with any amount of scenes. Click the
Open in editorbutton below to open this template in the editor and take a close look at how it is organized:
Step 2Render a single scene
You'll notice that the template has a composition named
Scenes, with nested compositions
Title-Scene,
Intro-Text,
Intro-Dedication, etc. Each of these scenes are placed on the same track.With this structure in place, the scenes can now be referred to as reusable components. Say we only want to include the
Single-Photo-With-Captionscene with a different image and caption. This can be done using the
copyoperator. Essentially, this API call replaces the content of the
Scenescomposition with a copy of one of its elements.
curl -X POST https://api.creatomate.com/v2/renders \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY_HERE" \ -d '{ "template_id": "YOUR_TEMPLATE_ID_HERE", "modifications": { "Scenes": [ { "copy": "Single-Photo-With-Caption", "1PC-Photo": "https://cdn.creatomate.com/demo/tribute-mpp-01.jpg", "1PC-Caption": "A different caption" } ] } }'
Step 3Generate the final video
Here's a more comprehensive example, made up of 5 scenes from the template. As you can see, you can refer to scenes regardless of their original order. The
Single-Photo-With-Backdropscene is used multiple times.Let's consider how this API request might be used as part of an application. First, a user submits any number of photos. The app can then distribute the images over the available scenes in the template (one
Three-Photosscene and two
Single-Photo-With-Backdropscenes). In this example, the intro
Intro-Dedicationand outro
Farewell-Messagescenes are included as well.
curl -X POST https://api.creatomate.com/v2/renders \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY_HERE" \ -d '{ "template_id": "YOUR_TEMPLATE_ID_HERE", "modifications": { "Scenes": [ { "copy": "Intro-Dedication", "ID-Name": "Fluff McPaws", "ID-Date": "1.1.2000 ~ 1.1.2026" }, { "copy": "Single-Photo-With-Backdrop", "SPB-Photo": "https://cdn.creatomate.com/demo/tribute-2p-01.jpg" }, { "copy": "Three-Photos", "3P-Photo-1": "https://cdn.creatomate.com/demo/tribute-3p-01.jpg", "3P-Photo-2": "https://cdn.creatomate.com/demo/tribute-3p-02.jpg", "3P-Photo-3": "https://cdn.creatomate.com/demo/tribute-3p-03.jpg" }, { "copy": "Single-Photo-With-Backdrop", "SPB-Photo": "https://cdn.creatomate.com/demo/tribute-spb.jpg" }, { "copy": "Farewell-Message", "FM-Text": "Wishing her all the high places to perch and no vacuum cleaners in sight." } ] } }'