> ## 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.

# Templates

> Learn how to use templates when creating packages.

## Overview

Users in iinked Sign can create reusable templates in the UI to quickly generate new signing packages for frequently used workflows.
You can retrieve a list of available templates and apply a template when creating a package.

## Steps

<Steps titleSize="h3">
  <Step title="Get the template">
    You can retrieve a list of an organization members current templates by calling `templates/list` endpoint.

    ```http Request theme={null}
    GET /templates/list
    {
        "memberId": "e4f0bce5-30fc-43c4-b9ee-364ff5b04dea",
        "sortBy": "last_used",
        "take": 100,
        "skip": 0
    }
    ```

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

    ### Manually getting template details

    If you know the template you want to use, you can manually copy the `template ID` and `signer roles` from iinked Sign by navigating to the Templates section, selecting a template, and copying the ID from the URL and the roles from the editor.
  </Step>

  <Step title="Create package using the template">
    Once you have the template ID and signer roles, you can create a new package by calling the `packages/add` endpoint and setting the `templateId`.

    ### Documents

    All documents associated with the template will be included in the package. You can add additional documents by including them in the `documents` array.

    #### Replacing documents

    If you want to replace a document with a different file (e.g., a new version), upload the new file and add it to the `documents` array,
    setting either `templateDocumentId` or `name` to that of the template document you want to replace.

    This will swap out the document in the package while retaining all templated fields.

    ### Signers

    Associate template signers by setting the `templateSignerId` or `templateRole` for each signer in the `signers` array.

    ### Recipients

    Associate template recipients by setting the `templateRecipientId` or `templateRole` for each recipient in the `recipients` array.

    <Tabs>
      <Tab title="Using roles">
        ```http Request highlight={5,9,18} theme={null}
        POST /packages/add
        {
            "name": "From Template",
            "type": "concurrent",
            "templateId": "{{template_id}}",
            "state": "open",
            "signers": [
                {
                    "templateRole": "Signer 1",
                    "firstName": "Signer",
                    "lastName": "One",
                    "email": "{{signer_1_email}}",
                    "mobileNumber": null
                }
            ],
            "recipients": [
                {
                    "templateRole": "Recipient 1",
                    "firstName": "Recipient",
                    "lastName": "One",
                    "email": "{{recipient_1_email}}",
                    "mobileNumber": null
                }
            ],
            "documents": []
        }
        ```
      </Tab>

      <Tab title="Using IDs">
        ```http Request  highlight={5,9,18} theme={null}
        POST /packages/add
        {
            "name": "From Template",
            "type": "concurrent",
            "templateId": "{{template_id}}",
            "state": "open",
            "signers": [
                {
                    "templateSignerId": "{{template_signer_1_id}}",
                    "firstName": "Signer",
                    "lastName": "One",
                    "email": "{{signer_1_email}}",
                    "mobileNumber": null
                }
            ],
            "recipients": [
                {
                    "templateRecipientId": "{{template_recipient_1_id}}",
                    "firstName": "Recipient",
                    "lastName": "One",
                    "email": "{{recipient_1_email}}",
                    "mobileNumber": null
                }
            ],
            "documents": []
        }         
        ```
      </Tab>

      <Tab title="Replace doc using ID">
        ```http Request highlight={5,9,18,27} theme={null}
        POST /packages/add
        {
            "name": "From Template",
            "type": "concurrent",
            "templateId": "{{template_id}}",
            "state": "open",
            "signers": [
                {
                    "templateSignerId": "{{template_signer_1_id}}",
                    "firstName": "Signer",
                    "lastName": "One",
                    "email": "{{signer_1_email}}",
                    "mobileNumber": null
                }
            ],
            "recipients": [
                {
                    "templateRecipientId": "{{template_recipient_1_id}}",
                    "firstName": "Recipient",
                    "lastName": "One",
                    "email": "{{recipient_1_email}}",
                    "mobileNumber": null
                }
            ],
            "documents": [
                {
                    "templateDocumentId": "{{template_document_1_id}}",
                    "fileName": "agreement-2.pdf",
                    "fileId": "{{file_id}}"
                }
            ]
        }
        ```
      </Tab>

      <Tab title="Replace doc using name">
        ```http Request highlight={5,9,18,27} theme={null}
        POST /packages/add
        {
            "name": "From Template",
            "type": "concurrent",
            "templateId": "{{template_id}}",
            "state": "open",
            "signers": [
                {
                    "templateRole": "Signer 1",
                    "firstName": "Signer",
                    "lastName": "One",
                    "email": "{{signer_1_email}}",
                    "mobileNumber": null
                }
            ],
            "recipients": [
                {
                    "templateRole": "Recipient 1",
                    "firstName": "Recipient",
                    "lastName": "One",
                    "email": "{{recipient_1_email}}",
                    "mobileNumber": null
                }
            ],
            "documents": [
                {
                    "name": "Agreement",
                    "fileName": "agreement-2.pdf",
                    "fileId": "{{file_id}}"
                }
            ]
        }
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>
