How to create non editable form fields with BoldSign API?

BoldSign allows you to create the read-only form fields, ensuring they are non-editable to signers. This guide will go through the process of setting read-only property to the supported form fields using BoldSign API.

Send a document to the signer with readonly property:

You can set the isReadOnly property to true for each field that should be non-editable to signers. The read-only option is supported only for the below fields:

  • TextBox
  • CheckBox
  • RadioButton
  • Name Field
  • Editable Date
  • Image Field

When setting the isReadOnly property to true, ensure that the prefilled value is also set; otherwise, an error message will be thrown.

DinakaranGSF3536 marked this conversation as resolved. Here are example codes you can use to set the form fields as read-only:

Code snippet

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="Sample Document"' \
  -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,
      "value": "Prefilled Value",
      "isReadOnly": true
}
  ],
  "locale": "EN"
}' \
  -F 'Files={your file}' \
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,
    isReadOnly: true,
    value: "Prefilled Value",
    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(
    name: "David",
    emailAddress: "david@cubeflakes.com",
    formFields: formFieldCollections,
    locale: Locales.FR);

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

var sendForSign = new SendForSign()
{
    DisableEmails = true,
    Signers = documentSigners,
    Title = "Sample Document",
    Files = filesToUpload
};
var documentCreated = documentClient.SendDocument(sendForSign);
Console.WriteLine(documentCreated.DocumentId);
import requests
import json

url = "https://api.boldsign.com/v1/document/send"

signer_data = {
    "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,
            "value": "prefilled Value",
            "isReadOnly": True
        }
    ],
    "locale": "EN"
}

payload = {
    'Signers': json.dumps(signer_data),
    'Title': "Sample Document"
}

files = [
    ('Files', ('{Your file name}', open('{Your file path}', 'rb'), 'application/pdf'))
]

headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API key}'
}

response = requests.post(url, headers=headers, data=payload, files=files)

print(response.text)
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  "isReadOnly": true,\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, the prefilled value should be given when you set the isReadOnly property to true for each field that should be non-editable by signers. By executing any one of the above code examples, the document will be sent for signature and the read-only fields cannot be edited by the signers.