> ## 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.

# Get template schema

> Get the exact variables a template needs, computed live

Every template has a different set of variables, so there's no fixed request shape to look up statically — this endpoint computes it **live** from the template itself, every time it's called, so it can never drift from what the template will actually do at generate time.

Serves both kinds of template: video variables come from the template's scenes, image variables from its layers. Without `type` you get video, exactly as before; pass `type=IMAGE_TEMPLATE` for an image template.

Call this before building a [Generate videos](/docs/api-reference/generation/bulk-generate-videos) or [Generate images](/docs/api-reference/generation/bulk-generate-images) request.

<ParamField path="template_id" type="string" required />

<ParamField query="type" type="string" default="TEMPLATE">
  `TEMPLATE` or `IMAGE_TEMPLATE` — must match the kind of template `template_id` actually is, or the lookup returns `404`. Same param as [List templates](/docs/api-reference/templates/list-templates).
</ParamField>

<ParamField header="Authorization" type="string" required>
  `Bearer {api_key}`
</ParamField>

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

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "template_id": "7a4facd6-136f-4d8a-8db6-0eb3b3e7086f",
    "name": "Customer shoutout",
    "variables": [
      { "name": "customer_name", "example_value": "Anmol" },
      { "name": "score", "example_value": "95" }
    ],
    "bulk_generate": {
      "method": "POST",
      "path": "/api/external/v1/templates/7a4facd6-136f-4d8a-8db6-0eb3b3e7086f/bulk-generate/",
      "body": {
        "rows": [{ "customer_name": "Anmol", "score": "95" }],
        "batch_name": "string (optional)"
      }
    }
  }
  ```

  ```json 200 OK — ?type=IMAGE_TEMPLATE theme={null}
  {
    "template_id": "b81c04ff-2a7e-4c19-9f0d-5c2a1e3d7b44",
    "name": "Diwali greeting card",
    "type": "IMAGE_TEMPLATE",
    "variables": [
      { "name": "customer_name", "example_value": "Anmol" },
      { "name": "city", "example_value": "Mumbai" }
    ],
    "credits_per_row": "0.00362",
    "bulk_generate": {
      "method": "POST",
      "path": "/api/external/v1/image-templates/b81c04ff-2a7e-4c19-9f0d-5c2a1e3d7b44/bulk-generate/",
      "body": {
        "rows": [{ "customer_name": "Anmol", "city": "Mumbai" }],
        "batch_name": "string (optional)"
      }
    }
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": "type must be one of TEMPLATE or IMAGE_TEMPLATE",
    "allowed": ["IMAGE_TEMPLATE", "TEMPLATE"]
  }
  ```

  ```json 401 Unauthorized theme={null}
  { "error": "API key required" }
  ```

  ```json 404 Not Found theme={null}
  { "error": "Template not found" }
  ```

  ```json 404 Not Found — ?type=IMAGE_TEMPLATE theme={null}
  { "error": "Image template not found" }
  ```
</ResponseExample>

## Response fields

<ResponseField name="variables" type="array">
  Every variable this template uses, each with `name` and an `example_value` pulled from the template itself.
</ResponseField>

<ResponseField name="type" type="string">
  Echoes back the kind of template this is — `TEMPLATE` or `IMAGE_TEMPLATE`.
</ResponseField>

<ResponseField name="credits_per_row" type="string">
  **Image templates only** — what one row costs: `0.00181 × variables.length`. Multiply by your row count for the batch total. Absent for video templates, which carry a fixed `estimated_credits` on the template itself instead.
</ResponseField>

<ResponseField name="bulk_generate" type="object">
  A ready-to-use example, including one example row and the **correct path for this template's kind** — `/templates/{id}/bulk-generate/` for video, `/image-templates/{id}/bulk-generate/` for images. Use a single-item `rows` list to generate just one.
</ResponseField>

<Note>
  A template with no variables at all returns an empty `variables` array, and `bulk_generate.body` reflects that (a single empty row) — you can still generate from it, every result just comes out identical.
</Note>

<Warning>
  `credits_per_row` is priced off the image template as it stands right now, whereas a batch is priced off the snapshot taken when it is submitted — editing the template in between changes the charge. Treat it as an estimate and `estimated_credits` in the [Generate images](/docs/api-reference/generation/bulk-generate-images) response as the real figure.
</Warning>
