Skip to content

Instantly share code, notes, and snippets.

@DSDevCenter
DSDevCenter / createEnvelopeFromTemplate.js
Created February 20, 2018 22:15
DocuSign Node.js SDK REST API Quickstart - Create envelope from Template
// 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}';
@DSDevCenter
DSDevCenter / createEnvelopeFromTemplate.cs
Last active February 20, 2018 22:17
DocuSign C# SDK REST API - Quickstart Create Envelope from Template
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";
// assign recipient to template role by setting name, email, and role name. Note that the
// template role name must match the placeholder role name saved in your account template.
TemplateRole tRole = new TemplateRole();
tRole.Email = "{USER_EMAIL}";
tRole.Name = "{USER_NAME}";
tRole.RoleName = "{ROLE}";
@DSDevCenter
DSDevCenter / createEnvelopeFromTemplate.java
Last active February 20, 2018 22:09
DocuSign Java SDK REST API Example - Quickstart Create Envelope from Template
// create a new envelope to manage the signature request
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.setEmailSubject("DocuSign Java SDK - Sample Signature Request");
// assign template information including ID and role(s)
envDef.setTemplateId("{TEMPLATE_ID}");
// create a template role with a valid templateId and roleName and assign signer info
TemplateRole tRole = new TemplateRole();
tRole.setRoleName("{ROLE}");
@DSDevCenter
DSDevCenter / createRecipientView.cs
Created February 20, 2018 03:07
DocuSign C# SDK Example - Create Recipient View (Embedded Signing URL) using eSignature REST API
RecipientViewRequest viewOptions = new RecipientViewRequest()
{
ReturnUrl = "https://www.docusign.com/",
ClientUserId = "1001", // must match clientUserId of the embedded recipient
AuthenticationMethod = "email",
UserName = "{USER_NAME}",
Email = "{USER_EMAIL}"
};
// instantiate an envelopesApi object
@DSDevCenter
DSDevCenter / createEnvelopeWithEmbeddedRecipient.cs
Last active February 20, 2018 03:33
DocuSign C# SDK Example - Create Envelope with Embedded Recipient using eSignature REST API
// Read a file from disk to use as a document.
byte[] fileBytes = File.ReadAllBytes("/Path/To/Document");
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";
// Add a document to the envelope
Document doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = "TestFile.pdf";
@DSDevCenter
DSDevCenter / createRecipientView.java
Created February 20, 2018 03:03
DocuSign Java SDK Example - Create Recipient View (Signing URL) using eSignature REST API
// instantiate a new EnvelopesApi object
EnvelopesApi envelopesApi = new EnvelopesApi();
// set the url where you want the recipient to go once they are done signing
RecipientViewRequest view = new RecipientViewRequest();
view.setReturnUrl("https://www.docusign.com");
view.setAuthenticationMethod("email");
// recipient information must match embedded recipient info we provided in step #2
view.setEmail("[RECIPIENT_EMAIL]");
@DSDevCenter
DSDevCenter / createEnvelopeWithEmbeddedRecipient.java
Created February 20, 2018 03:02
DocuSign Java SDK Example - Create Envelope with Embedded Recipient using eSignature REST API
// create a byte array that will hold our document bytes
byte[] fileBytes = null;
String pathToDocument = "[PATH/TO/DOCUMENT]";
try
{
String currentDir = System.getProperty("user.dir");
// read file from a local directory
Path path = Paths.get(currentDir + pathToDocument);
@DSDevCenter
DSDevCenter / createRecipientView.js
Last active June 10, 2021 19:35
DocuSign NODE SDK Create Recipient View Example (Embedded Signing) for eSignature REST API
// instantiate a new EnvelopesApi object
var envelopesApi = new docusign.EnvelopesApi();
// set the url where you want the recipient to go once they are done signing
// should typically be a callback route somewhere in your app
var viewRequest = new docusign.RecipientViewRequest();
viewRequest.returnUrl = 'https://www.docusign.com/';
viewRequest.authenticationMethod = 'email';
// recipient information must match embedded recipient info we provided in step #2
@DSDevCenter
DSDevCenter / createEnvelopeWithEmbeddedRecipient.js
Last active February 20, 2018 03:24
DocuSign NODE SDK Create Envelope with embedded recipient
// create a byte array that will hold our document bytes
var fileBytes = null;
try {
var fs = require('fs');
var path = require('path');
// read file from a local directory
fileBytes = fs.readFileSync(path.resolve(__dirname, "test.pdf"));
// fileBytes = fs.readFileSync(path.resolve(__dirname, "[PATH/TO/DOCUMENT]"));
} catch (ex) {
// handle error
@DSDevCenter
DSDevCenter / NodeSDKSamples.js
Created February 20, 2018 02:02
DocuSign NODE SDK Examples - DocuSign eSignature REST API
const express = require('express');
const passport = require('passport');
var session = require('express-session');
var docusign = require('./src/index');
const app = express();
const port = process.env.PORT || 3000;
const host = process.env.HOST || 'localhost';
app.use(session({