---
title: "The template's fields (from its sample data)"
method: GET
path: "/v1/templates/{id}/fields"
tags: ["Templates"]
---

# The template's fields (from its sample data)

`GET /v1/templates/{id}/fields`

## Request

- Base URL: `https://api.castpdf.com`
- URL: `https://api.castpdf.com/v1/templates/{id}/fields`
- Auth: HTTP bearer

What no-code tools show as form fields, read from the version's sample data: scalar fields by dotted path, arrays of scalars as list, arrays of objects as line_items with the fields of one item. Up to 200 fields, 6 levels deep. tree has the same fields as a nested form, keys kept exactly. Without sample data the arrays are empty.

## Path parameters

- `id` string, uuid, required

## Query parameters

- `version` string

## Response `200`

OK

- TemplateFields
  - `template_id` string, uuid
  - `version` integer
  - `fields` object[]
    - `key` string, required: The dotted path in the data, e.g. customer.name (inside a line item: relative to the item).
    - `type` 'string' | 'number' | 'boolean' | 'list', required
    - `sample` unknown, required
  - `line_items` object[]
    - `key` string
    - `fields` object[]
      - `key` string, required: The dotted path in the data, e.g. customer.name (inside a line item: relative to the item).
      - `type` 'string' | 'number' | 'boolean' | 'list', required
      - `sample` unknown, required
    - `sample_count` integer
  - `tree` TemplateTreeField[]: The same fields as a ready-made nested form (the shape Make uses for parameters): name is the data key exactly as in the sample data (spaces and dots included, never a path); objects are collections, arrays of objects are arrays whose spec is the fields of one item (line items, also inside objects), arrays of values are arrays with one value field. Send what such a form produces as merge_data on POST /v1/pdf.
    - `name` string, required
    - `label` string, required
    - `type` 'text' | 'number' | 'boolean' | 'collection' | 'array', required
    - `help` string, required
    - `spec` union: collection: its fields; array of objects: the fields of one item; array of values: the value field.
      - TemplateTreeField[]
      - object
        - `type` 'text' | 'number' | 'boolean'
        - `label` string
  - `tree_truncated` boolean: True when fields were left out of tree: more than 200, deeper than 6 levels, or arrays that mix values and objects.

## Other responses

- `default`: Error

---

[API](https://skmtc.dev/castpdf/apis/castpdf-api.md) · [All operations](https://skmtc.dev/castpdf/apis/castpdf-api/llms.txt) · [OpenAPI document](https://skmtc.dev/castpdf/apis/castpdf-api/revisions/4ec737ba2ba6?raw)
