Docs
Node.js

Node.js

Learn how to create your first sigature request using the DigiSign Node.js SDK.

Prerequisites

To get the most out of this guide, you’ll need to:

Install

Get the DigiSign Node.js SDK.

Authenticate

The DigiSign API requires authentication via an API Key. Learn More.

Call createSession to authenticate. Each session expires every 6 minutes.

import {createSession, SessionEnvironment} from '@usedigisign/node-sdk';
 
async function main() {
try {
const session = await createSession({
key: "ds_1234567890",
environment: SessionEnvironment.SANDBOX, // SessionEnvironment.SANDBOX or SessionEnvironment.PRODUCTION
});
 
    const keys = await session.keys.list({limit: 5, page: 2});
    console.log(keys);
 
} catch (error) {
console.error(error);
}
};
 
main()
 

Transform a template to a Request

The easiest way to create a request is by using the transform method.

import {createSession} from '@usedigisign/node-sdk';
 
async function main() {
  try {
    const session = await createSession({
      key: "<API_KEY>",
      environment: SessionEnvironment.SANDBOX, // SessionEnvironment.SANDBOX or SessionEnvironment.PRODUCTION
    });
    const workspaceId = "<WORKSPACE_ID>"
 
    const data = {
        "recipients": [
            {
                "id": "<RECIPIENT_ALIAS_ID>",
                "name": "Jidenna Okonkwo",
                "email": "jidenna.okonkwo@example.com",
                "fillable": {
                    "company": "Jide & Sons Limited",
                    "first_name": "Jidenna Ifeanyi",
                    "last_name": "Okonkwo"
                },
                "private_message": "Jide, please check this document ASAP, for your container. This is just a test document tho. Happy testing!!!"
            }
        ],
        "message": {
            "subject": "Avocado Replublic Export",
            "body": "Please review and sign this document as soon as you can. Thanks"
        }
}
 
    const result = await session.templates.workspace(workspaceId).transform('<TEMPLATE_ID>', data);
 
    console.log(result);
  } catch (error) {
    console.error(error);
  }
};
 
main()

Recipients ID must match a corresponding alias ID from the selected template.

Try it yourself

Was this page helpful?