Skip to main content
Legacy Endpoint — This is a legacy endpoint that supports template-based video generation with scene-by-scene control. The V3 APIs do not offer scene-by-scene generation. Use this endpoint only if your workflow requires template-driven video creation with variable substitution.

Overview

POST https://api.heygen.com/v2/template/{template_id}/generate Generates a video based on the specified template, including scene IDs to define the sequence of scenes and variable values for replacement.

Authentication

HeaderValue
x-api-keyYour HeyGen API key
Content-Typeapplication/json

Path Parameters

ParameterTypeRequiredDescription
template_idstringYesUnique identifier of the template.

Request Body

ParameterTypeRequiredDescription
variablesstring (JSON)YesDynamic variables used within the template.
captionbooleanNoEnable captions in the video. Default: false.
titlestringNoTitle of the video.
dimensionobjectNoCustom output dimensions. Must match the template’s aspect ratio.
dimension.widthintegerNoWidth of the output video. Default: 1280.
dimension.heightintegerNoHeight of the output video. Default: 720.
include_gifbooleanNoInclude a GIF preview URL in the webhook response. Default: false.
enable_sharingbooleanNoMake the video publicly shareable immediately after creation.
folder_idstringNoFolder ID where the video is stored.
brand_voice_idstringNoBrand Glossary ID for applying predefined translation and pronunciation rules (translation exclusions, enforced terms, vocabulary mappings, tone preferences).
callback_urlstringNoURL to notify when video rendering is complete. If both a webhook and callback_url are configured, events are sent to both.
keep_text_vertically_centeredbooleanNoWhen true, replaced text elements are vertically centered based on their actual rendered height.

Example Request

POST /v2/template/YOUR_TEMPLATE_ID/generate

{
  "title": "My Template Video",
  "caption": false,
  "dimension": {
    "width": 1280,
    "height": 720
  },
  "variables": {
    "script": {
      "name": "script",
      "type": "text",
      "properties": {
        "content": "Hello, welcome to our product demo."
      }
    },
    "headline": {
      "name": "headline",
      "type": "text",
      "properties": {
        "content": "Product Overview"
      }
    }
  }
}

Response

200 — Success

{
  "error": null,
  "data": {
    "video_id": "763fca2469b98a65b351eqr8c449f4e8"
  }
}
FieldTypeDescription
errorstring | nullError message if the request fails; null on success.
data.video_idstringUnique identifier of the generated video.

Full API Reference

For complete details, see the Generate Video from Template (V2) endpoint documentation.