Skip to main content

I’m using the DocuSign Node.js package to create an envelope in my Next.js application. I have imported the necessary classes from DocuSign as: 

 

import { ApiClient, EnvelopesApi, EnvelopeDefinition, TemplateRole } from 'docusign-esign';

 

But, it seems like I am unable to use the “EnvelopeDefinition” method. I have it as: 

 

// Prepare the envelope details

const envelopeDefinition = new EnvelopeDefinition();

 

The issue I’m having is that I get the message; “'EnvelopeDefinition' only refers to a type, but is being used as a value here.” when try to initialize the envelope definition.

 

What am I doing wrong? Can someone please asssist?

 

 

 

 

Hello Team

The issue is likely due to how TypeScript handles type-only imports versus actual value imports. 

const envelopeDefinition = { / initialize your envelope details here as an object / }; Or,  may be as below:

 

const envelopeDefinition = {
  emailSubject: "Please sign this document",
  templateId: "your-template-id",
  templateRoles: R
    {
      email: "recipient@example.com",
      name: "Recipient Name",
      roleName: "RoleName",
    },
  ],
  status: "sent",
};

This approach works as EnvelopeDefinition in DocuSign SDK might not be a JavaScript constructor. Instead, the SDK uses plain objects for configuration.

Please try and if you still see issues then please log a case with DS Support attaching logs  https://support.docusign.com/guides/ndse-user-guide-api-request-logging & we will investigate from there.

 

Thankyou

Sai

 


Hello Sai

 

Thank you for your response to me enquiry. I’ve managed to work around the issue by using the RESTAPI instead. I found that I was encountering numerous issues when I used the DocuSign SDK. I’ve implemented a similar structure as you’ve proposed in your solution and my application is now working as expected.

 

Thanks your for your assistance.

 

Kind regards,

Yattish


Reply