Skip to content

Instantly share code, notes, and snippets.

@DSDevCenter
Last active February 20, 2018 22:09
Show Gist options
  • Save DSDevCenter/641797847db64d10e3043375f9134b35 to your computer and use it in GitHub Desktop.
Save DSDevCenter/641797847db64d10e3043375f9134b35 to your computer and use it in GitHub Desktop.
DocuSign Java SDK REST API Example - Quickstart Create Envelope from Template
// create a new envelope to manage the signature request
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.setEmailSubject("DocuSign Java SDK - Sample Signature Request");
// assign template information including ID and role(s)
envDef.setTemplateId("{TEMPLATE_ID}");
// create a template role with a valid templateId and roleName and assign signer info
TemplateRole tRole = new TemplateRole();
tRole.setRoleName("{ROLE}");
tRole.setName("{USER_NAME}");
tRole.setEmail("{USER_EMAIL}");
// set the clientUserId on the recipient to mark them as embedded (ie we will generate their signing link)
tRole.setClientUserId("1001");
// create a list of template roles and add our newly created role
java.util.List<TemplateRole> templateRolesList = new java.util.ArrayList<TemplateRole>();
templateRolesList.add(tRole);
// assign template role(s) to the envelope
envDef.setTemplateRoles(templateRolesList);
// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus("sent");
// instantiate a new EnvelopesApi object
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
// call the createEnvelope() API
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
System.out.println("Envelope has been sent to " + tRole.getEmail());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment