Skip to content

How to create a envelope in Docusign using Node Js

Last updated on November 21, 2022

const axios = require('axios')
const path = require('path')
const fs = require('fs')

const docusign = {
    accountID: 'your account id',
    username: 'your email address',
    password: 'your password',
    integratorKey: 'xxxxx-xxxx-xxxx-xxxx-xxxxxxx'
}


const fileBytes = fs.readFileSync(path.resolve(__dirname, '1538129760865_gg2pbkcnkn9.pdf')) // file 

const base64Doc = Buffer.from(fileBytes).toString('base64')

axios({
    method: 'post',
    url: `https://demo.docusign.net/restapi/v2/accounts/${docusign.accountID}/envelopes`,
    headers: {
        'X-DocuSign-Authentication': JSON.stringify({
            "Username": docusign.username,
            "Password": docusign.password,
            "IntegratorKey": docusign.integratorKey
        }),
        'Content-Type': 'application/json'
    },
    data: {
        "recipients": {
            "signers": [
                {
                    "email": "[email protected]",
                    "name": "Arjun",
                    "recipientId": 1,
                    "tabs": {
                        "signHereTabs": [
                            {
                                "xPosition": "120",
                                "yPosition": "36",
                                "documentId": "1",
                                "pageNumber": "1"
                            }
                        ]
                    }
                }
            ]
        },
        "emailSubject": "DocuSign API - Signature Request on Document Call",
        "documents": [
            {
                "documentId": "1",
                "name": "blank1.pdf",
                "documentBase64": base64Doc
            }
        ],
        "status": "sent"
    }
}).then(console.log).catch(console.log)
0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments