How to send an envelope via your app
This topic demonstrates how to embed the Docusign Sender UI within your web app. For the best user experience, Docusign recommends using the API to construct draft envelopes and add recipients and tabs to those envelopes. After envelopes have been created, the Sender View enables your app’s users to edit the tabs, documents, recipients, and other envelope settings within your app before sending them out for approval.
Important: This example requires that you have created an envelope with created status or implemented the code from the embedded signing how-to, to generate a new envelope with created status.
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 calls 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 Confidential Authorization Code Grant for guidance on your options to get an Confidential Authorization Code Grant OAuth token.
Step 2. Create the envelope
Use the following steps to create the envelope:
- Instantiate the Docusign API client.
- Set the following default request header to add your access token.
"Authorization" : "Bearer {ACCESS_TOKEN}" - Initialize the Envelopes API.
- Create a new draft envelope and set the
statusproperty tocreated.
Important: This how-to draws on the code defined in the embedded signing how-to (which is part of the same code example launcher) to generate a new envelope with
createdstatus.
Step 3. Create the sender view
To create the sender view, first create an EnvelopeViewRequest object. This object contains the return URL to which the sender will be directed after they have sent the envelope. The viewAccess property is also required for this object and should be set to "envelope". The EnvelopeSettingsView object contains UX settings for the sender view. See EnvelopeViews:createSender for details on all of these settings.
Next, call the EnvelopeViews:createSender method with your API account ID, the ID of the draft envelope, and the EnvelopeViewRequest object. The code will return the URL for the embedded sending session at your requested starting view.
Expected response
Use the return URL in the JSON response to start the embedded sending session in your browser.
Next steps
- Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.
- Learn more about Embedded signing and sending.
- See how to Go-Live with a completed app and find the base path for API calls in the production environment.