Skip to content

Instantly share code, notes, and snippets.

@Ergin008
Ergin008 / LoginAPI.js
Last active March 22, 2016 17:34
code snippets that shows how to call the Login API using DocuSign-node NPM client
var docusign = require('docusign-esign');
var async = require('async');
var integratorKey = '[INTEGRATOR_KEY]', // Integrator Key associated with your DocuSign Integration
email = '[EMAIL]', // Email for your DocuSign Account
password = '[PASSWORD]', // Password for your DocuSign Account
recipientName = '[RECIPIENT_NAME]', // Recipient's Full Name
recipientEmail = '[RECIPIENT_EMAIL]'; // Recipient's Email
var basePath = "https://demo.docusign.net/restapi";
@Ergin008
Ergin008 / requestSignature.js
Last active September 22, 2015 19:32
full code sample that shows how to request a signature on a document using the docusign-node client: https://www.npmjs.com/package/docusign-node
// Install NPM package or download source
// https://www.npmjs.com/package/docusign-node
var docusign = require('docusign-node');
var async = require('async');
var assert = require('assert');
var fs = require('fs');
var integratorKey = "INTEGRATOR_KEY";
var email = "EMAIL";
@Ergin008
Ergin008 / CreateAndSendEnvelope.js
Last active March 22, 2016 17:35
code snippet that shows how to create and send an envelope from a document using the docusign-node client
function createAndSendEnvelope (loginAccounts, next) {
var fileBytes = null;
try {
var fs = require('fs'),
path = require('path');
// read file from a local directory
fileBytes = fs.readFileSync(path.resolve(__filename + '/..' + SignTest1File));
} catch (ex) {
@Ergin008
Ergin008 / embeddedSigning.js
Last active September 22, 2015 19:29
Full code sample that shows how to embed the document signing flow using the docusign-node client: https://www.npmjs.com/package/docusign-node
// Install NPM package or download source
// https://www.npmjs.com/package/docusign-node
var docusign = require('docusign-node');
var async = require('async');
var assert = require('assert');
var fs = require('fs');
var integratorKey = "INTEGRATOR_KEY";
var email = "EMAIL";
@Ergin008
Ergin008 / CreateEnvelopeWithEmbeddedRecipient.js
Last active March 22, 2016 17:35
code snippet that shows how to create an envelope with an embedded recipient using the DocuSign Node Client
function createAndSendEnvelopeWithEmbeddedRecipient (loginAccounts, next) {
var fileBytes = null;
try {
var fs = require('fs'),
path = require('path');
// read file from a local directory
fileBytes = fs.readFileSync(path.resolve(__filename + '/..' + SignTest1File));
} catch (ex) {
@Ergin008
Ergin008 / getRecipientView.js
Last active October 18, 2017 12:02
code snippets that shows how to request a recipient view (signing URL) using the DocuSign Node Client
function requestRecipientView (envelopeId, loginAccounts, next) {
// set where the recipient should be re-directed once they are done signing
const returnUrl = "http://www.docusign.com/developer-center";
var recipientView = new docusign.RecipientViewRequest();
recipientView.setReturnUrl(returnUrl);
recipientView.setUserName("[RECIPIENT_NAME]");
recipientView.setEmail("[RECIPIENT_EMAIL]");
recipientView.setAuthenticationMethod("email");
@Ergin008
Ergin008 / GetAuthorizationCode.java
Last active February 9, 2018 20:37
DocuSign API Authorization Code Grant Sample in demo (sandbox) environment.
// integrator keys are created through developer sandbox accounts then migrated
// to your production account when ready. Note that your integrator key also acts
// as your client ID during oauth requests
String IntegratorKey = "{integratorKey}";
// generate a client secret for the integrator key you supply above, again through sandbox admin menu
String ClientSecret = "{clientSecret}";
// must match a redirect URI (case-sensitive) you configured on the key
String RedirectURI = "https://yourapp.com/callback";
@Ergin008
Ergin008 / GetAccessToken.java
Last active February 9, 2018 06:02
Step 2 of DocuSign Auth Code Grant, uses the code that was generated from auth_code request
// Use the authorization code that was added as a query param to the redirect URI.
// from the previous request. You should set up a route that handles the redirect
// and parses the code so you can then pass it to token endpoint:
String code = "{ENTER_YOUR_AUTHORIZATION_CODE}";
// assign it to the token endpoint
apiClient.getTokenEndPoint().setCode(code);
// optionally register to get notified when a new token arrives
apiClient.registerAccessTokenListener(new AccessTokenListener() {
@Ergin008
Ergin008 / GetBaseUri.java
Created February 9, 2018 05:50
Get your DocuSign account's base URI and configure api client
AuthenticationApi authApi = new AuthenticationApi(apiClient);
LoginInformation loginInfo = authApi.login();
// note that the user might belong to multiple accounts, here we simply get first
String accountId = loginInfo.getLoginAccounts().get(0).getAccountId();
String baseUrl = loginInfo.getLoginAccounts().get(0).getBaseUrl();
// important: below code is required for production as the account sub-domains vary in the
// live system. We strip the base URI down to the form https://{env}.docusign.net/restapi
// then re-configure the api client with the new base path
@Ergin008
Ergin008 / soap_create_envelope.cs
Created February 12, 2018 21:54
SOAP Create Envelope (C#)
// Create the recipient
DocuSignWeb.Recipient recipient = new DocuSignWeb.Recipient();
recipient.Email = "Test email";
recipient.UserName = "Testing account";
recipient.Type = DocuSignWeb.RecipientTypeCode.Signer;
recipient.ID = "1";
recipient.RoutingOrder = 1;
// Need to specify captive info to embed the recipient
recipient.CaptiveInfo = new DocuSignWeb.RecipientCaptiveInfo();