See behind the scenes
When the form is submitted we use the Envelopes: create API to create the signature request with the corresponding form information. Since we are using a Template in this case the templateId
property is used to apply a given template to the envelope and the templateRoles
node is used to assign recipient(s) to roles within the template.
To match a recipient to a role we use the roleName
property, which must exactly match the role name saved in the template. We do this for both our Applicant and Cosigner. To set default tab values for each role we use the tabs
node just like we did when in the first loan example, except here we omit any positioning information since that is saved within the template.
To identify and populate a given tab we use the tabLabel
and value
properties, respectively. And once again to use embedded signing we must set the clientUserId
property for each recipient (or template role in this case).
To create and send an envelope from a template send an http POST request to:
POST /v2.1/accounts/{accountId}/envelopes
Click to view example request JSON
{ "status": "sent", "emailSubject": "Auto Loan Application", "emailBlurb": "Please sign the Loan application to start the application process.", "documents": [], "templateId": "ea7c6390-9ee5-4dcb-8319-c87b6a9dc7d8", "templateRoles": [ { "email": "-- RECIPIENT EMAIL HERE --", "roleName": "applicant", "name": "-- RECIPIENT NAME HERE --", "clientUserId": "1001", "tabs": { "textTabs": [ { "tabLabel": "Phone", "recipientId": "1", "value" : "5555555555" } ] }, "recipientId": "1" }, { "email": "-- RECIPIENT (COSIGNER) EMAIL HERE --", "roleName": "cosigner", "name": "-- RECIPIENT (COSIGNER) NAME HERE --", "clientUserId": "2002", "tabs": { "textTabs": [ { "tabLabel": "PhoneCosigner", "recipientId": "2" } ] }, "recipientId": "2" }, { "email": "-- INTERNAL EMPLOYEE EMAIL HERE --", "roleName": "employee", "name": "-- INTERNAL EMPLOYEE NAME HERE --" } ] }
If Embedded Signing was selected we next use the EnvelopeViews: createRecipient API to generate a signing URL for the recipient. For this to work the clientUserId
property must be set on the recipient when the envelope was sent during step 1.
Once the envelope is sent we save the envelope ID and Recipient information to our session then redirect to the /sign/embedded page. There we retrieve the envelope ID and recipient info from our session and create the recipient view by generating the URL and displaying in a full-width and full-height iframe.
To create the recipient view of the envelope we send an http POST request to:
POST /v2.1/accounts/{accountId}/envelopes/{envelopeId}/views/recipient
Click to view example request JSON (the ReturnUrl
information)
{ "clientUserId": "1001", "userName": "-- RECIPIENT NAME HERE --", "email": "-- RECIPIENT EMAIL HERE --", "recipientId": "1", "returnUrl": "-- RETURN URL HERE --", "authenticationMethod": "email" }