How to remove existing form fields when sending a document from a template?

When you no longer need a specific form field in a document while sending it from a template, BoldSign allows you to remove it via the API. To remove a field using the BoldSign API, you will need the Id of the field you wish to remove. You can retrieve the ID of the form field by using the Properties API. For more information, refer to the Properties API documentation.

Once you have the Id of the form field, you can use the RemoveFormFields property to remove the form fields based on the ID.

Below are examples of how to remove an existing form field when sending a document from a template:

Code snippet

curl -X 'POST' \
'https://api.boldsign.com/v1/template/send?templateId=2b216722-xxxx-xxxx-8fbf-b6e49f9138a9' \
-H 'accept: application/json' \
-H 'X-API-KEY:{Your API Key} ' \
-H 'Content-Type: application/json' \
-d '{
"title": "Invitation form",
"message": "Kindly review and sign this.",
"roles": [
{
"RoleIndex": 1,
"signerName": "David",
"signerEmail": "david@cubeflakes.com",
"signerType": "Signer",
"signerRole": "Signer",
}
 ],
"removeFormFields":["Label1","CheckBox1"]
}'


  
using BoldSign.Api;
using BoldSign.Model;

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

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

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

var sendForSignFromTemplate = new SendForSignFromTemplate()
{
    TemplateId = "2b216722-xxxx-xxxx-8fbf-b6e49f9138a9",
    Roles = roles,
    RemoveFormFields = new List<string>(){"Label1","CheckBox1"}
};

var documentCreated =  templateClient.SendUsingTemplate(sendForSignFromTemplate);


import requests
import json

url = "https://api.boldsign.com/v1/template/send?templateId=2b216722-xxxx-xxxx-8fbf-b6e49f9138a9"
payload = {
    "title": "Invitation form",
    "message": "Kindly review and sign this.",
    "roles": [
        {
            "roleIndex": 1,
            "signerName": "David",
            "signerEmail": "david@cubeflakes.com",
        }
    ],
    "removeFormFields": ["Label1", "CheckBox1"]
}

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');

async function SendTemplate() {
    try {
        const sendResponse = await axios.post(
            'https://api.boldsign.com/v1/template/send',
            {
                roles: [
                    {
                        roleIndex: 1,
                        signerName: "David",
                        signerEmail: "david@cubeflakes.com"
                    }
                ],
                title: 'Simple document',
                message: 'Kindly review and sign this.',
                removeFormFields: ["Label1", "CheckBox2"],
            },
            {
                params: {
                    templateId: '2b216722-xxxx-xxxx-8fbf-b6e49f9138a9',
                },
                headers: {
                    accept: 'application/json',
                    'X-API-KEY': '{Your API Key}', 
                    'Content-Type': 'application/json',
                },
            }
        );

        console.log(JSON.stringify(sendResponse.data)); 
        return sendResponse;
    } catch (error) {
        console.error('Error:', error.response ? error.response.data : error.message);
    }
}

SendTemplate();

In the provided code example, make sure to replace the values for removeformfields with the ID of the form field you want to delete. Once the code is executed, the specified form field will be removed from the document when sending it from the template.