> For the complete documentation index, see [llms.txt](https://developers.docstudio.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.docstudio.com/api-reference/create-template.md).

# Create Template

This document contains details for the /api/v1/template endpoint, including headers, request body, response fields, and status codes.

### Endpoint

| Property | Value              |
| -------- | ------------------ |
| Method   | `POST`             |
| URL      | `/api/v1/template` |

### Headers

| Header          | Required | Description                |
| --------------- | -------- | -------------------------- |
| `Authorization` | Yes      | Bearer authorization token |
| `Content-Type`  | Yes      | `application/json`         |
| `mailboxUuid`   | Yes      | Target mailbox UUID        |

```http
Authorization: Bearer {token}
Content-Type: application/json
mailboxUuid: {mailboxUuid}
```

### Request body

<table><thead><tr><th width="126.6666259765625">Field</th><th width="117.5555419921875">Type</th><th width="110.3333740234375">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>access</code></td><td>string</td><td>Yes</td><td>Template access level, such as <code>mailbox</code></td></tr><tr><td><code>categories</code></td><td>array</td><td>Yes</td><td>Category IDs, or an empty array</td></tr><tr><td><code>data</code></td><td>string</td><td>Yes</td><td>Template XML serialized as a JSON string</td></tr></tbody></table>

### Request example

```http
POST /api/v1/template
Authorization: Bearer {token}
Content-Type: application/json
mailboxUuid: 9baec31c-e940-4894-b6d1-52033e1af66e
```

```json
{
  "access": "mailbox",
  "categories": [],
  "data": "<template><info><name>Sales agreement</name><description>Template for sales agreement envelopes</description><subject>Sales agreement</subject><message>Please review and complete the agreement.</message></info><flow><roles><role id=\"23f20eec-adad-4325-b553-1bde4be29198\" title=\"Sender\" type=\"sender\" order=\"0\"/><role id=\"b811f2b6-1656-42aa-9420-a9b8addb0246\" title=\"Assignee\" type=\"assignee\" order=\"1\"/></roles></flow><documents><document id=\"4a61f258-fd9d-406c-b47e-81c90d4e5c47\"><info><title>Agreement</title></info><body><field type=\"text\" name=\"customer_name\" placeholder=\"Enter customer name\" roleId=\"b811f2b6-1656-42aa-9420-a9b8addb0246\" optional=\"false\"/></body></document></documents></template>"
}
```

### Response

| Field     | Type | Description                   |
| --------- | ---- | ----------------------------- |
| `uuid`    | UUID | Created template UUID         |
| `version` | UUID | Created template version UUID |

### Response example

```json
{
  "uuid": "56cacd6a-ffe7-4b77-9c0c-f928d9a18cb5",
  "version": "ab0d11cb-ebdd-42bd-a581-ddca1bb9b585"
}
```

### Status codes

<table><thead><tr><th width="180.6666259765625">Code</th><th>Description</th></tr></thead><tbody><tr><td><code>200</code></td><td>Success. The response contains the template UUID and version</td></tr><tr><td><code>401</code></td><td>Missing, invalid, or expired authorization token</td></tr><tr><td><code>403</code></td><td>Authenticated user cannot create templates in the target mailbox</td></tr></tbody></table>

### Related topics

* [Send Envelope](/api-reference/send-envelope.md)
* [Fill Envelope](/api-reference/fill-envelope.md)
