# Create a document from a saved template

> POST /api/v1/saved-templates/{id}/create-document: Create a document from a saved template.

`POST https://appliflo.com/api/v1/saved-templates/{id}/create-document`

Creates a fresh draft document with a copy of the template's file and fields (already placed: do not call detect). The template is never modified. Pass the result to POST /documents/{id}/send.

Send your API key in the `Authorization: Bearer` header. Every response is JSON: `{ success, data, error }`.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `id` | path | yes | Saved template id from GET /saved-templates |
| `Idempotency-Key` | header | no | A client-generated key scoping this request as a retry of a prior identical request. A replay within 24h returns the first response instead of repeating the side effect (e.g. a second send). The key is bound to the request it was first used with: the same key with a different body or target is refused (422, code idempotency_key_reused) |

## Request body (application/json)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | Defaults to the template's name. Up to 255 characters |

## Responses

| Status | Description |
| --- | --- |
| 201 | The new draft document. |
| 401 | Missing or invalid API key, or `api_key_expired` for a key past its expiry. |
| 403 | The API key's workspace does not have access to this resource, or `insufficient_scope` (with `required_scope`) for a key without the scope this route needs. |
| 404 | Resource not found in this workspace. |
| 422 | Request failed validation. |
| 500 | Internal error. |

## 201 response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | true | yes |  |
| `data` | object | yes |  |
| `data.document_id` | string | yes |  |
| `data.template_id` | string | yes |  |
| `data.name` | string | yes |  |
| `data.field_count` | integer | yes | At least 0 |
| `data.roles` | object[] | yes |  |
| `data.roles[].key` | string | yes |  |
| `data.roles[].label` | string | yes |  |
| `data.fields` | object[] | yes |  |
| `data.fields[].field_id` | string | yes |  |
| `data.fields[].label` | string \| null | yes |  |
| `data.fields[].semantic_type` | string | yes |  |
| `data.fields[].page` | integer | yes |  |
| `data.fields[].role` | string \| null | yes | The template role this field belongs to, when set |

See also: [Errors](https://dev.appliflo.com/guides/errors), [Rate limits](https://dev.appliflo.com/guides/rate-limits), [Idempotency](https://dev.appliflo.com/guides/idempotency).
