Skip to content

scott-mueller/Docusign-Demo

Repository files navigation

Node.js Launcher Code Examples

This GitHub repo includes code examples for both the DocuSign eSignature REST API and the DocuSign Rooms API.

To use the Rooms API code examples, modify the exampleAPI setting at the end of the config/appsettings.json file to rooms.

Note: To use the Rooms API, you must also create your DocuSign developer account for Rooms.

Introduction

This repo is a Node.js application that supports the following authentication workflows:

  • Authentication with DocuSign via Authorization Code Grant. When the token expires, the user is asked to re-authenticate. The refresh token is not used.

  • Authentication with DocuSign via JSON Web Token (JWT) Grant. When the token expires, it updates automatically.

eSignature API

For more information about the scopes used for obtaining authorization to use the eSignature API, see the Required Scopes section.

  1. Use embedded signing. Source
    Sends an envelope, then uses embedded signing for the first signer. With embedded signing, DocuSign signing is initiated from your website.
  2. Request a signature by email (Remote Signing). Source
    The envelope includes a PDF, Word, and HTML document. Anchor text is used to position the signing fields in the documents.
  3. List envelopes in the user's account. Source
    The envelopes' current status is included.
  4. Get an envelope's basic information. Source
    Lists basic information about an envelope, including its overall status.
  5. List an envelope's recipients Source
    Includes current recipient status.
  6. List an envelope's documents. Source
    Includes current recipient status.
  7. Download an envelope's documents. Source
    Downloads individual documents, the documents concatenated together, or a ZIP file of the documents.
  8. Programmatically create a template. Source
  9. Request a signature by email using a template. Source
  10. Send an envelope and upload its documents with multipart binary transfer. Source
    Binary transfer is 33% more efficient than using Base64 encoding.
  11. Use embedded sending. Source
    Embeds the DocuSign UI in your web app to finalize or update the envelope and documents before they are sent.
  12. Embed the DocuSign UI in your app. Source
  13. Use embedded signing from a template with an added document. Source
    Sends an envelope based on a template. In addition to the template's document(s), this example adds an additional document to the envelope by using the Templates feature.
  14. Accept payments. Source
    Sends an order form with online payment by credit card.
  15. Get envelope tab data. Source
    Retrieves the tab (field) values for all of the envelope's recipients.
  16. Set envelope tab values. Source
    Creates an envelope and sets the initial values for its tabs (fields). Some of the tabs are set to be read-only, others can be updated by the recipient. This example also stores metadata with the envelope.
  17. Set template tab values. Source
    Creates an envelope using a template and sets the initial values for its tabs (fields). This example also stores metadata with the envelope.
  18. Get the envelope custom field data (metadata). Source
    Retrieves the custom metadata (custom data fields) stored with the envelope.
  19. Require an access code for a recipient. Source
    Sends an envelope that requires entering an access code for the purpose of multifactor authentication.
  20. Require SMS authentication for a recipient. Source
    Sends an envelope that requires entering a six-digit code from an text message for the purpose of multifactor authentication.
  21. Require phone authentication for a recipient. Source
    Sends an envelope that requires entering a voice-based response code for the purpose of multifactor authentication.
  22. Require knowledge-based authentication (KBA) for a recipient. Source
    Sends an envelope that requires passing a public records check to validate identity for the purpose of multifactor authentication.
  23. Require ID Verification (IDV) for a recipient. Source
    Sends an envelope that requires the recipient to upload a government-issued ID for the purpose of multifactor authentication.
  24. Create a permission profile. Source
  25. Set a permission profile. Source
    Demonstrates how to set a user group's permission profile. You must have already created a permission profile and a group of users.
  26. Update individual permission settings. Source
    Demonstrates how to edit individual permission settings on a permission profile.
  27. Delete a permission profile. Source
  28. Create a brand. Source
    Creates a brand profile for an account.
  29. Apply a brand to an envelope. Source
    Demonstrates how to apply a brand you've created to an envelope. First, this example creates the envelope, then applies the brand to it. Anchor text is used to position the signing fields in the documents.
  30. Apply a brand to a template. Source
    Demonstrates how to apply a brand you've created to a template. You must have at least one created template and brand. Anchor text is used to position the signing fields in the documents.
  31. Bulk-send envelopes to multiple recipients. Source
    Demonstrates how to send envelopes in bulk to multiple recipients. First, this example creates a bulk-send recipients list, then creates an envelope. After that, it initiates bulk envelope sending.
  32. Pausing a signature workflow. Source
    Demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.
  33. Unpausing a signature workflow. Source
    Demonstrates how to update an envelope to resume the workflow that has been paused using the Update Envelope method. You must have created at least one envelope with a paused signature workflow to run this example.
  34. Using conditional recipients. Source
    Demonstrates how to create an envelope where the workflow is routed to different recipients based on the value of a transaction using the Create Envelope method.
  35. Request a signature by SMS delivery Source
    Demonstrates how to send a signature request via an SMS message using the Envelopes: create method.

Rooms API

