Create link for singing template

  • 29 March 2024
  • 1 reply


Hello! I have a node.js application. I need 1 template. At any time I will want to fill out the data in this template, after that create a link for the user to sign in DocuSign. Also I want to receive a call back after successful signing.
I don’t understand how to implement it in node.js

1 reply


Hey @YevheniiBondarenko,

You need to combine:

- envelope creation with templateId parameter and templateRoles array providing email, name, roleName (based on what you have in your template) and clientUserId (to allow you to generate a link to be accessed).

let envelopeDefinition = new docusign.EnvelopeDefinition();

envelopeDefinition.templateId = "ADD_YOUR_UUID_HERE";

let templateSigner = new docusign.TemplateRole(); = "Sonny Signer"; = "";
templateSigner.roleName = "Signer"; // this should match your template
templateSigner.clientUserId = "USE_AN_UNIQUE_IDENTIFIER_PER_USER_HERE";

envelopeDefinition.templateRoles = [templateSigner];

envelopeDefinition.status = "sent";

- send this envelope definition using createEnvelope method

let responseEnvelopeCreation = await envelopesApi.createEnvelope(accountId, { envelopeDefinition });

- once the envelope is sent, you need to collect the envelopeId from the API request you are doing to Docusign and then generate a recipient view with createRecipientView providing the same information you used in the envelope creation (email, name and clientUserId) and a returnUrl from your website where you are going to send the user to after signing the envelope:

let recipientViewRequest = new docusign.RecipientViewRequest(); = "Sonny Signer" = ""
recipientViewRequest.clientUserId = "USE_AN_UNIQUE_IDENTIFIER_PER_USER_HERE";
recipientViewRequest.returnUrl = "";
recipientViewRequest.authenticationMethod = "Password";

* "Password" is one authentication method used as example, see the proper one to use in our documentation

let responseRecipientView = await envelopesApi.createRecipientView(responseEnvelopeCreation.envelopeId, { recipientViewRequest });

* This responseRecipientView returns an URL where you are going to redirect the user to

- once you send the user to the signature page and their finish their activities there you are going to receive an event (for example, when user signs an envelope your returnUrl receives a query string named event=signing_complete) (you can see other possible events in our API reference page).


Once you receive this callback from Docusign you can execute the actions in your end depending on each event type you receive from us after the signature is completed.


Keep in mind the codes above are only focusing in the request structure but they are not complete (as they not cover the authentication parts, for example) and they can be changed in comparison with your code. 


I hope I could help here.