Skip to navigation

Node.js SDK setup and configuration

View as Markdown

Learn about Quickstart and how you can use it to quickly set up and run eSignature REST API code examples.

Adding the SDK to your project

The Node.js eSignature SDK is provided as a package named docusign-esign. By default, you will always get the latest stable version of the SDK. Prerelease versions (either release candidate (rc) or beta) can also be downloaded as shown below.

There are three ways to add the package to your project: via your preferred console, your project’s package.json file, or by downloading the SDK from GitHub.

Adding the Node.js SDK to your project using your console

In your console, navigate to your project directory, then run: npm i -s docusign-esign

To specify a version using your console, you can use the @ syntax:

npm i -s docusign-esign@5.8.1

Adding the Node.js SDK to your project using your project’s package.json file

  1. In your application’s package.json file, add: "docusign-esign"
  2. Open your console, navigate to your project directory, then run: "npm install"

If desired, you can specify a version. For example, adding the following to your project’s package.json file installs version 5.8.1 of the Docusign Node.js eSignature SDK:

"docusign-esign": "5.8.1"

Downloading the Node.js SDK from the GitHub repository

This open-source SDK is available for download in cases where you would like to make changes to the SDK. You can download the SDK from GitHub using the instructions below:

  1. Download or clone the SDK from the docusign-esign-node-client repository.
  2. In the console, navigate to the docusign-esign-node-client directory, then run: npm install

You can also select a different version to download from the docusign-esign-node-client repository’s release history.

Including the SDK library

Once you have installed the docusign-esign package, you will need to find the public modules that are required to complete various eSignature tasks.

When using the Node.js package, you must add the following require statement in your Node.js code:

const docusign = require('docusign-esign')

Docusign eSignature API modules

These Node.js SDK modules contain endpoint categories. Each of these modules corresponds to one of the categories listed in the left menu of the eSignature REST API reference. You will need these modules to make calls to the SDK functions that initiate REST API calls to the Docusign eSignature REST API.

Hereafter in the SDK documentation, the term “API object” will refer to eSignature REST API reference objects.

An API category contains all methods for each API resource in that category. For example, the Node.js SDK EnvelopesApi module includes the Envelopes:create function. This function corresponds to the create method of the API Envelopes resource.

The Node.js SDK function names roughly correspond to the API Resource:method names.

The API Resource:method page for each endpoint lists the API SDK Method in the SDK Method box. The Node.js function name will be the camelCase version of the API SDK Method name. For example, the API SDK Method Envelopes::createEnvelope, listed toward the bottom of the Envelopes:create page, is the Node.js SDK function createEnvelope.

Some API endpoints also use HTTP query parameters. Within the API, such query parameters use snake_case. For example, the Envelopes:get API method includes an optional query parameter, advanced_update. Within the SDK, the API’s query parameters are added as an elective optsOrCallback parameter after the request object.

Example: The getEnvelope function signature is:

this.getEnvelope = function(accountId, envelopeId, optsOrCallback, callback)

The queryParams variable is used to set the API method’s query parameters.

var queryParams = {
'advanced_update': optsOrCallback['advancedUpdate'],
'include': optsOrCallback['include']
};

The Node.js SDK query parameters in snake_case correspond to the API endpoint’s query parameters.

Docusign eSignature Models

These models contain the objects used for sending and receiving data from the eSignature API endpoints. By using these models instead of generic JSON objects, Node.js developers can develop with the Docusign eSignature API more easily and quickly than by using JSON directly.

There’s a one-to-one correspondence between the objects described in the API Reference and the Node.js Docusign eSignature Models. The API object names use flatcase (all lowercase without spaces) while the corresponding SDK models use PascalCase (the first letter is uppercase). For example, the API object paymentgatewayaccount corresponds to the Node.js model PaymentGatewayAccount.

The API object name is often not the same as the corresponding model in the Node.js SDK.

Object attribute names in the API also use camelCase. The corresponding properties of the Node.js SDK are also in camelCase.

Docusign eSignature Client, OAuth, and Error functions

These functions are needed to manage the overall API experience. The Client, OAuth, and Error functions, respectively, handle instantiating a client element to make API calls, authentication, and exception handling. You will need these functions to be able to use the Docusign eSignature API correctly.

Using the SDK

To make eSignature REST API calls with the SDK, you need:

  • A current accessToken.
  • The basePath for the API call.
  • For most API calls, you’ll also need the relevant accountId. Note that it is common for a user to be a member of multiple accounts.