Jonas B
Jonas B

Reputation: 3

.createEnvelope returning 'invalid Template Id'

I'm requesting a signature by email using an existing template.

After using JWT grant for successful authorization, I call the api function docusign.EnvelopesApi(dsApiClient).createEnvelope with a new envelope including my templateId.

The call results in the error: {"errorCode":"TEMPLATE_ID_INVALID","message":"Invalid template ID."}

async function main(){
    const args = makeEnvelope({
      email: "signer email",
      name: "Signer name",
      templateId: "some template id",
    });

    // Make the envelope request body
    let envelope = makeEnvelope(args)

    let results = await new docusign.EnvelopesApi(dsApiClient).createEnvelope(
      accountInfo.apiAccountId, {envelopeDefinition: envelope});

    return results;

}

function makeEnvelope(args){
  let env = new docusign.EnvelopeDefinition();
  env.templateId = args.templateId;

  let signer = docusign.TemplateRole.constructFromObject({
      email: args.signerEmail,
      name: args.signerName,
      roleName: 'signer'});

  env.templateRoles = [signer];
  env.status = "sent"; 

  return env;
}

main();

Upvotes: 0

Views: 530

Answers (1)

Inbar Gazit
Inbar Gazit

Reputation: 14005

This error can mean:

  1. TemplateID is just wrong.
  2. TemplateID is from production or developer account, but you are using developer account or production (mismatch)
  3. TemplateID is from a different account then the one you authenticating to.

I cannot tell which one it is, you will have to contact support for this. But instead of just double-checking your ID, you need to also double check the env (prod vs. dev) as well as the accounts, make sure it's from the same account.

Upvotes: 1

Related Questions