BoldSign AI Assistant
Chat with the BoldSign AI AssistantAdd File as Base64 When Sending a Document
BoldSign allows you to send files in base64 string format for e-signature using the files property. The .pdf, .png, .jpg, .docx, .xlsx and .pptx 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": "[email protected]",
"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 boldsign
import base64
configuration = boldsign.Configuration(host = "https://api.boldsign.com", api_key="YOUR_API_KEY")
with boldsign.ApiClient(configuration) as api_client:
document_api = boldsign.DocumentApi(api_client)
# Base64 string of the file (Ensure it is just the content, without the data:application/pdf;base64, prefix)
base64_string = "JVBERi0xLjcNCi..."
file_bytes = base64.b64decode(base64_string)
send_for_sign = boldsign.SendForSign(
title="Agreement",
message="Please sign this.",
files=[file_bytes],
signers=[
boldsign.DocumentSigner(
name="Alex",
emailAddress="[email protected]",
signerType="Signer",
formFields=[
boldsign.FormField(
id="sign1",
name="sign1",
fieldType="Signature",
pageNumber=1,
bounds=boldsign.Rectangle(x=50, y=50, width=200, height=25),
isRequired=True
)
]
)
]
)
document_created = document_api.send_document(send_for_sign)
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.