Overview
Generate videos from templates by providing variable values for each scene. This is perfect for creating personalized video content at scale.
How Templates Work
Templates in Hooked use scenes - each scene has a script with {{variables}} that you replace:
Get template details to see scenes and variables
Prepare your data with values for each variable per scene
Generate video with the templateId and scenes array
Request Body
Video type (must match template type). Use class for template-based videos.
The template ID to use (1-20 characters)
Video title (1-100 characters)
Enable auto-generated captions
Language code for the video (max 2 characters). Example: en, es, fr
Array of scenes (1-20 scenes). Each scene contains: Script text for this scene (1-5000 characters)
Avatar configuration for this scene Top-left position with x and y coordinates
Bottom-right position with x and y coordinates
Caption configuration for this scene Top-left position with x and y coordinates
Bottom-right position with x and y coordinates
Variables to replace in the scene (max 20 per scene) Variable key (1-100 characters)
Variable value (1-2000 characters)
Variable type: text or media
Voice ID for this scene (max 20 characters)
Voice settings for this scene Show Voice Settings Object
URL to receive completion notification (max 500 characters)
Custom data to pass through to webhook responses. Use this to correlate videos with your internal systems (e.g., course IDs, user IDs, order numbers). Maximum size: 5KB. {
"courseId" : "python-101" ,
"lessonId" : "lesson-5" ,
"studentId" : "student-123"
}
Scene Structure
Each scene in the scenes array must include:
The script for this scene (can include {{variables}})
Array of {key, type, value} pairs to replace in the script [
{ "key" : "name" , "type" : "text" , "value" : "John Doe" },
{ "key" : "product" , "type" : "text" , "value" : "AI Video Tool" }
]
curl -X POST "https://api.tryhooked.ai/v1/project/create" \
-H "Content-Type: application/json" \
-H "x-api-key: your_api_key_here" \
-d '{
"type": "class",
"templateId": "cmha385y900012yhv17qfmase",
"title": "My Video from Template",
"caption": true,
"language": "en",
"scenes": [
{
"script": "Welcome to our presentation. Today we' \' 'll discuss the key features of our product.",
"avatar": {
"id": "1",
"topLeft": { "x": 0, "y": 0 },
"bottomRight": { "x": 100, "y": 100 }
},
"variables": [
{"key": "name", "type": "text", "value": "Juan Montiel"},
{"key": "description_small", "type": "text", "value": "Welcome to our presentation."},
{"key": "background", "type": "media", "value": "https://example.com/background.jpg"}
],
"voice": "voice_abc123"
},
{
"script": "Our platform offers seamless integration with your existing tools and workflows.",
"variables": [
{"key": "module_number", "type": "text", "value": "1"}
],
"voice": "voice_abc123"
}
],
"webhook": "https://yoursite.com/webhook",
"metadata": {
"courseId": "python-101",
"lessonId": "lesson-5"
}
}'
Success Response
Error Response
{
"success" : true ,
"message" : "Project created successfully" ,
"data" : {
"projectId" : "proj_new_xyz789" ,
"status" : "processing" ,
}
}
Bulk Generation Example
Generate personalized videos for multiple customers:
const API_KEY = process . env . HOOKED_API_KEY ;
const TEAM_ID = process . env . HOOKED_TEAM_ID ;
const template = await getTemplateDetails ( templateId );
const customers = [
{ id: 'cust_1' , name: 'John Doe' , company: 'Acme Corp' , plan: 'Pro' },
{ id: 'cust_2' , name: 'Jane Smith' , company: 'TechStart' , plan: 'Enterprise' },
{ id: 'cust_3' , name: 'Bob Wilson' , company: 'Digital Inc' , plan: 'Starter' }
];
for ( const customer of customers ) {
// Map template scenes with customer data
const scenes = template . scenes . map ( scene => ({
script: scene . script ,
avatar: { id: "1" },
variables: scene . variables . map ( v => ({
key: v . key ,
type: v . type ,
value: customer [ v . key ] || v . value
})),
voice: 'voice_abc123'
}));
// Generate video
const response = await fetch ( 'https://api.tryhooked.ai/v1/project/create' , {
method: 'POST' ,
headers: {
'x-api-key' : API_KEY ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
type: template . type ,
templateId: templateId ,
title: `Video for ${ customer . name } ` ,
caption: true ,
language: 'en' ,
scenes: scenes ,
webhook: 'https://yoursite.com/webhook' ,
metadata: {
customerId: customer . id ,
customerName: customer . name
}
})
});
console . log ( `Video created for ${ customer . name } ` );
// Rate limiting - wait 1 second between requests
await new Promise ( resolve => setTimeout ( resolve , 1000 ));
}
Variable Replacement Rules
Variable names are case-sensitive:
{{name}} ≠ {{Name}}
{{firstName}} ≠ {{firstname}}
You must provide values for all variables in each scene: // ❌ Will fail if scene has {{name}} and {{product}}
"variables" : [
{ "key" : "name" , "value" : "John" }
]
// ✅ Correct
"variables" : [
{ "key" : "name" , "value" : "John" },
{ "key" : "product" , "value" : "AI Tool" }
]
Empty string values are allowed: { "key" : "optional_field" , "value" : "" }
This replaces {{optional_field}} with an empty string.
Overriding Template Settings
You can override some template settings:
{
"templateId" : "..." ,
"caption" : true ,
"scenes" : [ ... ]
}
{
"templateId" : "..." ,
"title" : "Custom Video Title" , // Override name
"scenes" : [ ... ]
}
{
"templateId" : "..." ,
"metadata" : {
"orderId" : "12345" ,
"customerId" : "cust_abc"
},
"scenes" : [ ... ]
}
Best Practices
Validate First Get template details and validate your data before generating
Use Webhooks Always provide webhook URLs for async notification
Rate Limiting Add delays between bulk requests (1 second recommended)
Error Handling Check for missing variables before generation
Missing Variables : If any required variable is missing, the video generation will fail. Always validate your data against the template’s variable requirements first.
API Limits
Limit Value Max scenes per project 20 Max script length per scene 5,000 characters Max variables per scene 20 Max variable key length 100 characters Max variable value length 2,000 characters Max title length 200 characters Max webhook URL length 500 characters Max metadata size 5KB