Created
February 20, 2018 22:15
-
-
Save DSDevCenter/326f0a962eb118e2e9cfc44cea1efc9b to your computer and use it in GitHub Desktop.
DocuSign Node.js SDK REST API Quickstart - Create envelope from Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a new envelope object that we will manage the signature request through | |
var envDef = new docusign.EnvelopeDefinition(); | |
envDef.emailSubject = 'Please sign this document sent from Node SDK'; | |
envDef.templateId = '{TEMPLATE_ID}'; | |
// create a template role with a valid templateId and roleName and assign signer info | |
var tRole = new docusign.TemplateRole(); | |
tRole.roleName = '{ROLE}'; | |
tRole.name = '{USER_NAME}'; | |
tRole.email = '{USER_EMAIL}'; | |
// set the clientUserId on the recipient to mark them as embedded (ie we will generate their signing link) | |
tRole.clientUserId = '1001'; | |
// create a list of template roles and add our newly created role | |
var templateRolesList = []; | |
templateRolesList.push(tRole); | |
// assign template role(s) to the envelope | |
envDef.templateRoles = templateRolesList; | |
// send the envelope by setting |status| to 'sent'. To save as a draft set to 'created' | |
envDef.status = 'sent'; | |
// use the |accountId| we retrieved through the Login API to create the Envelope | |
var accountId = accountId; | |
// instantiate a new EnvelopesApi object | |
var envelopesApi = new docusign.EnvelopesApi(); | |
// call the createEnvelope() API | |
envelopesApi.createEnvelope(accountId, {'envelopeDefinition': envDef}, function (err, envelopeSummary, response) { | |
if (err) { | |
return next(err); | |
} | |
console.log('EnvelopeSummary: ' + JSON.stringify(envelopeSummary)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment