.createEnvelope returning 'invalid Template Id'

Viewed 32

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."}

  • My server is authorized successfully,
  • I only have a single docu-sign admin user (myself)
  • The templateId is correct (i've double and tripped checked)
  • I'm on a paying account
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();
1 Answers

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.

Related