> ## Documentation Index
> Fetch the complete documentation index at: https://tfstudio.truefan.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates & Variables

> How templates and their variables work

## Templates

A template is a video built once in the TrueFan editor — avatar, scenes, layout, branding — and saved so it can be generated from repeatedly with different content each time. You never need to describe any of that in a request; you only ever reference a template by its `template_id`, and its full configuration is fetched live at generation time.

This means editing a template in the dashboard changes what future API calls against it will produce — the API always renders the *current* version of a template, not a snapshot from whenever you first looked it up.

<Note>
  One exception: a [Generate videos](/docs/api-reference/generation/bulk-generate-videos) request is snapshotted at submission time, so it always renders consistently even if someone edits the template while it's still processing.
</Note>

## Variables

You can create variables in the script section of the TrueFan editor — wherever a word or phrase should change per generation (a customer's name, a score, a product), insert a variable instead of typing fixed text. Every template has its own, different set.

Because the variable set is different per template, there's no fixed request shape to look up in static docs — instead, call [Get template schema](/docs/api-reference/templates/get-template-schema) to get the live, current list:

```bash theme={null}
curl "https://dev-backend-ai.truefans.in/api/external/v1/templates/{template_id}/schema/" \
  -H "Authorization: Bearer $TRUEFAN_API_KEY"
```

```json theme={null}
{
  "variables": [
    { "name": "customer_name", "example_value": "Anmol" },
    { "name": "score", "example_value": "95" }
  ]
}
```

### Supplying variable values

Pass a `rows` array in the body of [Generate videos](/docs/api-reference/generation/bulk-generate-videos) — one object per video, whether you're generating one or many:

```json theme={null}
{
  "rows": [
    { "customer_name": "Anmol", "score": "95" },
    { "customer_name": "Rahul", "score": "88" }
  ]
}
```

Each row's keys should match the variable names from the schema endpoint. A row missing a key just leaves that one variable blank in that row's video — it doesn't fail the whole batch.

## Cost

Every template carries its own `estimated_credits` — set when the template is saved — which is what one video from it costs. A request with multiple rows costs `estimated_credits × row_count`. You never send a cost in the request body; it's always computed server-side from the template.
