> 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-documentation/api-methods/create-template.md).

# Create Template

### Method

<table><thead><tr><th width="203">Method</th><th>POST</th></tr></thead><tbody><tr><td>URL</td><td><code>/api/v1/template</code></td></tr><tr><td>Authorization</td><td>Bearer {token}</td></tr><tr><td>Content-Type</td><td>application/json</td></tr><tr><td>Mailbox UUID header</td><td><code>{uuid}</code></td></tr><tr><td>Body</td><td><code>{"access":"string","categories":[],"data":"string"}</code></td></tr></tbody></table>

Use this endpoint to create a template from XML. Send the template XML as a string inside the `data` field and pass the target mailbox in the `mailboxUuid` header.

### How it works

Build the template as XML first. Then send that XML inside the JSON body.

The response returns the template UUID and version. Reuse those values later in envelope requests. Reuse the same role IDs, document IDs, and field names from the template structure.

### Request body

Use these body fields:

* `access` — template access level, such as `mailbox`
* `categories` — category IDs, or an empty array
* `data` — template XML string

```json
{
  "access": "mailbox",
  "categories": [],
  "data": "template XML string"
}
```

#### Template example

This simplified template example shows the XML that goes inside the `data` field.

```xml
<template>
    <info>
        <name>Template name</name>
        <description>Template description</description>
        <subject/>
        <message/>
        <expire/>
    </info>
    <documents>
        <document id="4a61f258-fd9d-406c-b47e-81c90d4e5c47">
            <info>
                <title>New document</title>
            </info>
            <body>
                <div class="editor-div">Structured document</div>
                <div class="editor-div">
                    Please fill the field below.
                    <field type="text" name="text field" roleId="b811f2b6-1656-42aa-9420-a9b8addb0246" placeholder="text field"/>
                </div>
            </body>
        </document>
    </documents>
    <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>
</template>
```

Use template fields to define which data recipients must fill or sign.

### Response example

```json
{
  "uuid": "56cacd6a-ffe7-4b77-9c0c-f928d9a18cb5",
  "name": "Template name",
  "description": "Template description",
  "data": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>...",
  "version": "ab0d11cb-ebdd-42bd-a581-ddca1bb9b585",
  "dataCreatedAt": "2020-12-02T06:30:44.543Z",
  "dataModifiedAt": "2020-12-02T06:30:44.543Z",
  "access": "mailbox",
  "archive": false,
  "categories": [],
  "createdAt": "2020-12-02T06:30:44.503Z",
  "modifiedAt": "2020-12-02T06:30:44.503Z"
}
```

Pay attention to `uuid` and `version`. Use them in [Send Envelope](https://support.docstudio.com/docstudio-docs/docstudio-for-developers/api-documentation/envelope/send-envelope) and [Fill Envelope](https://support.docstudio.com/docstudio-docs/docstudio-for-developers/api-documentation/envelope/fill-envelope).

### Related topics

* [Template Structure API](https://support.docstudio.com/docstudio-docs/docstudio-for-developers/template-api/template-structure-api)
* [Template API](https://support.docstudio.com/docstudio-docs/docstudio-for-developers/template-api)
* [Send Envelope](https://support.docstudio.com/docstudio-docs/docstudio-for-developers/api-documentation/envelope/send-envelope)
* [Fill Envelope](https://support.docstudio.com/docstudio-docs/docstudio-for-developers/api-documentation/envelope/fill-envelope)
