Blog
Home/

Generate and send personalized agreements with document generation for eSignature

Author Aaron Prohofsky
Aaron ProhofskyProduct Manager
Summary4 min read

New API calls let you use document generation to dynamically insert data from your systems into your agreements and send them automatically.

Table of contents

We are excited to introduce one of our newest eSignature features—Document Generation—to our eSignature REST API!

With document generation for eSignature, you can generate personalized, professional-looking agreements at the time of sending your agreement. You can dynamically insert data from your internal systems into your agreement, eliminating the possibility of formatting issues like overlapping or cut-off text. And this can all be done within your eSignature workflow—no need to prepare the agreement in other systems ahead of time!

You can try document generation for free in your developer account. In production accounts, the feature is a paid add-on, so please reach out to a Docusign representative to learn more.

Sample document generation use cases

While document generation is applicable for any agreement into which you want to dynamically insert data, here are some very common use cases you might consider:

  • Generate and send an offer letter that pulls in data from your HR system. 

  • Generate and send a loan offer that pulls in the terms and conditions from your underwriting and loan management software.

  • Generate and send a service request from your internal real estate management system.

Document generation also supports conditional clauses so that text can be automatically shown or removed based on data provided. This can greatly reduce the number of templates you need to create and manage! For the HR offer letter use case, the resident state of the candidate receiving the offer may determine if some clauses should be removed. Or with the service request use case, some of the sections of the agreement may be hidden based on what part of the property needs to be serviced.

Create your template for document generation

You can create an eSignature template that is compatible with document generation the same way you would any eSignature template, with one major difference: the document to be generated must be a DOCX file with data fields. (see Document Generation Syntax for details on adding detail fields). When you add that document to a template (either using the API or using the web app), Docusign eSignature will automatically recognize that it contains data fields and mark the template as compatible with document generation.

Sending your template for Document Generation via the API

At a high level, the steps required to send an envelope using an existing template that is compatible with document generation are:

  1. Create an envelope draft from the template: Envelopes:create

  2. Get the data fields (DocGenFormFields) for each document on the envelope: DocumentGeneration : getEnvelopeDocGenFormFields

  3. Update the values for each data field (DocGenFormField): [DocumentGeneration : updateEnvelopeDocGenFormFields]

  4. Send the envelope: Envelopes:update

For a more detailed walk-through, see this how-to guide

Example: Generate and send an offer letter to a new hire

As an example, let’s take an HR offer letter that has the following data fields:

  • Candidate_Name

  • State_Of_Employment

  • Annual_Salary

  • Start_Date

Here’s the letter:

Document template with dynamic fields

Get the data fields from the letter

Once you’ve created your envelope draft, you need to get the docGenFormFields like so:

GET{vx}/accounts/{accountId}/envelopes/{envelopeId}/docGenFormFields

Sample Response:

{
    "docGenFormFields": [
        {
            "documentId": "d5f70ce4-xxxx-xxxx-xxxx-04535e6ze372",
            "docGenFormFieldList": [
                {
                    "label": "Candidate_Name",
                    "type": "TextBox",
                    "required": "True",
                    "Name": "Candidate_Name"
                },
                {
                    "label": "State_Of_Employment",
                    "type": "TextBox",
                    "required": "True",
                    "Name": "State_Of_Employment"
                },
                {
                    "label": "Annual_Salary",
                    "type": "TextBox",
                    "required": "True",
                    "Name": "Annual_Salary"
                },
                {
                    "label": "Start_Date",
                    "type": "TextBox",
                    "required": "True",
                    "Name": "Start_Date"
                }
            ]
        }
    ]
}

Add data field values

Then, you would update the value of the docGenFormFields object with the appropriate data like so:

PUT: {vx}/accounts/{accountId}/envelopes/{envelopeId}/docGenFormFields

{
    "docGenFormFields": [
        {
            "documentId": "d5f70ce4-xxxx-xxxx-xxxx-04535e6ze372",
            "docGenFormFieldList": [
                {
                    "value": "Carry Candidate",
                    "Name": "Candidate_Name"
                },
                {
                    "value": "California",
                    "Name": "State_Of_Employment"
                },
                {
                    "value": "100,000",
                    "Name": "Annual_Salary"
                },
                {
                    "value": "August 1, 2023",
                    "Name": "Start_Date"
                }
            ]
        }
    ]
}

Now your final offer letter has all of the personalized information dynamically merged in, and the clause specific to candidates in the state of California is included. Now, you can send off a clean, professional-looking document to your new hire!

Generated document with fields inserted

Limitations 

The major limitation is that you are not able to add the data field values within the composite template API call. 

See Limitations and Considerations for Document Generation for a more detailed list of limitations.

Additional resources

Take a look at the resources below and take advantage of document generation!

Author Aaron Prohofsky
Aaron ProhofskyProduct Manager

Aaron Prohofsky has been with Docusign since January 2021. He is the product manager for the core sending experience in the Docusign web application. He graduated from UC Berkeley with a degree in engineering and has worked in the tech industry for many years. In his free time he loves playing basketball, beach volleyball and kiteboarding.

More posts from this author

Related posts

  • Accelerating Intelligent Agreement Management with a New “Docusign for Developers”
    Intelligent Agreement Management

    Accelerating Intelligent Agreement Management with a New “Docusign for Developers”

    Dmitri Krakovsky
  • Event Notifications using JSON SIM and HMAC

    Event Notifications using JSON SIM and HMAC

    Author Jonathan Sammons
    Jonathan Sammons
  • Streamline End-to-End Agreement Management with Docusign: A Developer Overview

    Streamline End-to-End Agreement Management with Docusign: A Developer Overview

    Author Larry Jin
    Larry Jin
Event Notifications using JSON SIM and HMAC

Event Notifications using JSON SIM and HMAC

Author Jonathan Sammons
Jonathan Sammons
Streamline End-to-End Agreement Management with Docusign: A Developer Overview

Streamline End-to-End Agreement Management with Docusign: A Developer Overview

Author Larry Jin
Larry Jin

Discover what's new with Docusign IAM or start with eSignature for free

Explore Docusign IAMTry eSignature for Free
Person smiling while presenting