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
BoldSign Logo Small

Features

Explore the BoldSign features that make eSigning easier.

Integrating eSignatures into Your Node.js Application

Integrating eSignatures into Your Node.js Application

By integrating eSignatures into your Node.js application, you can easily carry out the entire electronic signature process within your app. This empowers you and your users to perform all eSignature functionalities, including sending signature requests, signing documents, tracking document statuses, and downloading signed documents. You will streamline the eSignature workflow and eliminate the need for third-party applications, enhancing efficiency and productivity.

In this blog post, we’ll guide you through the process of integrating eSignatures into your Node.js applicaion using BoldSign, an advanced eSignature solution. With a comprehensive suite of APIs, BoldSign makes it easy to integrate electronic signing capabilities into your existing applications.

To demonstrate the benefits of integrating eSignatures, let’s take a real-life situation where you are a software developer working for a real estate agency. Your agency deals with numerous contracts and agreements that require signatures from agents, buyers, sellers, and other parties involved. Managing the signing process manually can be time-consuming, error-prone, and reduce the agency’s efficiency. However, with an eSignature application built with Node.js and BoldSign, you can reduce these downsides.

Getting started

To begin integrating eSignatures into your Node.js application using the BoldSign APIs, you’ll need the following prerequisites:

  • Node.js: Ensure that Node.js is installed on your machine.
  • BoldSign account: This can either be a paid account or a free sandbox account. If you don’t have one, you can sign up for a free sandbox account.
  • BoldSign API key: You will need an API key to authenticate your access. You can generate one on the API Key – BoldSign page.

Setting up the Node.js project

If you wish to integrate eSignatures into your existing application, you can skip this step and move to the next one. Otherwise, begin by creating a new directory for your project and initializing a new Node.js project. Install the required dependencies by running the following command.

    
npm install express axios dotenv
    
  • Express: A web application framework for Node.js.
  • Axios: A promise-based HTTP client for making API requests.
  • Dotenv: A module for loading environment variables from a .env file.

These dependencies will enable you to create a server, handle API requests, and load environment variables effectively.

Integrating the BoldSign API

To configure your environment variables, create a .env file in your project directory if you haven’t already done so. Open the file and include your BoldSign API key that you generated previously and your base URL. This ensures secure communication between your Node.js application and the BoldSign API.

    
BOLDSIGN_API_KEY=<API Key>
BOLDSIGN_BASE_URL=<Base URL>
    

Integrating the eSignatures into your Node.js application

Now that you have set up the Node.js project, we can integrate the eSignature functionalities into the application using BoldSign APIs.

To expedite the document-creation process for the real estate agency’s contracts, you can utilize a preconfigured template. You have the option to create the templates using either BoldSign for web or the BoldSign API.

Ensure that the templates you create include all the necessary information and fields required to complete your contracts or agreements. By including all the essential details in the templates, you can simplify the document preparation process and facilitate efficient completion of agreements.

Creating template for Real-Estate Scenario
Creating template for real estate scenario

Implementing document creation

Let’s proceed with implementing the document creation in your Node.js application. We need to create a dedicated route or API endpoint to handle this task. To accomplish this, leverage the Axios library for seamless HTTP communication with the BoldSign API endpoints.

Here’s an example code snippet of how you can create a document from a template in your Node.js application.

    
import express from 'express';
…
// Import required modules

// Define route for document creation
app.post('/create-document', async (req, res) => {
  const sendUrl = 'https://api.boldsign.com/v1/template/send/';
  const headers = {
    'X-API-KEY': process.env.BOLDSIGN_API_KEY,
    'Content-Type': 'application/json',
  };

  // Extract necessary data from request body
  const { sellerName, sellerEmail, buyerName, buyerEmail, amount, address, templateId } = req.body;

  const data = {
    roles: [
      {
        roleIndex: 1,
        signerName: sellerName,
        signerEmail: sellerEmail,
        existingFormFields: [
          {
            id: '<labelField1>',
            value: address,
          },
          {
            id: '<labelField2>',
            value: amount,
          },
        ],
      },
      {
        roleIndex: 2,
        signerName: buyerName,
        signerEmail: buyerEmail,
      },
    ],
    disableEmails: true,
  };
  
  // Create the document using BoldSign API.
  const response = await axios.post(sendUrl, data, {
    headers: headers,
    params: { templateId: templateId },
  });
  
  const docId = response.data.documentId;
  res.status(200).json({ success: true }); // Send a success response
});    

Generating the embedded signing URL

By default, BoldSign sends an email to the signers requesting them to sign and complete the contracts within the BoldSign application. Alternatively, you can use embedded signing by specifying the disableEmails parameter. This instructs BoldSign not to send emails to the signers, allowing you to configure the email process from your end once the document is created.

Embedding eSignature application with Node.js
Signing page embedded in an application

Here is an example code snippet to get the embedded sign link in a Node.js application.

    
const embedSignUrl = 'https://api.boldsign.com/v1/document/getEmbeddedSignLink/';

// If a redirect URL is specified, the iFrame will redirect users to it after they sign the document.
const redirectUrl = '{your-host}/{your-redirect-path}';

const headers = {
    'X-API-KEY': process.env.BOLDSIGN_API_KEY,
    'Content-Type': 'application/json',
  };

// Get the embedded signing URL.
const result = await axios.get(embedSignUrl, {
  headers: headers,
  params: { documentId: docId, signerEmail: sellerEmail, redirectUrl: redirectUrl },
});

const signUrl = response.data.signLink;

// Send the email using this sign link.    

To seamlessly integrate the signing process into your application, load the sign page URL, within an iframe on your application. This allows the recipient to interact with the signing page without leaving your site.

Integrate webhooks to download completed documents

You can integrate webhooks into your Node.js application to automate the process of downloading completed PDF documents and efficiently distribute them to the relevant parties. By subscribing to the DocumentCompleted event, which is triggered after all parties have signed the document, and the final PDF file is generated.

    
const axios = require('axios');

const headers = {
    'X-API-KEY': process.env.BOLDSIGN_API_KEY,
    'Content-Type': 'application/json',
};

const response = await axios.get('https://api.boldsign.com/v1/document/download', {
    params: {
        'documentId': '<documentId>'
    },
    headers: headers
});   

Upon receiving the Download Document API response, you can send emails containing the completed PDF files to the relevant parties. With webhooks in place, you can ensure timely delivery of signed documents to the concerned stakeholders, simplifying your document management process.

Conclusion

By leveraging the power of BoldSign, companies like real estate agencies can inegrate eSignatures into your Node.js application and can streamline the contract signing process. Irrespective of your industry or scenario, the steps outlined in this blog post enable you to seamlessly integrate BoldSign into your Node.js application, enhancing the eSignature experience of your users.

To learn more about the BoldSign APIs, check out our API documentation. Live API demos are also available for several 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!

Picture of Karthick Ramasamy

Karthick Ramasamy

I am an experienced full-stack developer with 7 years of hands-on expertise in .NET Core and JavaScript. My passion lies in crafting top-notch and highly efficient programs. I derive great satisfaction from solving technical challenges and continuously seek to expand my knowledge in software development. Outside of work, I find joy in embarking on journeys that take me over mountains.

Share this blog

Picture of Karthick Ramasamy

Karthick Ramasamy

I am an experienced full-stack developer with 7 years of hands-on expertise in .NET Core and JavaScript. My passion lies in crafting top-notch and highly efficient programs. I derive great satisfaction from solving technical challenges and continuously seek to expand my knowledge in software development. Outside of work, I find joy in embarking on journeys that take me over mountains.

Subscribe RSS feed

Leave a Reply

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