DocuSign Node Client
NPM module that wraps the DocuSign API
Documentation about the DocuSign API
Documentation about this package
You can sign up for a free developer sandbox.
============
Requirements
Node 4.2 or later.
Installation
NPM Package Manager
Install the client locally: npm install docusign-esign --save --save-exact
(note you may have to use sudo
based on your permissions)
Alternatively you can just copy the source code directly into your project.
Dependencies
This client has the following external dependencies:
Usage
To initialize the client, make the Login API Call and send a template for signature:
var docusign = require('docusign-esign');
var async = require('async');
var integratorKey = '***',
email = 'YOUR_EMAIL',
password = 'YOUR_PASSWORD',
docusignEnv = 'demo',
fullName = 'Joan Jett',
recipientEmail = 'joan.jett@example.com',
templateId = '***',
templateRoleName = '***',
debug = false;
var templateRoles = [{
email: email,
name: fullName,
roleName: templateRoleName
}];
var additionalParams = {};
var baseUrl = "https://demo.docusign.net/restapi";
var apiClient = new docusign.ApiClient();
apiClient.setBasePath(baseUrl);
const creds = "{\"Username\":\"" + email + "\",\"Password\":\"" + password + "\",\"IntegratorKey\":\"" + integratorKey + "\"}";
apiClient.addDefaultHeader("X-DocuSign-Authentication", creds);
docusign.Configuration.default.setDefaultApiClient(apiClient);
async.waterfall([
function login (next) {
var authApi = new docusign.AuthenticationApi();
var loginOps = new authApi.LoginOptions();
loginOps.setApiPassword("true");
loginOps.setIncludeAccountIdGuid("true");
authApi.login(loginOps, function (error, loginInfo, response) {
if (err) {
return next(err);
}
if (loginInfo) {
var loginAccounts = loginInfo.getLoginAccounts();
console.log("LoginInformation: " + JSON.stringify(loginAccounts));
next(null, loginAccounts);
}
});
},
function sendTemplate (loginAccounts, next) {
var envDef = new docusign.EnvelopeDefinition();
envDef.setEmailSubject("Please sign this document sent from Node SDK)");
envDef.setTemplateId(templateId);
var tRole = new docusign.TemplateRole();
tRole.setRoleName(templateRoleName);
tRole.setName(signerName);
tRole.setEmail(signerEmail);
var templateRolesList = [];
templateRolesList.push(tRole);
envDef.setTemplateRoles(templateRolesList);
envDef.setStatus("sent");
var loginAccount = new docusign.LoginAccount();
jloginAccount = loginAccounts[0];
var accountId = loginAccount.accountId;
var envelopesApi = new docusign.EnvelopesApi();
envelopesApi.createEnvelope(accountId, envDef, null, function (error, envelopeSummary, response) {
if (err) {
return next(err);
}
console.log("EnvelopeSummary: " + JSON.stringify(envelopeSummary));
next(null);
});
}
], function end (error) {
if (error) {
console.log('Error: ', error);
process.exit(1)
}
process.exit()
});
See CoreRecipes.js for more examples.
Testing
Unit tests are available in the Test folder.
Support
Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the DocuSignAPI tag.
License
The DocuSign Node Client is licensed under the following License.
Notes
This version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see Omitted Endpoints.