---
title: "Create a document from a template"
method: POST
path: "/v1/templates/{slug}/documents/"
tags: ["Templates"]
---

# Create a document from a template

`POST /v1/templates/{slug}/documents/`

## Request

- Base URL: `https://api.pdfbetter.com`
- URL: `https://api.pdfbetter.com/v1/templates/{slug}/documents/`
- Auth: HTTP bearer

`{slug}` is a library slug or one of your template ids. The template itself is never modified.

## Path parameters

- `slug` string, required

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `title` string

## Response `201`

Create a document from a template

- Document
  - `object` 'document', required
  - `id` string, required
  - `title` string, required
  - `kind` 'document' | 'template' | 'form', required
  - `status` 'draft' | 'completed' | 'archived', required
  - `pageCount` integer, required
  - `tags` string[], required
  - `folderId` string, nullable, required
  - `sourceName` string, nullable, required
  - `sourceSize` integer, nullable, required
  - `createdFromTemplate` string, nullable, required: Library template slug or user template id this document was created from
  - `createdAt` string, required: ISO 8601 timestamp (UTC)
  - `updatedAt` string, required: ISO 8601 timestamp (UTC)

## Other responses

- `400`: Invalid request (see `error.details.issues`)
- `401`: Missing or invalid API key
- `402`: Your plan doesn't include this (API access needs Business) or a monthly allowance is used up
- `403`: The API key lacks the required scope
- `404`: Not found (or not yours)
- `409`: Conflict with the current state
- `422`: Validation failed
- `429`: Rate limited — see RateLimit-* and Retry-After

---

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