Skip to content

Instantly share code, notes, and snippets.

@mmallis87
Last active August 9, 2018 22:29
Show Gist options
  • Save mmallis87/cd84db116646e2318d7c047d6380f4e7 to your computer and use it in GitHub Desktop.
Save mmallis87/cd84db116646e2318d7c047d6380f4e7 to your computer and use it in GitHub Desktop.
DocuSign EnvelopesApi.createEnvelope summary remarks

Creates an envelope. Using this function you can:

  • Create an envelope and send it.
  • Create an envelope from an existing template and send it. In either case, you can choose to save the envelope as a draft envelope instead of sending it by setting the request's `status` property to `created` instead of `sent`.

Sending Envelopes Documents can be included with the Envelopes::create call itself or a template can include documents. Documents can be added by using a multi-part/form request or by using the `documentBase64` field of the `document` object

Recipient Types An `envelopeDefinition` object is used as the method's body. Envelope recipients can be defined in the envelope or in templates. The `envelopeDefinition` object's `recipients` field is an `EnvelopeRecipients` resource object. It includes arrays of the seven types of recipients defined by DocuSign: Recipient type | Object definition - -- -- -- -- -- -- - | - -- -- -- -- -- -- -- -- agent (can add name and email information for later recipients/signers) | `agent` carbon copy (receives a copy of the documents) | `carbonCopy` certified delivery (receives a copy of the documents and must acknowledge receipt) | `certifiedDelivery` editor (can change recipients and document fields for later recipients/signers) | `editor` in-person signer (&quot;hosts&quot; someone who signs in-person) | `inPersonSigner` intermediary (can add name and email information for some later recipients/signers.) | `intermediary` signer (signs and/or updates document fields) | `signer` Additional information about the different types of recipients is available from the `EnvelopeRecipients` resource page and from the Developer Center ### Tabs Tabs (also referred to as `tags` and as `fields` in the web sending user interface), can be defined in the `envelopeDefinition`, in templates, by transforming PDF Form Fields, or by using Composite Templates (see below). Defining tabs: the `inPersonSigner`, and `signer` recipient objects include a `tabs` field. It is an `EnvelopeTabs` resource object. It includes arrays of the 24 different tab types available. See the `EnvelopeTabs` resource for more information. ## Using Templates Envelopes use specific people or groups as recipients. Templates can specify a role, eg `account_manager.` When a template is used in an envelope, the roles must be replaced with specific people or groups. When you create an envelope using a `templateId`, the different recipient type objects within the `EnvelopeRecipients` object are used to assign recipients to the template's roles via the `roleName` property. The recipient objects can also override settings that were specified in the template, and set values for tab fields that were defined in the template. ### Message Lock When a template is added or applied to an envelope and the template has a locked email subject and message, that subject and message are used for the envelope and cannot be changed even if another locked template is subsequently added or applied to the envelope. The field `messageLock` is used to lock the email subject and message. If an email subject or message is entered before adding or applying a template with `messageLock` true, the email subject and message is overwritten with the locked email subject and message from the template. ## Envelope Status The status of sent envelopes can be determined through the DocuSign webhook system or by polling. Webhooks are highly recommended: they provide your application with the quickest updates when an envelope's status changes. DocuSign limits polling to once every 15 minutes or less frequently. When a webhook is used, DocuSign calls your application, via the URL you provide, with a notification XML message. See the Webhook recipe for examples and live demos of using webhooks. ## Webhook Options The two webhook options, eventNotification and Connect use the same notification mechanism and message formats. eventNotification is used to create a webhook for a specific envelope sent via the API. Connect webhooks can be used for any envelope sent from an account, from any user, from any client. ### eventNotification Webhooks The Envelopes::create method includes an optional eventNotification object that adds a webhook to the envelope. eventNotification webhooks are available for all DocuSign accounts with API access. ### Connect Webhooks Connect can be used to create a webhook for all envelopes sent by all users in an account, either through the API or via other DocuSign clients (web, mobile, etc). Connect configurations are independent of specific envelopes. A Connect configuration includes a filter that may be used to limit the webhook to specific users, envelope statuses, etc. Connect configurations may be created and managed using the ConnectConfigurations resource. Configurations can also be created and managed from the Administration tool accessed by selecting &quot;Go to Admin&quot; from the menu next to your picture on the DocuSign web app. See the Integrations/Connect section of the Admin tool. For repeatability, and to minimize support questions, creating Connect configurations via the API is recommended, especially for ISVs. Connect is available for some DocuSign account types. Please contact DocuSign Sales for more information. ## Composite Templates The Composite Templates feature, like compositing in film production, enables you to overlay document, recipient, and tab definitions from multiple sources, including PDF Form Field definitions, templates defined on the server, and more. Each Composite Template consists of optional elements: server templates, inline templates, PDF Metadata templates, and documents. * The Composite Template ID is an optional element used to identify the composite template. It is used as a reference when adding document object information via a multi-part HTTP message. If used, the document content-disposition must include the `compositeTemplateId` to which the document should be added. If `compositeTemplateId` is not specified in the content-disposition, the document is applied based on the `documentId` only. If no document object is specified, the composite template inherits the first document. * Server Templates are server-side templates stored on the DocuSign platform. If supplied, they are overlaid into the envelope in the order of their Sequence value. * Inline Templates provide a container to add documents, recipients, tabs, and custom fields. If inline templates are supplied, they are overlaid into the envelope in the order of their Sequence value. * Document objects are optional structures that provide a container to pass in a document or form. If this object is not included, the composite template inherits the first document it finds from a server template or inline template, starting with the lowest sequence value. PDF Form objects are only transformed from the document object. DocuSign does not derive PDF form properties from server templates or inline templates. To instruct DocuSign to transform fields from the PDF form, set `transformPdfFields` to &quot;true&quot; for the document. See the Transform PDF Fields section for more information about process. * PDF Metadata Templates provide a container to embed design-time template information into a PDF document. DocuSign uses this information when processing the Envelope. This convention allows the document to carry the signing instructions with it, so that less information needs to be provided at run-time through an inline template or synchronized with an external structure like a server template. PDF Metadata templates are stored in the Metadata layer of a PDF in accordance with Acrobat's XMP specification. DocuSign will only find PDF Metadata templates inside documents passed in the Document object (see below). If supplied, the PDF metadata template will be overlaid into the envelope in the order of its Sequence value. ### Compositing the definitions Each Composite Template adds a new document and templates overlay into the envelope. For each Composite Template these rules are applied: * Templates are overlaid in the order of their Sequence value. * If Document is not passed into the Composite Template's `document` field, the first template's document (based on the template's Sequence value) is used. * Last in wins in all cases except for the document (i.e. envelope information, recipient information, secure field information). There is no special casing. For example, if you want higher security on a tab, then that needs to be specified in a later template (by sequence number) then where the tab is included. If you want higher security on a role recipient, then it needs to be in a later template then where that role recipient is specified. * Recipient matching is based on Recipient Role and Routing Order. If there are matches, the recipient information is merged together. A final pass is done on all Composite Templates, after all template overlays have been applied, to collapse recipients with the same email, username and routing order. This prevents having the same recipients at the same routing order. * If you specify in a template that a recipient is locked, once that recipient is overlaid the recipient attributes can no longer be changed. The only items that can be changed for the recipient in this case are the email, username, access code and IDCheckInformationInput. * Tab matching is based on Tab Labels, Tab Types and Documents. If a Tab Label matches but the Document is not supplied, the Tab is overlaid for all the Documents. For example, if you have a simple inline template with only one tab in it with a label and a value, the Signature, Initial, Company, Envelope ID, User Name tabs will only be matched and collapsed if they fall in the exact same X and Y locations. * roleName and tabLabel matching is case sensitive. * The defaultRecipient field enables you to specify which recipient the generated tabs from a PDF form are mapped to. You can also set PDF form generated tabs to a recipient other than the DefaultRecipient by specifying the mapping of the tab label that is created to one of the template recipients. * You can use tabLabel wild carding to map a series of tabs from the PDF form. To use this you must end a tab label with &quot;\*&quot; and then the system matches tabs that start with the label. * If no DefaultRecipient is specified, tabs must be explicitly mapped to recipients in order to be generated from the form. Unmapped form objects will not be generated into their DocuSign equivalents. (In the case of Signature/Initials, the tabs will be disregarded entirely; in the case of pdf text fields, the field data will be flattened on the Envelope document, but there will not be a corresponding DocuSign data tab.) ### Including the Document Content for Composite Templates Document content can be supplied inline, using the `documentBase64` or can be included in a multi-part HTTP message. If a multi-part message is used and there are multiple Composite Templates, the document content-disposition can include the `compositeTemplateId` to which the document should be added. Using the `compositeTemplateId` sets which documents are associated with particular composite templates. An example of this usage is: ``` - -5cd3320a-5aac-4453-b3a4-cbb52a4cba5d Content-Type: application/pdf Content-Disposition: file; filename=&quot;eula.pdf&quot;; documentId=1; compositeTemplateId=&quot;1&quot; Content-Transfer-Encoding: base64 ``` ### PDF Form Field Transformation Only the following PDF Form FieldTypes will be transformed to DocuSign tabs: CheckBox, DateTime, ListBox, Numeric, Password, Radio, Signature, and Text Field Properties that will be transformed: Read Only, Required, Max Length, Positions, and Initial Data. When transforming a PDF Form Digital Signature Field, the following rules are used: If the PDF Field Name Contains | Then the DocuSign Tab Will be - -- -- -- | - -- -- -- - DocuSignSignHere or eSignSignHere | Signature DocuSignSignHereOptional or eSignSignHereOptional | Optional Signature DocuSignInitialHere or eSignInitialHere | Initials DocuSignInitialHereOptional or eSignInitialHereOptional | Optional Initials Any other PDF Form Digital Signature Field will be transformed to a DocuSign Signature tab When transforming PDF Form Text Fields, the following rules are used: If the PDF Field Name Contains | Then the DocuSign Tab Will be - -- -- -- | - -- -- -- - DocuSignSignHere or eSignSignHere | Signature DocuSignSignHereOptional or eSignSignHereOptional | Optional Signature DocuSignInitialHere or eSignInitialHere | Initials DocuSignInitialHereOptional or eSignInitialHereOptional | Optional Initials DocuSignEnvelopeID or eSignEnvelopeID | EnvelopeID DocuSignCompany or eSignCompany | Company DocuSignDateSigned or eSignDateSigned | Date Signed DocuSignTitle or eSignTitle | Title DocuSignFullName or eSignFullName | Full Name DocuSignSignerAttachmentOptional or eSignSignerAttachmentOptional | Optional Signer Attachment Any other PDF Form Text Field will be transformed to a DocuSign data (text) tab. PDF Form Field Names that include &quot;DocuSignIgnoreTransform&quot; or &quot;eSignIgnoreTransform&quot; will not be transformed. PDF Form Date fields will be transformed to Date Signed fields if their name includes DocuSignDateSigned or eSignDateSigned. ## Template Email Subject Merge Fields This feature enables you to insert recipient name and email address merge fields into the email subject line when creating or sending from a template. The merge fields, based on the recipient's `roleName`, are added to the `emailSubject` when the template is created or when the template is used to create an envelope. After a template sender adds the name and email information for the recipient and sends the envelope, the recipient information is automatically merged into the appropriate fields in the email subject line. Both the sender and the recipients will see the information in the email subject line for any emails associated with the template. This provides an easy way for senders to organize their envelope emails without having to open an envelope to check the recipient. If merging the recipient information into the subject line causes the subject line to exceed 100 characters, then any characters over the 100 character limit are not included in the subject line. For cases where the recipient name or email is expected to be long, you should consider placing the merge field at the start of the email subject. * To add a recipient's name in the subject line add the following text in the `emailSubject` when creating the template or when sending an envelope from a template: [[<roleName>_UserName]] Example: `&quot;emailSubject&quot;:&quot;[[Signer 1_UserName]], Please sign this NDA&quot;,` * To add a recipient's email address in the subject line add the following text in the emailSubject when creating the template or when sending an envelope from a template: [[<roleName>_Email]] Example: `&quot;emailSubject&quot;:&quot;[[Signer 1_Email]], Please sign this NDA&quot;,` In both cases the <roleName> is the recipient's `roleName` in the template. For cases where another recipient (such as an Agent, Editor, or Intermediary recipient) is entering the name and email information for the recipient included in the email subject, then [[<roleName>_UserName]] or [[<roleName>_Email]] is shown in the email subject. ## Branding an envelope The following rules are used to determine the `brandId` used in an envelope: * If a `brandId` is specified in the envelope/template and that brandId is available to the account, that brand is used in the envelope. * If more than one template is used in an envelope and more than one `brandId` is specified, the first `brandId` specified is used throughout the envelope. * In cases where no brand is specified and the sender belongs to a Group; if there is only one brand associated with the Group, then that brand is used in the envelope. Otherwise, the account's default signing brand is used. * For envelopes that do not meet any of the previous criteria, the account's default signing brand is used for the envelope. ## BCC Email address feature The BCC Email address feature is designed to provide a copy of all email communications for external archiving purposes. DocuSign recommends that envelopes sent using the BCC for Email Archive feature, including the BCC Email Override option, include additional signer authentication options. To send a copy of the envelope to a recipient who does not need to sign, don't use the BCC Email field. Use a Carbon Copy or Certified Delivery Recipient type. ## Merge Recipient Roles for Draft Envelopes When an envelope with multiple templates is sent, the recipients from the templates are merged according to the template roles, and empty recipients are removed. When creating an envelope with multiple templates, but not sending it (keeping it in a created state), duplicate recipients are not merged, which could cause leave duplicate recipients in the envelope. To prevent this, the query parameter `merge_roles_on_draft` should be added when posting a draft envelope (status=created) with multiple templates. Doing this will merge template roles and remove empty recipients. ###### Note: DocuSign recommends that the `merge_roles_on_draft` query parameter be used anytime you are creating an envelope with multiple templates and keeping it in draft (created) status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment