How to authenticate signers with an access code before allowing them to sign the document using BoldSign API?
Authentication is the process of verifying the identity of a user. It adds an additional layer of security to the document signing process. BoldSign supports Email OTP, SMS OTP, and access code authentication to verify the signers. This guide will demonstrate how to mandate an access code verification from signers to validate their authority to sign the document.
The access code will be used when the sender wants to use a specific code to verify the signer. The access code must be communicated personally to the signer beforehand.
Here are some code examples which you can use to provide access code authentication for a document.
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", "authenticationType": "AccessCode", "authenticationCode": "1234", "formFields": [ { "id": "EditableDate", "name": "EditableDate", "fieldType": "EditableDate", "pageNumber": 1, "bounds": { "x": 200, "y": 200, "width": 125, "height": 25 }, "isRequired": true, "editableDateFieldSettings": { "dateFormat": "dd/MM/yyyy", "minDate": "2023-07-01T18:18:08.567Z", "maxDate": "2023-07-31T18:18:08.567Z" } } ], "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 EditableDateField = new FormField( id: "EditableDate", isRequired: true, type: FieldType.EditableDate, pageNumber: 1, bounds: new Rectangle(x: 200, y: 200, width: 125, height: 25), editableDateFieldSettings: new EditableDateFieldSettings(dateFormat:"dd/MM/yyyy", minDate: DateTime.Now, maxDate: DateTime.Now.AddDays(10))); var formFieldCollections = new List<FormField>() { EditableDateField }; var signer = new DocumentSigner( signerName: "David", signerEmail: "david@cubeflakes.com", formFields: formFieldCollections, authenticationType: AuthenticationType.AccessCode, authenticationCode: "1234", 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); 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", "authenticationType": "AccessCode", "authenticationCode": "1234", "formFields": [ { "id": "EditableDate", "name": "EditableDate", "fieldType": "EditableDate", "pageNumber": 1, "bounds": { "x": 200, "y": 200, "width": 125, "height": 25 }, "isRequired": True, "editableDateFieldSettings": { "dateFormat": "dd/MM/yyyy", "minDate": "2023-07-01T18:18:08.567Z", "maxDate": "2023-07-31T18:18:08.567Z" } } ], "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 fs = require('fs'); const FormData = require('form-data'); let formData = new FormData(); // Append Signers as an object, not a string formData.append('Signers', JSON.stringify({ name: "hanky", emailAddress: "hankyWhites@gmail.com", signerType: "Signer", signerRole: "Signer", authenticationType: "AccessCode", authenticationCode: "1234", formFields: [ { id: "EditableDate", name: "EditableDate", fieldType: "EditableDate", pageNumber: 1, bounds: { x: 100, y: 100, width: 125, height: 25 }, editableDateFieldSettings: { dateFormat: "dd/MM/yyyy", minDate: "2023-07-01T18:18:08.567Z", maxDate: "2023-07-31T18:18:08.567Z" }, isRequired: true } ], locale: "EN" })); // Append the file using a specific filename for the 'Files' property formData.append('Files', fs.createReadStream("{Your file path}"), { filename: '{Your file name}' }); formData.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}', 'Content-Type': 'multipart/form-data', ...formData.getHeaders() }, data: formData, }; axios.request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.error(error); });
In the above code examples set the authenticationType
to AccessCode
and provide a unique access code (e.g., "1234") in the authenticationCode
property. By executing any one of the above code examples, document will be sent to the signers. Signer can start the signing process after giving the access code that you have provided in the authenticationCode
.