> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# Ruby SDK setup and configuration

## Adding the SDK to your project

The Ruby SDK is provided as a gem named
[docusign_esign](https://rubygems.org/gems/docusign_esign/). By default, you will always get the latest stable version of the SDK. Prerelease versions (either release candidate (rc) or beta) can also be downloaded, as shown below.

There are three ways to add the package to your project: via your project’s Gemfile, your preferred console, or by downloading the SDK from GitHub.

### Adding the Ruby SDK to your project using your project’s Gemfile

1. In your application's Gemfile, add:
   `gem 'docusign_esign'`
2. Open your console, navigate to your project directory, and run:
   `bundle install`

If desired, you can specify a version. For example, adding the following to your project’s Gemfile installs version 3.5.0 of the Docusign Ruby eSignature gem:

```text
    gem 'docusign_esign', '~> 3.5'
```

### Adding the Ruby SDK to your project using your console

1. In your console, run:
   `gem install docusign_esign`

To specify a version using your console, you can use the -v switch as in the following example:

```text
    gem install docusign_esign -v 3.5.0
```

### Downloading the SDK from the GitHub repository

This open-source SDK is available for download in cases where you would like to make changes to the SDK. You can download the SDK from GitHub using the instructions below:

1. Download or clone the SDK from the
   [docusign-esign-ruby-client](https://github.com/docusign/docusign-ruby-client) repository.

2. In the console, navigate to local_path_to_repo/docusign-esign-ruby-client and run the following command:

```text
    gem build docusign_esign.gemspec
```

3. Install the gem from the newly generated gem file. For example:

```text
    gem install docusign_esign-3.9.0.gem
```

You can also select a different version to download from the
[docusign-esign-ruby-client](https://github.com/docusign/docusign-ruby-client) repository's
[release history](https://github.com/docusign/docusign-ruby-client/releases).

## Including the SDK library

Once you have installed the docusign_esign gem, you need to find the public classes that are required to complete various eSignature tasks. When developing with Ruby on Rails and Bundler, the following line in config/application.rb takes care of requiring all the gems specified in your Gemfile:

```text
    Bundler.require(*Rails.groups)
```

When using RubyGems by itself, you must add the following
`require` statement in your Ruby code:

```text
    require 'docusign_esign'
```

To access Docusign eSignature public classes and methods in your code, use the namespace
`Docusign_eSign`.

### [Docusign eSignature API classes](https://github.com/docusign/docusign-ruby-client/tree/master/lib/docusign_esign/api)

These Ruby SDK classes contain endpoint categories. Each of these classes corresponds to one of the categories listed in the left menu of the
[eSignature REST API reference](/docs/esign-rest-api/reference). You will need these classes to make calls to the SDK methods that initiate REST API calls to the Docusign eSignature REST API.

**Note:** Hereafter in the SDK documentation, the term “API object” will refer to
[eSignature REST API reference](/docs/esign-rest-api/reference) objects.

An
[API category](/docs/esign-rest-api/reference) contains all of the methods for each API resource in that category. For example, the Ruby SDK
`EnvelopesApi` class includes the
`create_envelope` method. This method corresponds to the API Envelopes resource
[create](/docs/esign-rest-api/reference/envelopes/envelopes/create) method.

The SDK’s method names roughly correspond to the API Resource:method names.

The API Reference page for each endpoint lists the corresponding SDK method associated with that endpoint. To find the Ruby SDK method that corresponds to an API Resource:method page, use the API Reference page’s
**SDK Method** box. The Ruby method name will be the “snake_case” version of the API SDK method name. For example, the API SDK Method
`Envelopes::createEnvelope` is the Ruby SDK method
`create_envelope` .

### [Docusign eSignature Model classes](https://github.com/docusign/docusign-ruby-client/tree/master/lib/docusign_esign/models)

These classes contain the objects used for sending and receiving data from the eSignature API endpoints. By using these classes instead of generic JSON objects, Ruby developers can develop with the Docusign eSignature API more easily and quickly than by using JSON directly.

There’s a one-to-one correspondence between the objects described in the
[API Reference](/docs/esign-rest-api/reference) and the classes in the Ruby Docusign eSignature Model classes. The API object names use camelCase (the first letter is lowercase) while the corresponding SDK models use PascalCase (the first letter is uppercase). For example, the API object
[paymentgatewayaccount](/docs/esign-rest-api/reference/payments/paymentgatewayaccounts/list#response200_paymentgatewayaccount) corresponds to the Ruby object
[PaymentGatewayAccount](https://github.com/docusign/docusign-ruby-client/blob/master/lib/docusign_esign/models/payment_gateway_account.rb).

**Note:** The API object name is often not the same as the corresponding model in the Ruby SDK.

Object attribute names in the API also use camelCase. The corresponding properties of the Ruby SDK are in “snake_case.”

Some API endpoints also use HTTP query parameters. Within the API, such query parameters use “snake_case.” For example, the
[Envelopes:create](/docs/esign-rest-api/reference/envelopes/envelopes/create) API method includes an optional query parameter,
`change_routing_order`. Within the SDK, the API’s query parameters are added as an elective
`options` parameter after the request object.

**Example:** The
`Docusign_eSign::EnvelopesApi.create_envelope` method signature is:

```text
    def create_envelope(account_id, envelope_definition, options = Docusign_eSign::CreateEnvelopeOptions.default)
```

The
`CreateEnvelopeOptions` class is used to set the API method’s query parameters. The class is defined as:

```text
      class CreateEnvelopeOptions
        attr_accessor :cdse_mode
        attr_accessor :change_routing_order
        attr_accessor :completed_documents_only
        attr_accessor :merge_roles_on_draft
        attr_accessor :tab_label_exact_matches

        def self.default
          @@default ||= CreateEnvelopeOptions.new
        end
      end
```

The class attributes in "snake_case" correspond to the API endpoint's query parameters.

### [Docusign eSignature Client, OAuth, and ApiError classes](https://github.com/docusign/docusign-ruby-client/tree/master/lib/docusign_esign/client)

These classes are needed to manage the overall API experience. The
`Client`,
`OAuth`, and
`ApiError` classes, respectively, handle instantiating a client element to make API calls, authenticating, and exception handling. You will need these classes to be able to use the Docusign eSignature API correctly.

### Using the SDK

To make eSignature REST API calls with the SDK, you need:

* A current access token
* The base path for the API call
* For most API calls, you’ll also need the relevant
  `account_id`. Note that it is common for a user to be a member of multiple accounts.