How to add Dropdown field for signers while sending an eSignature request via API?
BoldSign supports to incorporate Dropdown fields into your documents, allowing signers to choose from a predetermined list of options.
Send a document to the signer with Dropdown fields:
You can set the dropdown form field by providing dropdownOptions presenting it as a dropdown list of choices.
Here are some example codes you can use to set dropdown form fields:
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": "[email protected]",
"signerType": "Signer",
"signerRole": "Signer",
"formFields": [
{
"id": "DropDown",
"name": "DropDown",
"fieldType": "DropDown",
"pageNumber": 1,
"bounds": {
"x": 200,
"y": 200,
"width": 125,
"height": 25
},
"isRequired": true,
"dropdownOptions":["Male", "Female"],
"value": "Male"
}
],
"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 dropdownField = new DropdownField(
id: "DropDown",
isRequired: true,
dropdownOptions: new List<string> { "Male", "Female" },
value: "Male",
pageNumber: 1,
bounds: new Rectangle(x: 100, y: 100, width: 125, height: 25));
var formFieldCollections = new List<FormField>()
{
dropdownField
};
var signer = new DocumentSigner(
signerName: "David",
signerType: SignerType.Signer,
signerEmail: "[email protected]",
formFields: formFieldCollections,
locale: Locales.EN);
var documentSigners = new List<DocumentSigner>()
{
signer
};
var sendForSign = new SendForSign()
{
Signers = documentSigners,
Title = "Sample Document",
Files = filesToUpload
};
var documentCreated = documentClient.SendDocument(sendForSign);
import requests
import json
url = "https://api.boldsign.com/v1/document/send"
signer_data = {
"name": "hanky",
"emailAddress": "[email protected]",
"signerType": "Signer",
"signerRole": "Signer",
"formFields": [
{
"id": "DropDown",
"name": "DropDown",
"fieldType": "DropDown",
"pageNumber": 1,
"bounds": {
"x": 200,
"y": 200,
"width": 125,
"height": 25
},
"isRequired": True,
"dropdownOptions":["Male", "Female"],
"value": "Male"
}
],
"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": "[email protected]",\r\n "signerType": "Signer",\r\n "signerRole": "Signer",\r\n "formFields": [\r\n {\r\n "id": "DropDown",\r\n "name": "DropDown",\r\n "fieldType": "DropDown",\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 "dropdownOptions": ["Male", "Female"],\r\n "value": "Male",\r\n "isRequired": true\r\n}\r\n ],\r\n "locale": "EN"\r\n}');
data.append('Files', fs.createReadStream('{Your file path}'));
data.append('Title', "Sample Document");
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 given example, replace the dropDownOptions values with the desired values. Set the field type as DropDown. Upon executing the provided code, a document will be created with the specified dropDownOptions values for the DropDown form fields.