
Check out BoldSign at the Singapore Business Show, booth 716, on August 30 - 31! Learn More
Check out BoldSign at the Singapore Business Show, booth 716, on August 30 - 31! Learn More
In this blog post, we will guide you on how to embed the eSignature solution into your Python app using BoldSign APIs. Let’s assume a real-life scenario where you, as a business owner, have just secured a new customer. To finalize the deal, you need their signature on a contract.
Next, you’ll need an API key to authenticate your access. The API key is located on the API Key – BoldSign page. We will use this API key in our Python code later on.
You can either use your existing Python Flask application or build a new one:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'Hello, World!'
if __name__ == '__main__':
app.run(debug=True)
First, we should create a BoldSign template that will be used in the application to send documents out for signature. A new template can be created using BoldSign APIs or through the BoldSign web application. The template should include all the essential elements required for the customer contract signing scenario.
With all the necessary steps completed, we are now all set to embed the BoldSign for our customer contract signing scenario. We will incorporate the following functionalities in the application:
With the template successfully created for our scenario, we can now utilize the BoldSign send API to initiate the signing process. In the send API, it is necessary to provide the template ID and the required form details.
To implement this in our app.py route “/”, we can call the send template API to retrieve the template ID. Following is an example snippet of Python code that demonstrates this functionality.
@app.route('/', methods=('GET', 'POST'))
def home(name=None):
if request.method == 'POST':
data = {"templateId": '**templateId**', "customerName": request.form['customerName'], "companyName": request.form["companyName"],
"customerEmail": request.form['customerEmail'], "contractDetails": request.form['contractDetails'], "apikey": '**api-key**'}
# here you will get the documentid
documentId = getdocumentid(data)
def getdocumentid(data):
url = 'https://api.boldsign.com/v1/template/send?templateId=' + \
data["templateId"]
payload = json.dumps({
"title": "Customer Contract Signing",
"message": "Please sign the contract",
"roles": [
{
"roleIndex": 1,
"signerName": data["customerName"],
"signerEmail": data["customerEmail"],
"role": "Manager",
"existingFormFields": [
{
"id": "CustomerName",
"value": data["customerName"]
},
{
"id": "CompanyName",
"value": data["companyName"]
},
{
"id": "CustomerEmail",
"value": data["customerEmail"]
},
{
"id": "ContractDetails",
"value": data["contractDetails"]
}
]
}]})
headers = {
'X-API-KEY': data["apikey"],
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.json()["documentId"]
By utilizing the document ID and customer email address, we can generate an embedded signing link using the BoldSign getEmbeddedSignLink API. This link will be loaded into an iframe within the application, providing a seamless signing experience for the customer. Following is an example of how the Python code can be implemented.
def getsignlink(data):
url = "https://api.boldsign.com/v1/document/getEmbeddedSignLink?documentId=" + \
data["documentId"] + "&signeremail=" + data["customerEmail"] + \
"&redirectUrl=" + data["baseUrl"] + "response/"
headers1 = {
'X-API-KEY': data["apikey"],
}
response = requests.request("GET", url, headers=headers1, data={})
# here you can get the signLink for first signer
return response.json()["signLink"]
<iframe style='width: 100%; height:100%;' src="{{ iframe }}"></iframe>
The next screenshot shows the signing screen embedded in the application.
Once the signing process is successfully completed, you can download the signed document if you wish to save a copy for your records using the download API in BoldSign. The following code snippet illustrates this.
def downloadDocument(data):
url = "https://api.boldsign.com/v1/document/download?documentId=" + \
data["documentId"]
headers1 = {
'X-API-KEY': data["apikey"],
}
response = requests.request("GET", url, headers=headers1, data={})
We have successfully embed the eSignature solution into your Python application for customer contract signing by leveraging the power of BoldSign APIs. In a similar way, you can integrate BoldSign APIs into any of your projects to streamline the e-signing workflow. BoldSign offers a wide range of APIs, allowing you to track signature request statuses and access various other functionalities.
To learn more about BoldSign APIs, visit our API documentation. Live API demos are also available for several different scenarios. Sample code for popular programming languages is available in this GitHub repo.
If you have questions, you can contact us through our support portal. We are always happy to assist you!
Latest Articles
Send eSignature documents from bubble.io using BoldSign
Create Custom Form Fields to Speed Up Document Building with BoldSign
Top 10 Use Cases of eSignatures