Articles in this section
Category / Section

How to set the form fields required by the signers via API?

Published:
4 mins read

BoldSign supports signers to add form fields during the signing process. Signers must fill in these fields before they can complete signing the document. This ensures that all necessary information is collected and helps to avoid incomplete signatures.

Send a document to the signer with required property:

You can set the isRequired property to true for each field should be filled by signers.

Here are example codes you can use to set the required for form fields:

Code snippet

cURL

curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {your API key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'Title="Invitation form"' \
  -F 'Signers={
  "name": "hanky",
  "emailAddress": "hankyWhites@gmail.com",
  "signerType": "Signer",
  "signerRole": "Signer",
  "formFields": [
    {
      "id": "TextBox",
      "name": "TextBox",
      "fieldType": "TextBox",
      "pageNumber": 1,
      "bounds": {
        "x": 100,
        "y": 100,
        "width": 125,
        "height": 25
      },
      "isRequired": true
    }
  ],
  "locale": "EN"
}' \
  -F 'Files=@{your file}' \

.Net

var apiClient = new ApiClient("https://api.boldsign.com", "{Your API key}");
var documentClient = new DocumentClient(apiClient);

var documentFilePath = new DocumentFilePath
{
    ContentType = "application/pdf",
    FilePath = "{Your File path}"
};

var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};

var TextBoxField = new FormField(
    id: "sign",
    isRequired: true,
    type: FieldType.TextBox,
    pageNumber: 1,
    bounds: new Rectangle(x: 200, y: 200, width: 125, height: 25));

var formFieldCollections = new List<FormField>()
{
    TextBoxField
};

var signer = new DocumentSigner(
    signerName: "David",
    signerType: SignerType.Signer,
    signerEmail: "david@cubeflakes.com",
    formFields: formFieldCollections,
    locale: Locales.EN);

var documentSigners = new List<DocumentSigner>()
{
    signer
};

var sendForSign = new SendForSign()
{
    Title = "Sample Document",
    HideDocumentId = false,
    Signers = documentSigners,
    Files = filesToUpload,
};
var documentCreated = documentClient.SendDocument(sendForSign);

Python

import boldsign

configuration = boldsign.Configuration(api_key="Your_API_Key")

with boldsign.ApiClient(configuration) as api_client:
    document_api = boldsign.DocumentApi(api_client)

    form_fields = [
        boldsign.FormField(
            field_type="TextBox",
            page_number=1,
            bounds=boldsign.Rectangle(x=100, y=100, width=125, height=25),
            is_required=True
        )
    ]

    document_signer = boldsign.DocumentSigner(
        name="Hanky",
        email_address="hankyWhites@gmail.com",
        signer_type="Signer",
        signer_role="Signer",
        form_fields=form_fields,
    )

    send_for_sign = boldsign.SendForSign(
        title="Sample Document",
        files=["{Your file path}"], 
        signers=[document_signer]
    )

    send_document_response = document_api.send_document(send_for_sign)

    print(send_document_response)

Node.js

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('Signers', '{\r\n  "name": "hanky",\r\n  "emailAddress": "hankyWhites@gmail.com",\r\n  "signerType": "Signer",\r\n  "signerRole": "Signer",\r\n  "formFields": [\r\n    {\r\n      "id": "TextBox",\r\n      "name": "TextBox",\r\n      "fieldType": "TextBox",\r\n      "pageNumber": 1,\r\n      "bounds": {\r\n        "x": 100,\r\n        "y": 100,\r\n        "width": 125,\r\n        "height": 25\r\n      },\r\n  "isRequired": true\r\n}\r\n  ],\r\n  "locale": "EN"\r\n}');
data.append('Title', "Sample Document");
data.append('Files', fs.createReadStream('{Your file path}'));

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.boldsign.com/v1/document/send',
  headers: { 
    'accept': 'application/json', 
    'X-API-KEY': '{Your API key}', 
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

In the above example, when you set the isRequired property to true for each field should be filled before they can sign the document. By executing any one of the above code examples, the document will be sent for signature and signers won’t be able to submit it without filling in the required values.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied