0

I'm trying to insert a text field into an existing DocuSign template using REST API, and I was wondering how I can do this. I checked the TemplateDocuments:update where it sends a PUT request using API, but I'm assuming that this request changes all the text tabs in the template. Would it be possible if someone can help me insert a text field inside an existing template without changing the other already existing fields?

Larry K
  • 47,808
  • 15
  • 87
  • 140
  • Are you trying to change the template, or the envelope created from a template? In both cases, I suggest you try to first do it from the web app, without the API, and generate API logs, these would show you what the web app does (it uses the REST API too) – Inbar Gazit Dec 18 '21 at 22:13
  • Welcome to stackOverflow! ***Please check (accept) the best answer to your questions. Thank you!*** – Larry K Dec 19 '21 at 12:06

1 Answers1

0

Yes, you can add a text field to an existing template at the time of calling Envelopes:create. Do this via composite templates.

The key is to include the documentId attribute for the right document in the template. You also need to specify the page number, x, and y information.

Determining the document ID

The template's first document usually has ID 1. To see the document's ID:

  1. Open the template for editing
  2. Click View for the document of interest
  3. On the document's modal display: open the browser's menu and choose "Open image in new tab"
  4. Inspect the new tab's URL. The number after /documents/ is the document ID. Eg URL .../documents/456/pages/... has document ID 456

Example

Here's an example which adds a text field and a list (dropdown) field. The text field is locked (not-editable). It serves as a label for the new list field.

  "envelopeDefinition": {
    "status": "sent",
    "compositeTemplates": [
      {
        "compositeTemplateId": "1",
        "serverTemplates": [
          {
            "sequence": "1",
            "templateId": "f4e5bdd4-xxxx-xxxxx-xxxx-5fd6b1ebe2fc"
          }
        ],
        "inlineTemplates": [
          {
            "sequence": "1",
            "recipients": {
              "signers": [
                {
                  "email": "name@example.com",
                  "name": "Signer Name",
                  "roleName": "signer",
                  "recipientId": "1",
                  "tabs": {
                    "textTabs": [
                      {
                        "documentId": "1",
                        "locked": "true",
                        "value": "Added via the API. Office:",
                        "font": "Helvetica",
                        "fontSize": "Size12",
                        "pageNumber": "3",
                        "xPosition": "40",
                        "yPosition": "428"
                      }
                    ],
                    "listTabs": [
                      {
                        "documentId": "1",
                        "font": "Helvetica",
                        "fontSize": "Size12",
                        "locked": "false",
                        "required": "false",
                        "pageNumber": "3",
                        "xPosition": "190",
                        "yPosition": "428",
                        "listItems": [
                          {
                            "text": "San Francisco",
                            "value": "SF"
                          },
                          {
                            "text": "London",
                            "value": "LON"
                          },
                          {
                            "text": "Paris",
                            "value": "PAR"
                          },
                          {
                            "text": "Jerusalem",
                            "value": "JLM"
                          },
                          {
                            "text": "São Paulo",
                            "value": "SP"
                          }
                        ]
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    ]
  }
Larry K
  • 47,808
  • 15
  • 87
  • 140