Replace Video in Template
Easily replace video elements within template using API
Welcome to Video Replacement!
In this guide, we will learn how to replace videos within a template and generate a video. The Template API allows you to dynamically modify video elements to create customized videos that suit your specific needs.

Video Properties
When replacing videos in templates, you can use the following properties to customize how the video appears:
Creating Template through the Interface
To create templates, visit the Template page and click on "Create Template". You can then set variables and change variable names using the toolbar's API icon.
Variable Assignment:
As you can see, we have assigned a variable name to our video element. In this tutorial, we will demonstrate how to change this video using the Template API.

Step 1: Get a List of Your Templates
Using the following API request you will get a list of your templates that you have created in the interface, obtain your template_id from here.
curl --location 'https://api.konpro.ai/v1/templates' \
--header 'accept: application/json' \
--header 'x-api-key: <your-api-key>'Step 2: Retrieve Template Elements
To retrieve template elements for a specific template, use this API request. Get the variable you want to change from here.
curl --location 'https://api.konpro.ai/v1/template/<template_id>' \
--header 'accept: application/json' \
--header 'x-api-key: <your-api-key>'Step 3: Modify Template Elements and Generate Video
To change template elements and generate videos, you will need to submit an API request as follows. In the request body, specify the elements you want to modify by providing the appropriate object within the variables section.
curl --location 'https://api.konpro.ai/v1/template/<template_id>/generate' \
--header 'x-api-key: <your-api-key>' \
--header 'Content-Type: application/json' \
--data '{
"caption": false,
"title": "New Video",
"variables": {
"shopping_video": {
"name": "shopping_video",
"type": "video",
"properties": {
"url": "https://example.com/video.mp4",
"asset_id": null,
"play_style": "loop",
"fit": "contain"
}
}
}
}'You will receive a video_id after your request. To check the video's status and retrieve further details, you can use the video_status API endpoint.
Success:
And using the Template API, we changed our video and generated our new video, here is the before and after:

You can also use images and videos interchangeably within templates. Here is how to replace an image with a video or vice versa.