Github repo: https://github.com/docusign/code-examples-ruby
To switch between API code examples, modify the examples_API 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.
Before you can make any API calls using JWT Grant, you must get your user’s consent for your app to impersonate them. To do this, the impersonation scope is added when requesting a JSON Web Token.
This repo is a Ruby on Rails application.
For more information about the scopes used for obtaining authorization to use the eSignature API, see the Required Scopes section.
-
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. The example creates an envelope using a template and sets the initial values for some of its tabs (fields). Source.
-
Send an envelope and upload its documents with multpart 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 the recipient to upload a government issued id.
-
Creating a permission profile Source. This code example demonstrates how to create a user group's permission profile using the Create 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 permissions profile and group of users.
-
Updating individual permission settings Source. This code example demonstrates how to update individual settings for a specific permission profile using the Update Permission Profile method. You must have already created permissions profile and group of users.
-
Deleting a permission profile Source. This code example demonstrates how to an account's permission profile using the Delete AccountPermissionProfiles method. You cannot delete the Everyone nor the Administrator profile types as those are defaults.
-
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 brand to it.
-
Applying a brand to a template Source. This code example demonstrates how to apply a brand you've created to a template using using the Create Envelope method. You must have at least one created template and brand.
-
Bulk sending envelopes to multiple recipients Source. This example creates and sends a bulk envelope by generating a bulk recipient list and initiating a bulk send.
-
Pausing a signature workflow Source. This example demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.
-
Unpausing a signature workflow Source. This example demonstrates how to resume an envelope workflow that has been paused.
-
Using conditional recipients Source. This example demonstrates how to create an envelope where the workflow is routed to different recipients based on the value of a transaction.
-
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 a Rooms developer account.
For more information about the scopes used for obtaining authorization to use the Rooms API, see the Required Scopes section.
- 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.
- Export data from a room. 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.
- Search for rooms with filters. Source. This example searches for rooms in your DocuSign Rooms account using a specific filter.
- Get an external form fillable session. Source. This example creates an external form that can be filled using DocuSign for a specific room in your DocuSign Rooms account.
- Creating a form group. Source. This example creates a new form group with the name given in the name property of the request body.
- Grant office access to a form group. Source. This example assigns an office to a form group for your DocuSign Rooms.
- Assign a form to a form group. Source. This example assigns a form to a form group for your DocuSign Rooms.
For more information about the scopes used for obtaining authorization to use the Clickwrap API, see the Required Scopes section.
- Creating a clickwrap. Source. This example demonstrates how to use the Click API to create a clickwrap that you can embed in your website or app.
- Activate a clickwrap. Source. This example demonstrates how to use the Click API to activate a new clickwrap that you have already created.
- Creating a new clickwrap version. Source. This example demonstrates how to use the Click API to create a new version of a clickwrap.
- Getting a list of clickwraps. Source. This example demonstrates how to use the Click API to get a list of clickwraps associated with a specific DocuSign user.
- Getting clickwrap responses. Source. This example demonstrates how to use the Click API to get a list of clickwraps associated with a specific DocuSign user.
Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip items 1 and 2 below as they were automatically performed for you.
-
A free DocuSign developer account; create one if you don't already have one.
-
A DocuSign app and integration key that is configured for authentication to use either Authorization Code Grant or JWT Grant.
This video demonstrates how to obtain an integration key.
To use Authorization Code Grant, you will need an integration key and a secret key. See Installation steps for details.
To use JWT Grant, you will need an integration key, an RSA key pair, and the API Username GUID of the impersonated user. See Installation steps for JWT Grant authentication for details.
For both authentication flows:
If you use this launcher on your own workstation, the integration key must include a redirect URI of
http://localhost:3000/auth/docusign/callback
If you host this launcher on a remote web server, set your redirect URI as
{base_url}/auth/docusign/callback
where {base_url} is the URL for the web app.
-
Ruby version 2.7.2 or later
- Update the Gemfile to use later versions of Ruby.
- Windows x64 only:
- Ensure that your Ruby folder is appended with -x64, e.g. Ruby27-x64
- Install Curl for Ruby: Download libcurl.dll
Save libcurl-x64.dll as libcurl.dll
Place libcurl.dll in your Ruby folder, e.g. C:\Ruby27-x64\bin
Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip step 4 as it was automatically performed for you.
- Extract the Quickstart ZIP file or download or clone the code-examples-ruby repository.
- In your command-line environment, switch to the folder:
cd <Quickstart folder name>orcd code-examples-ruby - Install the dependencies:
bundle install - To configure the launcher for Authorization Code Grant authentication, create a copy of the file config/appsettings.example.yml and save the copy as config/appsettings.yml.
- Add your integration key. On the Apps and Keys page, under Apps and Integration Keys, choose the app to use, then select Actions > Edit. Under General Info, copy the Integration Key GUID and save it in appsettings.yml as your
integration_key. - Generate a secret key, if you don’t already have one. Under Authentication, select + ADD SECRET KEY. Copy the secret key and save it in appsettings.yml as your
integration_secret. - Add the launcher’s redirect URI. Under Additional settings, select + ADD URI, and set a redirect URI of http://localhost:3000/auth/docusign/callback. Select SAVE.
- Set a name and email address for the signer. In appsettings.yml, save an email address as
signer_emailand a name assigner_name.
Note: Protect your personal information. Please make sure that appsettings.yml will not be stored in your source code repository.
- Add your integration key. On the Apps and Keys page, under Apps and Integration Keys, choose the app to use, then select Actions > Edit. Under General Info, copy the Integration Key GUID and save it in appsettings.yml as your
- Run the launcher:
rails s - Open a browser to http://localhost:3000/auth/docusign
Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip step 4 as it was automatically performed for you.
Also, in order to select JSON Web Token authentication in the launcher, in config/appsettings.yml, change quickstart to false.
- Extract the Quickstart ZIP file or download or clone the code-examples-ruby repository.
- In your command-line environment, switch to the folder:
cd <Quickstart folder name>orcd code-examples-ruby - Install the dependencies:
bundle install - To configure the launcher for JWT Grant authentication, create a copy of the file config/appsettings.example.yml and save the copy as config/appsettings.yml.
- Add your API Username. On the Apps and Keys page, under My Account Information, copy the API Username GUID and save it in appsettings.yml as your
impersonated_user_guid. - Add your integration key. On the Apps and Keys page, under Apps and Integration Keys, choose the app to use, then select Actions > Edit. Under General Info, copy the Integration Key GUID and save it in appsettings.yml as your
jwt_integration_key. - Generate an RSA key pair, if you don’t already have one. Under Authentication, select + GENERATE RSA. Copy the private key and save it in a new file named config/docusign_private_key.txt.
- Add the launcher’s redirect URI. Under Additional settings, select + ADD URI, and set a redirect URI of http://localhost:3000/auth/docusign/callback. Select SAVE.
- Set a name and email address for the signer. In appsettings.yml, save an email address as
signer_emailand a name assigner_name.
Note: Protect your personal information. Please make sure that appsettings.yml will not be stored in your source code repository.
- Add your API Username. On the Apps and Keys page, under My Account Information, copy the API Username GUID and save it in appsettings.yml as your
- Run the launcher:
rails s - Open a browser to http://localhost:3000/auth/docusign
- If it is your first time using the app, grant consent by selecting Accept. On the black navigation bar, select Logout, then Login.
- From the picklist, select JSON Web Token (JWT) grant > Authenticate with DocuSign.
- Select your desired code example.
When using the Ruby launcher on a Windows machine you may get the following error:
SSL peer certificate or SSH remote key was not OK
This error occurs because you’re attempting to use the Ruby launcher with a self-signed certificate or without SSL/HTTP security. The API calls from Ruby SDKs are using a built-in Curl tool that is enforcing the SSL requirement. You can disable this security check to run the launcher in an insecure manner on your developer machine.
- It is highly recommended that you don’t disable this security check
- in a production environment or in your integration.
- This method is offered here solely as a means to enable you to
- develop quickly by lowering the security bar on your local machine.Find the root folder for your Ruby gems (in this case, a 64-bit version of Ruby 2.7.0):
C:\Ruby27-x64\lib\ruby\gems\2.7.0\gems\
Find the relevant DocuSign Ruby SDK you are using. The name always starts with “docusign”; for instance, DocuSign Click SDK version 1.0.0:
C:\Ruby27-x64\lib\ruby\gems\2.7.0\gems\docusign_click-1.0.0\lib\docusign_click
Find the configuration.rb file in that folder.
Modify the following two lines in the configuration.rb file, replacing true with false:
@verify_ssl = true
@verify_ssl_host = true
Once this is complete, you can run your Ruby on Rails application again and you should be able to make API calls on your localhost.
When using the Ruby launcher on OSX you may get the following error:
Faraday::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain))
Please update SSL certificates if rvm is your version manager. Or check other steps for different scenarios.
$ rvm osx-ssl-certs status all
$ rvm osx-ssl-certs update all
To use the payments code example, create a test payment gateway on the Payments page in your developer account. See Configure a payment gateway for details.
Once you've created a payment gateway, save the Gateway Account ID GUID to appsettings.yml.
This repository uses the MIT License. See LICENSE for details.
Pull requests are welcomed. Pull requests will only be considered if their content uses the MIT License.