# Create document via Template

## Create document via Template

<mark style="color:green;">`POST`</mark> `https://api.zapsign.com.br/api/v1/models/create-doc/`

This endpoint allows you to create a document using a DOCX Template. You only need to send the data that will replace the dynamic fields in the template in JSON format, and you will receive the response in JSON as well.

{% hint style="info" %}
Before getting started, you must create the Template on the ZapSign web platform in the Templates section and select the DOCX option (**this feature is not available for PDF templates**). [See the tutorial](https://clients.zapsign.com.br/en/help/templates) for creating a dynamic template.
{% endhint %}

#### Headers

<table><thead><tr><th width="207">Name</th><th width="141">Type</th><th>Description</th></tr></thead><tbody><tr><td>Authorization<mark style="color:red;">*</mark></td><td>string</td><td><p>apiToken ahead of the "Bearer" text. </p><p>Ex: Bearer c7f35c84-7893-4087-b4fb-d1f06c23</p></td></tr></tbody></table>

#### Request Body

<table><thead><tr><th width="217">Name</th><th width="139">Type</th><th>Description</th></tr></thead><tbody><tr><td>template_id<mark style="color:red;">*</mark></td><td>string</td><td><p>Dynamic template's Identifier/token </p><p>Ex: https://app.zapsign.co/conta/modelos/{TEMPLATE_ID}</p><p></p><p>To access yout templates list. just click here:<br><a href="https://app.zapsign.com.br/conta/modelos/">https://app.zapsign.co/conta/modelos/</a></p><p></p><p></p></td></tr><tr><td>signer_name<mark style="color:red;">*</mark></td><td>string</td><td><p>Signer's name. If there is more than one signer on your document, you can add it latter using the <a href="/pages/-MHDkQeDNJ1RAak5D5vV">Add signer</a> endpoint.</p><p></p></td></tr><tr><td>data[]['de']</td><td>string</td><td><p>Variable to replace.</p><p>Ex: "{{FULL NAME}}"</p></td></tr><tr><td>data[]['para']</td><td>string</td><td>Value to replace the variable for. Ex: "John Doe"</td></tr><tr><td>signer_email</td><td>string</td><td>Signer's email. If there is more than one signer on your document, you can add it latter using the <a href="/pages/-MHDkQeDNJ1RAak5D5vV">Add signer</a> endpoint.</td></tr><tr><td>signer_phone_country</td><td>String</td><td>Signer's country code (Ex: 1). If there is more than one signer on your document, you can add it latter using the <a href="/pages/-MHDkQeDNJ1RAak5D5vV">Add signer</a> endpoint.</td></tr><tr><td>signer_phone_number</td><td>String</td><td>Signer's phone number (Ex: 11999999999). If there is more than one signer on your document, you can add it latter using the <a href="/pages/-MHDkQeDNJ1RAak5D5vV">Add signer</a> endpoint.</td></tr><tr><td>lang </td><td>string</td><td><p>Document's language. Possible values: </p><p>"pt-br" (portugues)</p><p>"es" (spanish)</p><p>"en" (english). </p><p>Default: "pt-br"</p></td></tr><tr><td>disable_signer_emails </td><td>boolean</td><td><p>To deactivate all emails sent to signers, send this parameter as true.</p><p>Default: false</p></td></tr><tr><td>brand_logo</td><td>string</td><td><p>If you want to use your brand on the signing experience insted of ZapSign's logo, send here your logo's URL (it has to be publicly accesible)</p><p>Default: ""</p></td></tr><tr><td>brand_primary_color </td><td>string</td><td><p>If you want to use your brand color on the signing experience as the primary button color, send here the rgb or hexadecimal.</p><p>Ex: "#0011ee". </p><p>Default: ""</p></td></tr><tr><td>brand_name</td><td>string</td><td><p>If you want to set the sender name of all email's sent to signers, send here the brand name.</p><p>Ex: if "Lorem Lawyers" is sent, the email's sender will be "Lorem Lawyers via ZapSign".</p><p>Max-length: 100 caracteres. </p><p>Default: ""</p></td></tr><tr><td>external_id </td><td>string</td><td><p>This doc ID on your application.</p><p>Default: ""</p></td></tr><tr><td>folder_path</td><td>string</td><td><p>path of the folder inside ZapSign where the document will be placed. If the folders do not exist, they will be created automatically. Requirements: (1) folder_path can be up to 255 characters long, (2) each folder can be up to 50 characters long, (3) there is a limit of 5 folder levels. </p><p>Ex.: "/api/" or "/folder1/folder2/folder3/". Default: "/" (no folder).</p></td></tr><tr><td>created_by</td><td>string</td><td><p></p><p>email of the user who will be defined as creator of the document, for internal organization purposes. If the email does not exist or is not your account user, this parameter will be ignored. </p><p>Default: "" (document will have template owner as creator)</p><p></p></td></tr><tr><td>send_automatic_email </td><td>boolean</td><td><p>If <strong>true</strong>, ZapSign will send an email to the signers with the signature link. If <strong>false</strong> (default), you will have to send this link to your signer.</p><p>Attention: for this field to work, you have to set the signer's email as a dynamic field, ex: {{SIGNER EMAIL}}, and this value must be sent along with the replacement values</p><p></p><p><img src="/files/0OB7RJ2zK2QcTpqA6idf" alt=""></p></td></tr><tr><td>custom_message</td><td>string</td><td><p>(applies to <strong>send_automatic_email: true</strong> and <strong>send_automatic_whatsapp: true</strong>). </p><p>The custom_message is the message you can add to the signer's email sent by ZapSign.</p><p>Ex: "Helo John, \n This is your job contract. \n </p><p>The \n its for "breaking lines" on the email's text. </p><p>Default: ""</p></td></tr><tr><td>signer_has_incomplete_fields</td><td>bolean</td><td><p>If set to <em>true</em>, the signer will be redirected to fill out the template form before signing the document. </p><p>Default: false</p></td></tr><tr><td>reminder_every_n_days</td><td>integer</td><td>Represents the interval of days between reminders that will be sent to signers, as long as they don`t sign. There will be 3 tries at most. Observation: this field must only be filled if send_automatic_whatsapp or send_automatic_email are true. Example: if setted to 8 it will be sent one email every 7 days, until it's signed, for at most 21 days.</td></tr><tr><td>allow_refuse_signature</td><td>boolean</td><td>If true, signers have the option to refuse to sign. Default: false.</td></tr><tr><td>disable_signers_get_original_file</td><td>boolean</td><td>If true, signers do not have the option to download the original document. Default: false.</td></tr><tr><td>signature_order_active</td><td>boolean</td><td>If true, the signer's signatures will be ordered sequentially. Default: false. Always true when signer_has_incomplete_fields = true.</td></tr><tr><td>send_automatic_whatsapp</td><td>boolean</td><td>If <strong>true</strong>, ZapSign will send a whatsapp message to the signer with the link to sign the document.<br><strong>Note:</strong> For this to work, it is mandatory that the signer's phone number is defined. <strong>each automatic sending via WhatsApp (tokenWhatsapp) costs 0,1 USD. Buy credits in</strong> <a href="https://app.zapsign.com.br/conta/configuracoes?tab=plans"><strong>Configuration > Plan</strong></a><strong>.</strong></td></tr><tr><td>send_automatic_whatsapp_signed_file</td><td>boolean</td><td>If <strong>true</strong>, ZapSign will send a whatsapp message to the signer with the link to the signed document.<br><strong>Note:</strong> For this to work, it is mandatory that the signer's phone number is defined. <strong>each automatic sending via WhatsApp (tokenWhatsapp) costs 0,1 USD. Buy credits in</strong> <a href="https://app.zapsign.com.br/conta/configuracoes?tab=plans"><strong>Configuration > Plan</strong></a><strong>.</strong></td></tr><tr><td>Metadata</td><td>Array</td><td>Custom metadata sent during document creation, in <code>key</code> and <code>value</code> pair format. This information appears only in the creation, signing, rejection, and deletion webhooks.</td></tr><tr><td>folder_token</td><td>string</td><td><p>If provided, this field will take precedence over <code>folder_path</code>. It defines the directory based on the <strong>folder token</strong>, which can be obtained by accessing:<br><code>https://app.zapsign.com.br/conta/documentos?pasta=&#x3C;folder_token></code></p><p>If you don't know the token yet, navigate to the desired folder starting from:<br><code>https://app.zapsign.com.br/conta/documentos</code><br>Then, copy the <code>pasta</code> parameter from the URL after opening the target folder.</p></td></tr><tr><td>signature_placement</td><td>string</td><td><p>Allows you to position the signature in the document using an anchor text (no need for x, y coordinates). Set signature_placement: "&#x3C;&#x3C;{signature_identifier}>>" and the signature will be placed wherever this text is found. If the text appears more than once, the signature will be placed in all occurrences.</p><p></p><p><strong>Note</strong>: using <mark style="color:$danger;"><strong>&#x3C;&#x3C; >></strong></mark> is highly recommended to avoid conflicts with the document text, but it is not mandatory (e.g., "&#x3C;>"). Default: "". If you do not want the anchor text to be visible in the final document, simply set the anchor text color to match the document background color.</p></td></tr><tr><td>rubrica_placement</td><td>string</td><td><p>Allows positioning the rubrica in the document using anchor text (no x, y coordinates needed). Set rubrica_placement: "&#x3C;&#x3C;{rubrica_identifier}>>" and the rubrica will be positioned where this text is found. If the text appears more than once, the rubrica will be positioned at all locations. </p><p></p><p><strong>Note</strong>: using <mark style="color:$danger;"><strong>&#x3C;&#x3C; >></strong></mark> is highly recommended to avoid conflicts with text, but is not mandatory. Ex: "&#x3C;>". Default: "". If you do not want the anchor text to be visible in the final document, simply set the anchor text color to match the document background color.</p></td></tr></tbody></table>

{% tabs %}
{% tab title="200 Template created successfully." %}

```json
{
    "open_id": 5,
    "token": "eb9c367a-e62f-4992-8360-b0219deaeecc",
    "status": "pending",
    "name": "Employment Contract",
    "original_file": "https://zapsign.s3.amazonaws.com/pdf/62xxxxx-d8fc-4392-8575-f3c46c3cfc7a/df6bac91-2766-4182-8c8b-ded5287e4c0f.pdf",
    "signed_file": null,
    "created_at": "2020-04-16T03:33:46.241747Z",
    "last_update_at": "2020-04-16T03:33:46.241775Z",
    "signers": [
        {
            "token": "921c115d-4a6e-445d-bdca-03fadedbbc0b",
            "sign_url": "https://app.zapsign.com.br/verificar/921c115d-4a6e-445d-bdca-03fadedbbc0b",
            "status": "new",
            "name": "João da Silva",
            "email": "",
            "phone_country": "",
            "phone_number": "",
            "times_viewed": 0,
            "last_view_at": null,
            "signed_at": null
        }
    ],
    "answers": [ // list of variables and responses in the dynamic model (if the document was created using a dynamic model).
        {
            "variable": "COMPLETE NAME",
            "value": "Name Test"
        },
        {
            "variable": "FULL ADDRESS",
            "value": "Address Test"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### Request

{% embed url="<https://www.postman.com/zapsign/workspace/zapsign-workspace/request/27495556-11b56f17-c3cd-4898-bd58-98bcb011b925?ctx=documentation>" %}
URL for postman Create doc from Template endpoint
{% endembed %}

### Response

After a successfull request, you should get a response like this:

{% hint style="warning" %}
**Caution:** the **original\_file** and **signed\_file** links are temporary and **expires in 60 minutes**. In case your system needs to save those links it is recommended that you save them in your own CDN or that you call the [Detail document](/english/documentos/detalhar-documento.md) endpoint every time your user needs a valid URL that will expires in more 60 minutes.
{% endhint %}

```javascript
{
    "open_id": 5,
    "token": "eb9c367a-e62f-4992-8360-b0219deaeecc",
    "status": "pending",
    "name": "Job contract",
    "original_file": "https://zapsign.s3.amazonaws.com/pdf/62xxxxx-d8fc-4392-8575-f3c46c3cfc7a/df6bac91-2766-4182-8c8b-ded5287e4c0f.pdf",
    "signed_file": null,
    "created_at": "2020-04-16T03:33:46.241747Z",
    "last_update_at": "2020-04-16T03:33:46.241775Z",
    "signers": [
        {
            "token": "921c115d-4a6e-445d-bdca-03fadedbbc0b",
            "sign_url": "https://app.zapsign.co/verificar/921c115d-4a6e-445d-bdca-03fadedbbc0b",
            "status": "new",
            "name": "John Doe",
            "email": "",
            "phone_country": "",
            "phone_number": "",
            "times_viewed": 0,
            "last_view_at": null,
            "signed_at": null,
            "resend_attempts": null
        }
    ],
    "answers": [
        {
            "variable": "FULL NAME",
            "value": "Foo bar"
        },
        {
            "variable": "SOCIAL SECURITY NUMBER",
            "value": "999-99-XXXX"
        },
        {
            "variable": "FULL ADDRESS",
            "value": "2989 Heller Crossing Apt. 023 - Springfield, NY / 13347"
        }
    ]
}
```

What you should do with this response is **send the signature link to the signer through your application.**

The signature link consists of the route:\
**<https://app.zapsign.co/verificar/{signer\\_token}>**

Thus, in the example above, where we have one signer, you must send the following signature link:\
\&#xNAN;\*\*- <https://app.zapsign.co/verificar/921c115d-4a6e-445d-bdca-03fadedbbc0b**\\>
\
And now just wait for your signer to sign!

### More than one signer?

{% hint style="info" %}
If you want to add more signers, use the "[Add Signer](/english/signatarios/adicionar-signatario.md)" endpoint, receive the new signer's token and send the signature link as explained above.
{% endhint %}

### How to create a Dynamic Template at ZapSign

Enter our help center and check the step-by-step:

{% embed url="<https://clients.zapsign.com.br/en/help/templates>" %}

### Chat with Gepeto!

Have any questions? Use our artificial intelligence trained with all the API documentation. =)

{% embed url="<https://n8n.zapsign.com.br/webhook/fee2c476-7f23-4a4f-8928-5c7ab081ffcd/chat>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zapsign.com.br/english/documentos/criar-documento-via-modelo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
