Skip to main content

Overview

Template personalization lets you create a single video template and generate hundreds of unique videos by replacing variables. This is ideal for outreach, onboarding, and marketing campaigns.

Quick Example

const response = await fetch('https://api.hooked.ai/v1/project/create', {
  method: 'POST',
  headers: {
    'x-api-key': 'your_api_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    type: 'class',
    templateId: 'template_abc123',
    scenes: [
      {
        script: 'Hi {{name}}! Welcome to {{company}}.',
        variables: [
          { key: 'name', value: 'Sarah Johnson' },
          { key: 'company', value: 'TechStart Inc' }
        ]
      },
      {
        script: 'Your {{plan}} plan includes {{features}}.',
        variables: [
          { key: 'plan', value: 'Professional' },
          { key: 'features', value: 'unlimited videos and priority support' }
        ]
      }
    ],
    webhook: 'https://your-domain.com/webhook'
  })
});

const data = await response.json();
console.log('Project ID:', data.data.projectId);

Bulk Personalization

Generate videos for multiple recipients:
const API_KEY = process.env.HOOKED_API_KEY;
const BASE_URL = 'https://api.hooked.ai/v1';

const recipients = [
  { name: 'John', company: 'Acme Corp', plan: 'Pro' },
  { name: 'Sarah', company: 'TechStart', plan: 'Starter' },
  { name: 'Mike', company: 'BigCo', plan: 'Enterprise' }
];

for (const recipient of recipients) {
  const response = await fetch(`${BASE_URL}/project/create`, {
    method: 'POST',
    headers: {
      'x-api-key': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      type: 'class',
      templateId: 'template_abc123',
      scenes: [
        {
          script: `Hi {{name}}! Welcome to {{company}}.`,
          variables: [
            { key: 'name', value: recipient.name },
            { key: 'company', value: recipient.company }
          ]
        }
      ],
      webhook: `https://your-domain.com/webhook?user=${recipient.name}`
    })
  });

  const data = await response.json();
  console.log(`Created video for ${recipient.name}:`, data.data.projectId);

  await new Promise(resolve => setTimeout(resolve, 1000));
}

Variable Rules

  1. Provide all required variables — every {{variable}} in the script needs a value
  2. Case-sensitive — variable names must match exactly
  3. Overlay text — variables appear as text overlays on the video slide
  4. Empty values allowed — pass "" if a variable is optional
// ✅ All variables provided
{
  script: "Hello {{name}} from {{company}}!",
  variables: [
    { key: "name", value: "John Doe" },
    { key: "company", value: "Acme Corp" }
  ]
}

// ❌ Missing 'company' variable
{
  script: "Hello {{name}} from {{company}}!",
  variables: [
    { key: "name", value: "John Doe" }
  ]
}