Sometimes, we are in such a rush to get a document signed that we forget certain steps in the process. If you realize that you forgot to prefill the form fields right after sending your document in BoldSign, it’s not a problem. In this blog post, we will look at how to prefill form fields after sending an eSignature document via the API.

After a document has been sent to signers, the Prefill Form Fields API allows you to assign values to certain fields in it. This function is very beneficial for adding data from a variety of sources, ensuring that the document is ready for signature without the need for error-prone manual entry. However, it is important to note that once the document has been signed by the signer, prefilling is not permitted.

Supported Form Fields

The following form fields support prefilling:

  • Text boxes: Ideal for inserting text data such as names, addresses, and other information.
  • Checkboxes: Useful for yes/no questions or selections.
  • Radio Buttons: Allows selection from multiple options.
  • Editable Dates: Enable prefilling date fields with specific dates.
  • Dropdowns: Facilitate selection from a predefined list of options.

Step-by-Step Guide

Step 1: Retrieve Form Field IDs

Before you can prefill fields, you need to identify the form field IDs in the document. This can be done using the properties API. You can refer to this documentation to see how to get the properties of the document. The properties will contain the IDs of the form fields.

Step 2: Prefill the Form Fields

Once you have the form field IDs, you can use the Prefill API to assign values. You can assign values in the fields array by providing id as the form field ID and value as the form field value. Following are some examples in different programming languages using the BoldSign API.


curl --location --request PATCH 'https://api.boldsign.com/v1/document/prefillFields?documentId= b5529f7e-xxxx-49ff-xxxx-7686e52dfa8a \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: {your-API-key}' \
--data '{
    "fields": [
        {
            "id": "textbox_mShRr",
            "value": "John Doe"
        },
        {
            "id": "checkbox_1a2b3c",
            "value": "on"
        },
        {
            "id": "radioChild_8WSDS",
            "value": "on"
        },
        {
            "id": "editableDate_14AXl",
            "value": "05/10/2023"
        },
        {
            "id": "dropdown_002d4",
            "value": "United States"
        }
    ]
}'
 
var apiClient = new ApiClient("https://api.boldsign.com", "{your API key}");
var documentClient = new DocumentClient(apiClient);

var documentId = "b5529f7e-xxxx-49ff-xxxx-7686e52dfa8a";
var prefillFieldRequest = new PrefillFieldRequest(documentId)
{
    Fields = new List()
    {
        new PrefillField()
        {
            Id = "textbox_mShRr",
            Value = "Prefill value"
        },
        new PrefillField()
        {
            Id = "checkbox_1a2b3c",
            Value = "on"
        },
        new PrefillField()
        {
            Id = "radioChild_8WSDS",
            Value = "off"
        },
        new PrefillField()
        {
            Id = "editableDate_14AXl",
            Value = "05/10/2023"
        },
        new PrefillField()
        {
            Id = "dropdown_002d4",
            Value = "United States"
        },
    },
};
await documentClient.PrefillFieldsAsync(prefillFieldRequest);

import requests
url = 'https://api.boldsign.com/v1/document/prefillFields'
headers = {
    'Content-Type': 'application/json',
    'X-API-KEY': '{your-API-key}'
}
data = {
    "fields": [
        {
            "id": "textbox_mShRr",
            "value": "Prefill value"
        },
        {
            "id": "checkbox_1a2b3c",
            "value": "off"
        },
        {
            "id": "radioChild_8WSDS",
            "value": "on"
        },
        {
            "id": "editableDate_14AXl",
            "value": "05/10/2023"
        },
        {
            "id": "dropdown_002d4",
            "value": "United States"
        }
    ]
}
document_id = 'b5529f7e-xxxx-49ff-xxxx-7686e52dfa8a'
params = {'documentId': document_id}
response = requests.patch(url, headers=headers, json=data, params=params)
 

const axios = require('axios');
const url = 'https://api.boldsign.com/v1/document/prefillFields';
const apiKey = '{your-API-key}';
const documentId = 'b5529f7e-xxxx-49ff-xxxx-7686e52dfa8a';
const headers = {
    'Content-Type': 'application/json',
    'X-API-KEY': apiKey
};
const data = {
    fields: [
        {
            id: 'textbox_mShRr',
            value: 'Prefill value'
        },
        {
            id: 'checkbox_1a2b3c',
            value: 'on'
        },
        {
            id: 'radioChild_8WSDS',
            value: 'off'
        },
        {
            id: 'editableDate_14AXl',
            value: '05/10/2023'
        },
        {
            id: 'dropdown_002d4',
            value: 'United States'
        }
    ]
};
axios.patch(url, data, { headers, params: { documentId } })
    .then(response => {
        console.log(response);
    })
    .catch(error => {
        console.error('Error:', error);
    });
 

<?php
require 'vendor/autoload.php'; // Make sure to include the autoload file from GuzzleHttp
use GuzzleHttp\Client;
$url = 'https://api.boldsign.com/v1/document/prefillFields';
$apiKey = '{your-API-key}';
$documentId = 'b5529f7e-xxxx-49ff-xxxx-7686e52dfa8a';
$headers = [
    'Content-Type' => 'application/json',
    'X-API-KEY' => $apiKey
];
$data = [
    'fields' => [
        [
            'id' => 'textbox_mShRr',
            'value' => 'Prefill value'
        ],
        [
            'id' =>'checkbox_nWpnN',
            'value' => 'off'
        ],
        [
            'id' => 'radioChild_8WSDS',
            'value' => 'on'
        ],
        [
            'id' => 'editableDate_14AXl',
            'value' => '05/11/2023'
        ],
        [
            'id' => 'dropdown_002d4',
            'value' => 'United States'
        ]
    ]
];

$client = new GuzzleHttp\Client();
$response = $client->request('PATCH', $url, [
    'headers' => $headers,
    'json' => $data,
    'query' => ['documentId' => $documentId]
]);
$body = $response->getBody();
echo $body;
 

Conclusion

Prefilling form fields in eSignature documents is a useful feature that enhances efficiency and accuracy. Even if you forget to do so before sending a document, BoldSign lets you correct that oversight, ensuring that documents are ready for signing without the need for manual entry. Implementing the Prefill Form Fields API in your workflow can save time, reduce errors, and improve the overall signing experience for all parties involved.

If you are not yet a customer, feel free to start a 30-day free trial of BoldSign to test out all its features. Please leave any comments you may have below; your thoughts are much appreciated. Schedule a demo or contact our support team via our support portal if you have any questions or would like more information about our services.