Docusign JS for embedded signing reference
You can use the Docusign JS JavaScript library to:
- Implement Embedded signing with focused view, focused view/Click to Agree, and classic signing sessions.
- Render web form instance URLs for the Docusign Web Forms API.
This topic focuses on using Docusign JS for embedded signing. See Web Forms API when using it with the Web Forms API. The library can be used for both purposes on the same web page.
1. Install Docusign JS
Add the development or production version of Docusign JS to your web page:
- If your app uses the Development environment:
<script src="https://js-d.docusign.com/bundle.js"></script> - If your app uses the Production environment:
<script src="https://js.docusign.com/bundle.js"></script>
Note: Do not make a local copy of bundle.js, it must match the platform version.
2. Add a container element to your DOM
When the Docusign JS mount method is called, it will add an iframe to the DOM element you use as an argument for the method. When the sessionEnd event is raised, the library will delete the iframe.
Add an empty block element (such as a div) to your DOM to hold the iframe. You must set the block element’s width and height. You can use @media CSS to change the div’s width based on the overall screen’s width. Bootstrap and other layout systems can also be used.
3. Call EnvelopeViews:createRecipient
Call the EnvelopeViews:createRecipient API method and provide values for the frameAncestors and messageOrigins attributes:
-
The frameAncestors attribute is an array of HTTP origin strings, not including anything after the hostname or port. Include the
https://apps-d.docusign.comorigin for the developer environment orhttps://apps.docusign.comfor production. Include additional origins for your app’s ancestor origins that will embed the signing session. Origins must usehttpsrather thanhttp, with the exception of forlocalhost. Thelocalhostorigin can’t be used in production.Note:
frameAncestorshas a limit of 500 characters (for all URLs combined).Examples:
-
The messageOrigins attribute is an array of HTTP origin strings. The array must have one member:
["https://apps-d.docusign.com"] # demo["https://apps.docusign.com"] # production
-
The returnUrl attribute must be set, but will not be used.
All other attributes should be set as usual.
The EnvelopeViews:createRecipient API method’s url response is used in the browser with Docusign JS. If you call createRecipient on the server, return the url to your browser page.
The window.loadDocuSign(``integration_key``) RETURNS Promise resolves to a Docusign object, and is called first to obtain the Docusign object.
Performance tip: This method can be called asynchronously before it is needed to create a signing session.
The integration_key argument is a string that contains your application’s integration key (client ID). Client IDs are not secrets.
Signing method
The Docusign object includes the signing method:
signing(SigningConfiguration) RETURNS Signing object
The signing method creates the embedded signing session. It takes as a parameter a SigningConfiguration object to control the signing session’s format and style attributes. The returned Signing object represents the signing session that will be displayed. See Signing object methods for a list of methods.
SigningConfiguration object properties
StyleObject properties
Some styling options have not yet been implemented for some display formats.
The following options are supported for the Docusign JS StyleObject:
Example SigningConfiguration object
Signing object methods
The signing object is used to display the signing session and catch the signing-related events it raises.
Use Docusign JS with JavaScript
This example uses the JavaScript module type to enable the await keyword at the top level of the script.