Skip to main content

Overview

A template is a video layout you build once in HeyGen Studio, with named slots for text, media, avatars, and voices. Use the API to find your templates, read what each one exposes, and generate videos from them:
Templates are created and edited in the HeyGen web editor. Only templates that have variables defined appear in the list, and the detail endpoint supports templates built in the current editor format (draft version 4). Create a template in HeyGen Studio first, then drive it from the API.

List Templates

  • Endpoint: GET /v3/templates
  • Purpose: Return a paginated list of API-ready templates in the workspace.
Response

Query Parameters

ParameterTypeRequiredDefaultDescription
limitintegerNo100Templates per page, 1100.
tokenstringNoOpaque pagination cursor from a previous response’s next_token.

Get a Template

  • Endpoint: GET /v3/templates/{template_id}
  • Purpose: Return template details including its variable schema (with current default values) and scene list.
Response
The variables object is keyed by variable name, and each value is returned in the same shape a generate request accepts — so you can take this response, replace the default values with your own, and submit it back to render a video. The content, asset, and other fields hold the template’s current defaults; a text variable may come back empty when the template leaves it unfilled.

Variable Types

Every variable has a type discriminator that determines the rest of its fields:

text

FieldTypeRequiredDescription
contentstringYesReplacement text, up to 10000 characters. May be empty in a GET response (an unfilled default); must be non-empty when generating.

image

FieldTypeRequiredDefaultDescription
assetobjectYesImage to place — see Asset input.
fitstringNocontainHow the image fits the placeholder box: cover, contain, crop, or none.

video

FieldTypeRequiredDefaultDescription
assetobjectYesVideo to place — see Asset input.
fitstringNocontainHow the video fits the placeholder box: cover, contain, crop, or none.
play_stylestringNoloopPlayback when the video is shorter than the scene: fit_to_scene, freeze, loop, once, or full_video.
volumenumberNo1.0Audio volume of the video track, 0.0 (muted) to 1.0.

audio

FieldTypeRequiredDescription
assetobjectYesAudio to place — see Asset input.

voice

FieldTypeRequiredDescription
voice_idstringYesVoice used for text-to-speech. Browse with GET /v3/voices.
localestringNoOptional voice locale, e.g. en-US.

character

FieldTypeRequiredDefaultDescription
character_idstringYesAvatar ID or talking photo ID to place.
character_typestringNoavatarKind of character character_id refers to: avatar or talking_photo.

Asset input

image, video, and audio variables take an asset object, discriminated by type. Provide one of:
FormShape
Public URL{ "type": "url", "url": "https://..." }
Uploaded asset{ "type": "asset_id", "asset_id": "..." } — from POST /v3/assets (see Upload Assets).
Inline base64{ "type": "base64", "media_type": "image/png", "data": "<base64>" }

Scenes

scenes lists the template’s scenes in order. Each has a scene_id (usable to restrict a render to a subset of scenes), the script text with variable placeholders left unreplaced, and the variables referenced in that scene.

Generate a Video

  • Endpoint: POST /v3/templates/{template_id}
  • Purpose: Render a video from the template, replacing its variables with the values you supply.

Quick Example

Response
Generation is asynchronous. Poll GET /v3/videos/{video_id} until status is completed, then read the download URL.

Request Body

ParameterTypeRequiredDefaultDescription
variablesobjectYesReplacements keyed by variable name, each following the per-type shapes in Variable Types. Only include the variables you want to change.
titlestringNoTitle for the generated video.
scene_idsarray of stringsNoScene IDs to render, in order — repeats allowed to duplicate a scene. Scenes must already exist in the template; the API can’t create new ones. Omit to render every scene.
dimensionobjectNoOutput resolution override as { "width": ..., "height": ... } (even, 1284096). Must keep the template’s aspect ratio.
fpsnumberNo25Output frame rate: 25, 30, or 60.
captionbooleanNofalseBurn captions into the video.
subtitlesobjectNoSubtitle style — see Subtitle settings. Supplying this implies captions.
reorder_musicbooleanNotrueWhen true, background-audio tracks move with their scenes; when false, they stay pinned to the original layout positions.
keep_text_vertically_centeredbooleanNofalseRe-center replaced text elements based on their rendered height.
include_gifbooleanNofalseInclude a GIF preview URL in the webhook payload.
enable_sharingbooleanNofalseMake the generated video’s share page publicly accessible.
callback_urlstringNoWebhook URL called with the result, in addition to any registered endpoints.
callback_idstringNoOpaque ID echoed back in webhook events for this video.
folder_idstringNoFolder to place the generated video in.
brand_voice_idstringNoBrand voice ID controlling pronunciation and term handling.

Subtitle settings

When you pass subtitles, preset_name is required; the rest override the preset.
FieldTypeRequiredDefaultDescription
preset_namestringYesSubtitle preset, e.g. classic, bold, bright.
alignmentintegerNo2Subtitle alignment.
disable_highlightbooleanNofalseOverride the preset’s word-highlight style.
font_sizeintegerNoFont-size override for the preset.
positionobjectNoPosition override as { "x": ..., "y": ... }.

From template to video

The typical flow is three steps:
  1. DiscoverGET /v3/templates to find the template and its id.
  2. InspectGET /v3/templates/{template_id} to read the variable schema and defaults.
  3. Fill and generate — replace the defaults in the variables object with your own values and POST them to POST /v3/templates/{template_id}, then poll GET /v3/videos/{video_id} for the result.