For more information about the scopes used for obtaining authorization to use the Rooms API, see the Required Scopes section.

Note: To use the Rooms API, you must also create your DocuSign Developer Account for Rooms. Examples 4 and 6 require that you have the DocuSign Forms feature enabled in your Rooms for Real Estate account.

  1. Create a room with data. Source
    Creates a new room in your DocuSign Rooms account to be used for a transaction.
  2. Create a room from a template. Source
    Creates a new room using a template.
  3. Export data from a room. Source.
    Exports all the available data from a specific room in your DocuSign Rooms account.
  4. Add a form to a room. Source.
    Adds a standard real estate-related form to a specific room in your DocuSign Rooms account.
  5. Search for a room with a filter. Source
    Searches for a room in your DocuSign Rooms account using a specific filter.
  6. Create an external form fillable session. Source
    Creates an external form that can be filled using DocuSign for a specific room in your DocuSign Rooms account.
  7. Creating a form group. Source.
    Creates a new form group with the name given in the name property of the request body.
  8. Grant office access to a form group. Source.
    Assigns an office to a form group for your DocuSign Rooms.
  9. Assign a form to a form group. Source.
    Assigns a form to a form group for your DocuSign Rooms.

Click API:

For more information about the scopes used for obtaining authorization to use the Click API, see the Required Scopes section.

  1. Create a clickwrap. Source
    Demonstrates how to create a clickwrap that you can embed in your website or app.
  2. Activate a clickwrap. Source
    Demonstrates how to activate a new clickwrap. By default, new clickwraps are inactive. You must activate your clickwrap before you can use it.
  3. Create a new clickwrap version. Source
    Demonstrates how to use the Click API to create a new version of a clickwrap.
  4. Get a list of clickwraps. Source
    Demonstrates how to get a list of clickwraps associated with a specific DocuSign user.
  5. Get clickwrap responses. Source
    Demonstrates how to get user responses to your clickwrap agreements.

Monitor API

Note: To use the Monitor API, you must also enable DocuSign Monitor for your organization.
For information about the scopes used for obtaining authorization to use the Monitor API, see the scopes section.

  1. Get monitoring data. Source
    Demonstrates how to get and display all of your organization’s monitoring data.

Installation

Prerequisites

Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip items 1 and 2 below as they're automatically performed for you.

  1. Create a DocuSign developer account if you don't already have one.

  2. A DocuSign integration key (client ID) that is configured for authentication to use either Authorization Code Grant or JWT Grant.

    To use Authorization Code Grant, you will need an integration key and its secret key.

    To use JWT Grant, you will need an integration key, an RSA key pair, and the API Username GUID of the impersonated user. See Configure JWT below for detailed steps.

    For both authentication flows:

    If you use this launcher on your own workstation, the integration key must include a redirect URI of http://localhost:5000/ds/callback

    If you will not be running the example on your own workstation, use the appropriate DNS name and port instead of localhost.

  3. Node.js version 8.10 or later with npm version 5 or later.

  4. A name and email for a signer, and a name and email for a cc recipient.

Installation steps

Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip step 4 below as it was automatically performed for you.

  1. Extract the Quickstart ZIP file or download or clone the code-examples-node repository.

  2. Switch to the folder: cd <Quickstart_folder_name> or cd code-examples-node

  3. Run npm install

  4. Create a new file config/appsettings.json by using config/appsettings.example.json as your template. Update config/appsettings.json with your integration key GUID and other settings.

    Note: Protect your integration key and secret and/or RSA private key pair; ensure that config/appsettings.json will not be stored in your source code repository.

  5. npm start

  6. Open a browser to http://localhost:5000

Configure JWT

  1. Create a new integration key on the Apps and Keys page and save the GUID to a secure location for step 5 below.
  2. Set a redirect URI of http://localhost:5000/ds/callback
  3. Generate an RSA key pair. Under Apps and Integration Keys, choose the integration key to use, then select Actions, then Edit. In the Authentication section, select ADD RSA KEYPAIR. Save the private key to a secure location for the next step.
  4. Create a new file config/private.key, then save your RSA private key in it.
  5. Update the file config/appsettings.json with your integration key GUID from step 1 as your dsJWTClientId and your API Username from the Apps and Keys page as your impersonatedUserGuid.
  6. Run the launcher using npm start, then select JSON Web Token when authenticating your account.

Payments code example

To use the payments example, create a test payments gateway for your DocuSign developer account. See PAYMENTS_INSTALLATION.md for instructions.

Then add the Gateway Account ID to the config/appsettings.json file.

Unit Testing

  1. Before running the unit tests you will need to obtain an access token and an API Account ID.
  2. Either:
    • Update the file test/testHelpers.js in the project's root folder with the access token, API Account ID, signer and cc information, or
    • Create and export this information as the environment variables named in that file.
  3. Run npm test

License and additional information

License

This repository uses the MIT License. See the LICENSE file for more information.

Pull Requests

Pull requests are welcomed. Pull requests will only be considered if their content uses the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages