How to add a file as a base64 string when sending a document for signature?
BoldSign allows you to send files in base64 string format for e-signature using the files
property. The .pdf, .png, .jpg, and .docx are supported file formats. The preferred file format is .pdf. You can refer the following link for supported file formats. The base64 format should be in the following format data:application/{{fileType}};base64,{{content}}
.
Here is an example demonstrating how to add a file as a base64 string when sending a document for e-signature using BoldSign API:
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: application/json' \ -d '{ "Message": "Please sign this.", "Signers": [ { "name": "Alex", "emailAddress": "alexgayle@cubeflakes.com", "signerType": "Signer", "formFields": [ { "id": "sign1", "name": "sign1", "fieldType": "Signature", "pageNumber": 1, "bounds": { "x": 50, "y": 50, "width": 125, "height": 25 }, "isRequired": true } ], "locale": "EN" } ], "Files": [ "data:application/pdf;base64,JVBERi0xLjcKJcfs..." ], "Title": "Agreement" }'
import requests import json url = "https://api.boldsign.com/v1/document/send" signer_data = { "name": "Alex", "emailAddress": "alexgayle@cubeflakes.com", "signerType": "Signer", "formFields": [ { "id": "sign1", "name": "sign1", "fieldType": "Signature", "pageNumber": 1, "bounds": { "x": 50, "y": 50, "width": 200, "height": 25 }, "isRequired": True } ], "locale": "EN" } payload = { 'Message': 'Please sign this.', 'Signers': [signer_data], 'Title': 'Agreement', 'Files': [ 'data:application/pdf;base64,JVBERi0xLjcNCi...' ] } headers = { 'Content-Type': 'application/json', 'accept': 'application/json', 'X-API-KEY': '{Your API Key}' } response = requests.post(url, headers=headers, json=payload) print(response.text)
const axios = require('axios'); const url = "https://api.boldsign.com/v1/document/send"; const signerData = { "name": "Alex", "emailAddress": "alexgayle@cubeflakes.com", "signerType": "Signer", "formFields": [ { "id": "string", "name": "string", "fieldType": "Signature", "pageNumber": 1, "bounds": { "x": 50, "y": 50, "width": 200, "height": 25 }, "isRequired": true } ], "locale": "EN" }; const payload = { 'Message': 'Please sign this.', 'Signers': [signerData], 'Title': 'Agreement', 'Files': [ 'data:application/pdf;base64,JVBERi0xLjcNCi...' ] }; const headers = { 'Content-Type': 'application/json', 'accept': 'application/json', 'X-API-KEY': '{Your API Key}' }; axios.post(url, payload, { headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error:', error); });
In the provided code examples, make sure to replace the SignerEmail
and SignerName
properties with the email and name of the signer you wish to send the document. After executing the above code, you can send the base64 string format file for signature request.