Send document from template by filling existing fields

This article provides a guide on how to create a template in BoldSign's web app, and then use that template to fill in existing field values programmatically and send the document for signature. For instance, if you have a claim form and your user submits a form with values, you may need to pre-fill those values in the BoldSign form fields programmatically and send a signature request to your user.

Follow the steps below to send a document for signature using an already created template:

  1. Create a template in BoldSign's web app. See How to Create a Template in the BoldSign Web App for instructions.
  2. Make a note of the unique field ID for each field that you add to the template. You will need these field IDs later to programmatically fill in the fields using the BoldSign API.
  3. Use the copied template ID and field IDs to fill in the fields with values and send the document to your signers.

Here are example codes you can use to do this:

Code snippet

curl --location --request POST 'https://api.boldsign.com/v1/template/send?templateId={templateID}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbG...' \
--data-raw '{
    "roles": [
        {
            "RoleIndex": 1,
            "SignerEmail": "signer1@email.com",
            "SignerName": "Signer Name",
            "ExistingFormFields": [
                {
                    "Id": "State",
                    "Value": "North Carolina"
                },
                {
                    "Id": "Country",
                    "Value": "United States"
                }
            ]
        }
    ]
}

var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var templateClient = new TemplateClient(apiClient);

var existingFormFieldCollections = new List<ExistingFormField>
{
    new ExistingFormField(
        id: "State",
        value: "North Carolina"
    ),
    new ExistingFormField(
        id: "Country",
        value: "United States"
    ),
};

var templateRole = new Roles(
    roleSignerIndex:1,
    roleSignerName:"David",
    roleSignerEmailAddress:"david@cubeflakes.com",
    existingFormFields: existingFormFieldCollections,
    locale: Locales.EN);

var roles = new List<Roles>
{
    templateRole,
};

var sendForSignFromTemplate = new SendForSignFromTemplate()
{
    TemplateId = "{templateID}",
    Roles = roles
};

var documentCreated =  templateClient.SendUsingTemplate(sendForSignFromTemplate);
import requests

url = "https://api.boldsign.com/v1/template/send?templateId={templateID}"

payload = {
    "roles": [
        {
            "roleIndex": 1,
            "signerName": "David",
            "signerEmail": "david@cubeflakes.com",
            "existingFormFields": [
                {
                    "id": "State",
                    "value": "North Carolina"
                },
                {
                    "id": "Country",
                    "value": "United States"
                }
            ]
        }
    ]
}

headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API key}',
    'Content-Type': 'application/json;odata.metadata=minimal;odata.streaming=true'
}

response = requests.post(url, headers=headers, json=payload)
print(response.text)
const axios = require('axios');
const response = await axios.post(
    'https://api.boldsign.com/v1/template/send',
    {
        'roles': [
            {
                'roleIndex': 1,
                'signerName': 'David',
                'signerEmail': 'david@cubeflakes.com',
                'existingFormFields': [
                    {
                        'id': "State",
                        'value': "North Carolina"
                    },
                    {
                        'id': "Country",
                        'value': "United States"
                    }
                ]
            }
        ]
    },
    {
        params: {
            'templateId': '{templateID}'
        },
        headers: {
            'accept': 'application/json',
            'X-API-KEY': '{your API key}',
            'Content-Type': 'application/json;odata.metadata=minimal;odata.streaming=true'
        }
    }
);

In the above example, replace the templateId with the ID of the template you created earlier. Then, update the SignerEmail and SignerName properties with the email and name of the signer you want to send the document to. Finally, use the field IDs you noted earlier to fill in the fields with the desired values, and include those field IDs and values in the ExistingFormFields array.

That's it! Once you run the code, the document will be sent for signature with the fields pre-filled with the specified values.