Github repo: code-examples-python
This GitHub repo includes code examples for DocuSign APIs.
To switch between API code examples, modify the EXAMPLES_API_TYPE setting at the end of the configuration file. Set only one API type to true and set the remaining to false.
If none of the API types are set to true, the DocuSign eSignature REST API code examples will be shown. If multiple API types are set to true, only the first will be shown.
Note: to use the Rooms API you must also create your DocuSign Developer Account for Rooms.
This repo is a Python 3 application that demonstrates:
- Use embedded signing. Source. This example sends an envelope, and then uses embedded signing for the first signer. With embedded signing, the DocuSign signing is initiated from your website.
- Request a signature by email (Remote Signing). Source. The envelope includes a pdf, Word, and HTML document. Anchor text (AutoPlace) is used to position the signing fields in the documents.
- List envelopes in the user's account. Source. The envelopes' current status is included.
- Get an envelope's basic information. Source. The example lists the basic information about an envelope, including its overall status.
- List an envelope's recipients Source. Includes current recipient status.
- List an envelope's documents. Source.
- Download an envelope's documents. Source. The example can download individual documents, the documents concatenated together, or a zip file of the documents.
- Programmatically create a template. Source.
- Request a signature by email using a template. Source.
- Send an envelope and upload its documents with multipart binary transfer. Source. Binary transfer is 33% more efficient than using Base64 encoding.
- Use embedded sending. Source. Embeds the DocuSign web tool (NDSE) in your web app to finalize or update the envelope and documents before they are sent.
- Embedded DocuSign web tool (NDSE). Source.
- Use embedded signing from a template with an added document. Source. This example sends an envelope based on a template. In addition to the template's document(s), the example adds an additional document to the envelope by using the Composite Templates feature.
- Payments example: an order form, with online payment by credit card. Source.
- Get the envelope tab data. Retrieve the tab (field) values for all of the envelope's recipients. Source.
- Set envelope tab values. The example creates an envelope and sets the initial values for its tabs (fields). Some of the tabs are set to be read-only, others can be updated by the recipient. The example also stores metadata with the envelope. Source.
- Set template tab values. The example creates an envelope using a template and sets the initial values for its tabs (fields). The example also stores metadata with the envelope. Source.
- Get the envelope custom field data (metadata). The example retrieves the custom metadata (custom data fields) stored with the envelope. Source.
- Requiring an Access Code for a Recipient Source. This example sends an envelope that requires an access-code for the purpose of multi-factor authentication.
- Requiring SMS authentication for a recipient Source. This example sends an envelope that requires entering in a six digit code from an text message for the purpose of multi-factor authentication.
- Requiring Phone authentication for a recipient Source. This example sends an envelope that requires entering in a voice-based response code for the purpose of multi-factor authentication.
- Requiring Knowledge-Based Authentication (KBA) for a Recipient Source. This example sends an envelope that requires passing a Public records check to validate identity for the purpose of multi-factor authentication.
- Requiring ID Verification (IDV) for a recipient Source. This example sends an envelope that requires submitting a photo of a government issued id for the purpose of multi-factor authentication.
- Creating a permission profile Source. This code example demonstrates how to create a permission profile using the Create Permission Profile method.
- Setting a permission profile Source. This code example demonstrates how to set a user group’s permission profile using the Update Group method. You must have already created the permissions profile and the group of users.
- Updating individual permission settings Source. This code example demonstrates how to edit individual permission settings on a permissions profile using the Update Permission Profile method.
- Deleting a permission profile Source. This code example demonstrates how to delete a permission profile using the Delete Permission Profile method.
- Creating a brand Source. This example creates brand profile for an account using the Create Brand method.
- Applying a brand to an envelope Source. This code example demonstrates how to apply a brand you've created to an envelope using the Create Envelope method. First, creates the envelope and then applies the brand to it. Anchor text (AutoPlace) is used to position the signing fields in the documents.
- Applying a brand to a template Source. This code example demonstrates how to apply a brand you've created to a template using the Create Envelope method. You must have already created the template and the brand. Anchor text (AutoPlace) is used to position the signing fields in the documents.
- Bulk sending envelopes to multiple recipients Source. This code example demonstrates how to send envelopes in bulk to multiple recipients using these methods: Create Bulk Send List, Create Bulk Send Request. Firstly, creates a bulk send recipients list, and then creates an envelope. After that, initiates bulk envelope sending.
- Pausing a signature workflow Source. This code example demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient using the Create Envelope method.
- Unpausing a signature workflow Source. This code example demonstrates how to update an envelope to resume the workflow that has been paused using the Update Envelope method. You must have created at least one envelope with a paused signature workflow to run this example.
- Using conditional recipients Source. This code example demonstrates how to create an envelope where the workflow is routed to different recipients based on the value of a transaction using the Create Envelope method.
- Request a signature by SMS delivery Source. This code example demonstrates how to send a signature request via an SMS message using the Envelopes: create method.
Note: to use the Rooms API you must also create your DocuSign Developer Account for Rooms. Examples 4 and 6 require that you have the DocuSign Forms feature enabled in your Rooms for Real Estate account.
- Create a room with data. Source. This example creates a new room in your DocuSign Rooms account to be used for a transaction.
- Create a room from a template. Source. This example creates a new room using a template.
- Create a room with Data. Source. This example exports all the available data from a specific room in your DocuSign Rooms account.
- Add forms to a room. Source. This example adds a standard real estate related form to a specific room in your DocuSign Rooms account.
- How to search for rooms with filters. Source. This example demonstrates how to return rooms that have had their field data, updated within the time period between Start date and End date.
- Create an external form fillable session.
Source.
This example demonstrates how to create an
external form fill session
using the Rooms API:
the result of this code example is the URL for the form fill session, which you can embed in your integration or send to the user. - Create a form group Source. This example demonstrates creating a DocuSign Form Group.
- Grant office access to a form group Source. This example demonstrates how to grant Office access to a Form Group.
- Assign a form to a form group Source. This example demonstrates how to assign a form to a form group.
- Create a clickwrap. Source. This example demonstrates how to use DocuSign Click to create a clickwrap that you can embed in your website or app.
- Activate a clickwrap. Source. This example demonstrates how to use DocuSign Click to activate a new clickwrap that you have already created.
- Create a new clickwrap version. Source. This example demonstrates how to use DocuSign Click to create a new version of a clickwrap.
- Get a list of clickwraps. This example demonstrates how to use DocuSign Click to get a list of clickwraps associated with a specific DocuSign user. Source.
- Get clickwrap responses. This example demonstrates how to use DocuSign Click to get user responses to your clickwrap agreements. Source.
- Get monitor data. Source. This example demonstrates how to get and display all of your organization’s monitoring data.
-
Authentication with Docusign via Authorization Code Grant flow . When the token expires, the user is asked to re-authenticate. The refresh token is not used in this example.
-
Authentication with DocuSign via the JSON Web Token (JWT) Grant. When the token expires, it updates automatically.
Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip steps 1 and 2 below as they're automatically performed for you.
-
A DocuSign Developer account (email and password) on demo.docusign.net. Create a free account.
-
A DocuSign Integration Key (a client ID). To use Authorization code grant, you will need the Integration Key itself, and its secret. To use JSON Web token, you will need the Integration Key itself, the RSA Secret Key and an API user ID for the user you are impersonating.
If you use this example on your own workstation, the Integration key must include a Redirect URI of
http://localhost:5000/ds/callback
If you will not be running the example on your own workstation, use the appropriate DNS name and port instead of
localhost
This video demonstrates how to create an Integration Key (client id) for a user application like this example. Note that the redirect url for your Integration Key will be
http://localhost:5000/ds/callback
if you use the default Python settings. -
Python 3.
-
A name and email for a signer, and a name and email for a cc recipient.
Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip steps 4 and 5 below as they're automatically performed for you.
-
Extract the Quickstart ZIP file or download or clone the code-examples-python repo.
-
Switch to the folder: cd <Quickstart_folder_name> or cd code-examples-python
-
pip3 install -r requirements.txt (or pipenv can be used)
-
Make a copy of the app/ds_config_sample.py and name it ds_config.py
-
Update this new file app/ds_config.py with your Integration Key and other settings.
Note: Protect your Integration Key and secret--you should ensure that ds_config.py file will not be stored in your source code repository.
-
python run.py
Note: You will need to alias the python command to run Python 3 or use python3 run.py
-
Open a browser to http://localhost:5000
- Create a developer account on developers.docusign.com if you don't already have one.
- Create a new API key in the Admin panel: https://admindemo.docusign.com/api-integrator-key, take note of the public key.
- Set a redirect URI of
http://localhost:5000/ds/callback
as mentioned in the installation steps above for the API key you make in step 2. - Generate an RSA keypair in the administrator console on the DocuSign developer account and copy the private key to a secure location.
- Create a new file in your repo source folder named private.key, and paste in that copied RSA private key, then save it.
- Update the file app/ds_config.py and include the newly created API key from step 2 as well as your account user id GUID which is also found on the Admin panel:
https://admindemo.docusign.com/api-integrator-key
.
From there you should be able to run the launcher using python run.py then selecting JSON Web Token when authenticaing your account.
To use the payments example, create a test payments gateway for your developer account.
See the PAYMENTS_INSTALLATION.md file for instructions.
Then add the payment gateway account id to the app/ds_config.py file.
The examples in this repository can also be used with the Implicit Grant OAuth flow. See the Authentication guide for information on choosing the right authentication flow for your application.
This repository uses the MIT License. See the LICENSE file for more information.
Pull requests are welcomed. Pull requests will only be considered if their content uses the MIT License.