The BoldSign mobile app is now available. Visitthis link for more details and give it a try!

The BoldSign mobile app is now available. Visitthis link for more details and give it a try!

Request Demo

Features

Explore the BoldSign features that make eSigning easier.

Embed the BoldSign eSignature Solution into Your Python App Banner

How to Embed an eSignature Solution into Your Python Application

Embedding the BoldSign eSignature process into your application will enhance your eSignature workflow and streamline the signing experience of your customers. They can sign the documents directly in your application, eliminating the need to switch to other third-party platforms. This seamless integration builds trust in your security and eliminates the hassle of navigating multiple applications for completing the signing process.
In this blog post, we will guide you on how to embed BoldSign into your Python application 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.

Prerequisites

Before we begin building the application, we need to ensure the following prerequisites are in place:

Setting up a BoldSign account

To use BoldSign APIs, you’ll need a BoldSign account. The account can be either a paid or a free sandbox account. If you haven’t created a BoldSign account yet, you can easily sign up for a free account right now.

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.

Setting up a Python Flask application

You can either use your existing Python Flask application or build a new one:

  1. Create a new directory for the application.
  2. Inside the newly created directory, create a new Python file named app.py.
  3. Open the app.py file and import the necessary modules for your Flask application. Here's an example snippet.
        
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
    return 'Hello, World!'
if __name__ == '__main__':
    app.run(debug=True)

Embedding the eSignature process into the Python app

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.

cubeflakes-customer-sample-form
Once the template has been created, we should note down the template ID, which we’ll use in our Python code later.

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:

  • Sending the document to the customer for signing.
  • Embedding the signing process into the app.
  • Downloading the signed document within the app.

Sending the document out for signature

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"]

The getdocumentid function retrieves the document ID, which is required to generate the embedded signing link.

Embed the signing process into the app

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.

cubeflakes-review-and-sign-sample

Downloading the document

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={})

Conclusion

We have successfully embedded the BoldSign eSignature solution into a 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 eSigning 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 documentationLive 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!

Share this blog

Subscribe RSS feed

Leave a Reply

Your email address will not be published. Required fields are marked *