> ## Documentation Index
> Fetch the complete documentation index at: https://docs.iinkedsign.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto templates

> Learn how to use auto templates to streamline your workflow and enhance productivity.

## Overview

Auto templates in iinked Sign allow users to create document templates that can be automatically detected and
applied to a document when creating a new signing package. This feature helps streamline the signing process by predefining
templated fields for commonly used documents within your organization.

You can also manually apply an auto template when creating packages via the API by specifying the `autoTemplateCode` for any document.

<Tip>
  Using auto templates is especially useful when your packages contain documents that can vary, because you can choose which auto template to apply to each document individually.
</Tip>

## Steps

<Steps titleSize="h3">
  <Step title="Get the auto template code">
    To apply an auto template to a document when creating a package, you need to obtain the `autoTemplateCode` for the desired template.
    You can find this code in the auto template editor within iinked Sign. It appears in the `Auto Template Document` panel under each document.

    You can also retrieve a list of auto templates by calling the `templates/list` endpoint and filtering the results to only include auto templates.

    ```http Request highlight={4-6} theme={null}
    GET /templates/list
    {
        "memberId": null,
        "types": [
            "auto_template"
        ],
        "take": 100,
        "skip": 0
    }
    ```

    See the [Templates list API](/v4/api/templates/list) for more information.
  </Step>

  <Step title="Create package using the auto template">
    Once you have the `autoTemplateCode`, you can create a new package by calling the `packages/add` endpoint and
    specifying the `autoTemplateCode` for each document.

    <Tabs>
      <Tab title="Using code">
        ```http Request highlight={8,17} theme={null}
        POST /packages/add
        {
            "name": "From Auto Template Code",
            "type": "concurrent",
            "state": "open",
            "signers": [
                {
                    "templateRole": "Signer 1",
                    "firstName": "Signer",
                    "lastName": "One",
                    "email": "signer@example.com",
                    "mobileNumber": null
                }
            ],
            "documents": [
                {
                    "autoTemplateCode": "agreements:agreement123",
                    "fileName": "agreement.pdf",
                    "fileId": "{{file_id}}"
                }
            ]
        }
        ```
      </Tab>

      <Tab title="Using auto">
        You can also use the special `auto` value for the `autoTemplateCode` field. This instructs iinked Sign to automatically
        detect and apply any matching auto template based on the document name or content.

        ```http Request highlight={8,17} theme={null}
        POST /packages/add
        {
            "name": "From Auto Template Code",
            "type": "concurrent",
            "state": "open",
            "signers": [
                {
                    "templateRole": "Signer 1",
                    "firstName": "Signer",
                    "lastName": "One",
                    "email": "signer@example.com",
                    "mobileNumber": null
                }
            ],
            "documents": [
                {
                    "autoTemplateCode": "auto",
                    "fileName": "agreement.pdf",
                    "fileId": "{{file_id}}"
                }
            ]
        }
        ```
      </Tab>

      <Tab title="Using IDs">
        Alternatively, you can specify the `autoTemplateId` and `autoTemplateDocumentId` directly for more precise control.

        ```http Request highlight={8,17-18} theme={null}
        POST /packages/add
        {
            "name": "From Auto Template Code",
            "type": "concurrent",
            "state": "open",
            "signers": [
                {
                    "templateRole": "Signer 1",
                    "firstName": "Signer",
                    "lastName": "One",
                    "email": "signer@example.com",
                    "mobileNumber": null
                }
            ],
            "documents": [
                {
                    "autoTemplateId": "{{auto_template_id}}", 
                    "autoTemplateDocumentId": "{{auto_template_document_id}}",
                    "fileName": "agreement.pdf",
                    "fileId": "{{file_id}}"
                }
            ]
        }
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>
