Docusign eSignature Node Client SDK

repository·master·Indexed 41 days ago

https://github.com/docusign/docusign-esign-node-client

The official Node.js client library for the Docusign eSignature REST API v2.1. It provides API classes such as EnvelopesApi, TemplatesApi, and UsersApi, along with data models for managing envelopes, recipients, and documents. Supports Authorization Code Grant and JSON Web Token (JWT) authentication workflows. Version 10.0.0 requires Node.js 12 or higher.

Tokens
10.7K
Snippets
27
Records
34
Agent score
99%

What's inside Docusign

  1. Install the Docusign eSignature Node Client SDK via npm

    master

    To integrate Docusign into your Node.js project, install the docusign-esign package using npm. Ensure you are in your project's root directory before running the command.

    Requirements

    • Node.js: Version 12 or higher
    • Docusign Account: A free developer account is required to use the API.

    Version Information

    • Latest SDK version: 10.0.0
    • API version: v2.1
    npm install docusign-esign -save
  2. Explore Docusign eSignature Node SDK code examples

    master

    You can find practical implementations and common use cases in the following resources:

    1. Launcher: A self-executing package in the Docusign Launcher repository that showcases various use cases.
    2. Quickstart: Preconfigured versions for your Docusign developer account available via the Docusign Quickstart guide.

    These examples support both Authorization Code Grant and JSON Web Token (JWT) authentication workflows.

  3. Overview of Docusign eSignature Node Client SDK

    master
    The Docusign eSignature Node Client SDK is the official client library for interacting with the Docusign eSignature REST API. It provides a structured way to manage envelopes, templates, users, and other eSignature resources using Node.js. The SDK is auto-generated from the OpenAPI specification (v2.1) and includes comprehensive models and API classes to match the REST API surface.
  4. Access Docusign eSignature Data Models

    master

    The Docusign eSignature Node Client SDK exports a wide range of model constructors used to represent various entities within the eSignature API. These models are used to structure request payloads and parse response data.

    Commonly used models include:

    • Envelope: Represents an envelope (a collection of documents and recipients).
    • Recipient: Represents a person participating in an envelope.
    • EnvelopeDocument: Represents a document within an envelope.
    • Email: Represents email-related data.
    • SignHere: Represents a signature field/tab.
    • PowerForm: Represents a PowerForm entity.
    • Notary: Represents notary-related information.

    Each model is available as a constructor on the main SDK entrypoint.

  5. Core components of the Docusign eSignature SDK

    master

    The SDK is organized into several key functional areas that you will use to build your integration:

    API Classes

    The SDK provides specific API classes for different resource domains. Common classes include:

    • EnvelopesApi: For managing the lifecycle of envelopes (sending, status, etc.).
    • TemplatesApi: For managing document templates.
    • UsersApi: For managing user information and permissions.
    • AccountsApi: For account-level operations.
    • AuthenticationApi: For handling OAuth and authentication flows.
    • FoldersApi, GroupsApi, WorkspacesApi, PowerFormsApi, and more.

    Models

    The SDK includes a vast collection of data models (found in the model/ directory) that represent the request and response bodies for the API. Examples include Envelope, Recipient, Document, Template, and User. These models ensure type safety and structure when interacting with the API.

    Configuration and Client

    • Configuration: Used to set up global or instance-specific settings (like base paths or authentication details).
    • ApiClient: The underlying engine that handles the actual HTTP communication with the Docusign servers.
  6. Initialize the Docusign eSignature SDK

    master

    The Docusign eSignature Node Client is initialized by importing the main module. The SDK follows a factory pattern that exports several core components: Configuration for setting up environment and credentials, ApiClient for handling HTTP requests, a vast collection of model classes for data structures, and various Api classes for interacting with specific Docusign resources.

    To use the SDK, you typically instantiate an ApiClient, configure it with your credentials, and then use the specific API classes (e.g., EnvelopesApi) to perform actions.

    const Docusign = require('docusign-esign');
    
    // The SDK exports Configuration, ApiClient, models, and API classes
    // Example usage pattern:
    const apiClient = new Docusign.ApiClient();
    const envelopesApi = new Docusign.EnvelopesApi(apiClient);
  7. How to use the Docusign eSignature Node Client

    master

    The Docusign Node.js SDK follows a pattern where you first instantiate an API class to perform operations, and then use model classes to construct the data objects required by those operations.

    For CommonJS applications, you can require the module and follow this workflow:

    1. Import the SDK.
    2. Instantiate an API class (e.g., XxxApi) to access specific service methods.
    3. Instantiate model classes (e.g., Yyy) to create data structures.
    4. Set properties on the model instances.
    5. Pass the model instance as an argument to the API service method.
    var Docusign = require('docusign-esign'); // Replace 'index' with the actual package name
    
    // 1. Allocate the API class we're going to use
    var xxxSvc = new Docusign.XxxApi(); 
    
    // 2. Construct a model instance
    var yyyModel = new Docusign.Yyy(); 
    
    // 3. Set properties on the model
    yyyModel.someProperty = 'someValue';
    
    // 4. Invoke the service
    var zzz = xxxSvc.doSomething(yyyModel);
  8. Use the CustomFieldV2 model

    master

    The CustomFieldV2 class is a data model used to define version 2 custom fields in DocuSign. You can instantiate it using the new keyword or populate an existing instance from a plain JavaScript object using CustomFieldV2.constructFromObject(data, obj). This is useful when receiving field data from the API or preparing custom field definitions for a request.

    const CustomFieldV2 = require('docusign-esign').model.CustomFieldV2;
    
    const fieldData = {
      fieldId: '12345',
      name: 'My Custom Field',
      value: 'Custom Value',
      required: 'true'
    };
    
    const customField = CustomFieldV2.constructFromObject(fieldData);
  9. Construct AddressInformationV2 from an object

    master

    The constructFromObject method allows you to create or populate an AddressInformationV2 instance using a plain JavaScript object. This is useful when receiving address data from an external source or API.

    Parameters:

    • data (Object): The plain JavaScript object containing the address properties.
    • obj (AddressInformationV2, optional): An existing instance to populate. If not provided, a new instance is created.

    Returns:

    • The populated AddressInformationV2 instance.
    const address = AddressInformationV2.constructFromObject({
      address1: '123 Main St',
      city: 'San Francisco'
    });
  10. Access Docusign eSignature API services

    master

    The Docusign eSignature Node Client SDK organizes its functionality into specialized API service classes. To interact with different parts of the Docusign platform (e.g., managing envelopes, templates, or users), you must instantiate the corresponding API class.

    Commonly used API services include:

    • EnvelopesApi: For managing envelopes (sending, retrieving, and managing signing processes).
    • TemplatesApi: For managing document templates.
    • UsersApi: For managing user information and profiles.
    • AccountsApi: For account-level operations.
    • FoldersApi: For managing folder structures.
    • WorkspacesApi: For workspace-related operations.

    Each service is exported from the main entrypoint and can be instantiated to perform specific tasks.

    const DocusignSDK = require('docusign-esign');
    
    // Example of instantiating an API service
    const envelopesApi = new DocusignSDK.EnvelopesApi();
    const templatesApi = new DocusignSDK.TemplatesApi();
  11. DisplayAppliancePage model properties

    master

    The DisplayAppliancePage model represents data related to appliance pages within the DocuSign eSignature API. You can instantiate this model or use constructFromObject to populate an instance from a plain JavaScript object.

    Properties

    PropertyTypeDescription
    documentIdStringSpecifies the document ID number that the tab is placed on. This must refer to an existing Document's ID attribute.
    documentNameStringThe name of the document.
    externalDocumentIdStringAn external identifier for the document.
    heightNumberHeight of the tab in pixels.
    isFirstPageBooleanIndicates if this is the first page.
    pageIdStringThe unique identifier for the page.
    pageNoNumberThe sequence number of the page.
    pageStatusStringThe status of the page.
    pageTypeStringThe type of the page.
    widthNumberWidth of the tab in pixels.
    const DisplayAppliancePage = require('docusign-esign').model.DisplayAppliancePage;
    
    const pageData = {
      documentId: '1',
      documentName: 'Contract.pdf',
      pageNo: 1,
      height: 1080,
      width: 792
    };
    
    const appliancePage = DisplayAppliancePage.constructFromObject(pageData);