Replace Video In Template
In this guide, you'll learn how to replace videos within a template video. You can view the example template video here.
Retrieve Template Variables
You can fetch the template variables using the following API call:
curl -X GET 'https://api.heygen.com/v1/template.get?video_id=<video_id>' \
-H 'X-Api-Key: <your-api-key>'
{
"code": 100,
"data": {
"scenes": [
{
"variables": [
{
"name": "video_0",
"properties": [
{
"default": "<url>",
"name": "link"
},
{
"default": "none",
"name": "play_style"
}
],
"type": "video"
}
]
}
],
"template_id": "c2735a01d43343babb9138528a68cd46",
"video_id": "c2735a01d43343babb9138528a68cd46"
},
"message": "Success"
}
Customize Template Variables and Generate Video
Now, you can proceed to replace the video's link
variable in your template. Use the following API request:
curl --request POST \
--url https://api.heygen.com/v1/template.generate \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <your-api-key>' \
--data '
{
"template_id": "c2735a01d43343babb9138528a68cd46",
"title": "test sub video",
"test": true,
"variables": [
{
"properties": {
"link": "https://resource.heygen.com/video/ad50df8f597e4d889dec70562f57c67f/1920x1080.mp4",
"play_style": "fit"
},
"name": "video_0"
}
]
}
'
View the Result
Let's take a look at how a template video can be transformed. Below, you'll find the original template video and the video after customizing it.
Here's the original template video:
And here's the video after customizing it, where we've replaced the video within the template:
As you can see, with HeyGen's API, you can seamlessly replace video content within templates, offering endless possibilities for customization and personalization.
Updated 3 months ago