---
title: "Create a template (live keys)"
method: POST
path: "/v1/templates"
tags: ["Templates"]
---

# Create a template (live keys)

`POST /v1/templates`

## Request

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

## Request body

- object
  - `name` string, required
  - `html` string, required
  - `css` string
  - `sample_data` object
  - `settings` object
    - `mode` 'fast' | 'print'
    - `format` union
      - 'A4' | 'A5' | 'Letter' | 'Legal'
      - object
        - `width` string, required
        - `height` string, required
    - `orientation` 'portrait' | 'landscape'
    - `margin` string

## Response `201`

OK

- Template
  - `id` string, uuid
  - `name` string
  - `current_version` integer
  - `pinned_version` integer, nullable
  - `updated_at` string, date-time
  - `thumbnail_url` string, uri: Signed PNG of the current version first page (480 px wide, rendered with its sample data); made on first request, the url changes with each version.
  - `version` integer
  - `html` string
  - `css` string, nullable
  - `sample_data` object, nullable
  - `settings` object

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