How to embed an elastic signing agreement
This topic demonstrates how to embed an agreement using an elastic template with a unique agreement link and dynamic content using the ClickWraps:createHasAgreed method.
Important: You must create, activate, and add dynamic content to a elastic template to complete this how-to.
Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.
Required data
Running the code in this how-to requires this data:
Step 1. Obtain your OAuth token
To make the API call shown in this how-to, you need a valid OAuth access token. Docusign supports access tokens for three different recommended OAuth grant types: Public Authorization Code Grant, Confidential Authorization Code Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.
See Authentication for guidance on your options to get an OAuth token.
Step 2. Construct your API headers
After you have a valid OAuth access token, you are ready to construct the API headers that you will pass to the API call. Construct your headers like this, but make sure to substitute your valid OAuth access token for {ACCESS_TOKEN}.
Step 3. Construct the request body
Next, create the request body. The metadata provided in the gist matches the available dynamic fields in the INSERT DATA editor.
Step 4. Call the Click API
Now that you have constructed your API headers and request body, make a POST request to the Click API and include the request body to populate the dynamic fields within your elastic signing agreement. Here’s how you make the call, but make sure to substitute your API account ID for {account_id} and elastic template ID for {clickwrap_id}.
Note: For compatibility with previous versions of the Click API, elastic templates use clickwrap endpoints.
Expected response
Copy the agreementUrl from the JSON response and paste it in the corresponding line in the HTML in the next step.
Step 5. Write your HTML for embedding the elastic template
Write the code you need to embed your elastic template on your web page. This includes three HTML tags:
-
A
<div>that identifies where on your web page the elastic template should render -
Two
<script>tags:-
One that calls the Docusign elastic template JavaScript library
-
Another that calls the Docusign
Clickwrap.rendermethod from the JavaScript library- Paste the
agreementUrlthat is generated in the prior step
- Paste the
-
Expected response
You can paste the HTML gist with your unique agreementUrl into an HTML editor to preview your elastic template with dynamic content.
Next steps
- Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.
- Learn How to customize a elastic template’s appearance.
- See How to get a list of elastic templates.
- See how to Go-Live with a completed app and find the base path for API calls in the production environment.
- See the list of Click event callbacks