SDKs overview
The DocuSign API offers a suite of official Software Development Kits (SDKs) designed to streamline the integration of e-signature capabilities into various applications. These SDKs provide an abstraction layer over the DocuSign eSignature REST API, handling aspects such as authentication, request formatting, and response parsing. Developers can utilize these language-specific libraries to interact with core DocuSign functionalities, including creating and sending envelopes, managing recipients and documents, and retrieving signing status updates. The availability of SDKs across multiple popular programming languages aims to reduce development time and complexity for integrating DocuSign’s services, ensuring a consistent developer experience across platforms as detailed in the DocuSign eSignature REST API documentation.
Using an SDK can simplify the development process by providing pre-built methods and objects that map directly to API resources and actions. This approach helps developers quickly implement common e-signature workflows without needing to manage the intricacies of direct HTTP requests and JSON parsing. For instance, an SDK might offer a method like createEnvelope() that encapsulates the entire process of constructing and sending an e-signature request, including specifying signers, documents, and tabs. This contrasts with directly calling the REST API, which would require manual construction of the JSON payload and handling of HTTP status codes. The SDKs are regularly updated to reflect new API features and ensure compatibility with the latest DocuSign platform enhancements.
Official SDKs by language
DocuSign provides official SDKs for several programming languages, each maintained to support the latest features of the eSignature REST API. These SDKs are the recommended method for interacting with the DocuSign API, offering a robust and well-documented interface. Each SDK is designed to be idiomatic to its respective language, providing a natural development experience for developers familiar with that ecosystem. The following table outlines the officially supported SDKs, their typical package names, and common installation methods:
| Language | Package Manager/Name | Install Command (Example) | Maturity |
|---|---|---|---|
| C# | NuGet (DocuSign.eSign.dll) | Install-Package DocuSign.eSign |
Stable |
| Java | Maven/Gradle (docusign-esign-java) | Maven: <dependency><groupId>com.docusign</groupId><artifactId>docusign-esign-java</artifactId><version>...</version></dependency> |
Stable |
| Node.js | npm (@docusign/esign-rest-api) | npm install @docusign/esign-rest-api |
Stable |
| PHP | Composer (docusign/esign-client) | composer require docusign/esign-client |
Stable |
| Python | pip (docusign-esign) | pip install docusign-esign |
Stable |
| Ruby | RubyGems (docusign_esign) | gem install docusign_esign |
Stable |
Each SDK repository typically includes examples and comprehensive documentation to assist developers in getting started. For detailed API methods and data structures, developers can refer to the DocuSign eSignature API reference.
Installation
Installing a DocuSign SDK typically involves using the standard package manager for the chosen programming language. The process is generally straightforward, requiring a single command to add the SDK to your project's dependencies. Below are specific installation instructions for each official SDK:
C#
For C# projects, the DocuSign SDK is available via NuGet. Open your project in Visual Studio, navigate to the NuGet Package Manager, and search for DocuSign.eSign, or use the Package Manager Console:
Install-Package DocuSign.eSign
Java
Java developers can add the DocuSign eSignature Java client to their Maven or Gradle project dependencies. For Maven, add the following to your pom.xml:
<dependency>
<groupId>com.docusign</groupId>
<artifactId>docusign-esign-java</artifactId>
<version>[LATEST_VERSION]</version>
</dependency>
Replace [LATEST_VERSION] with the current version, which can be found on the DocuSign SDKs and Tools page.
Node.js
Node.js developers can install the SDK using npm:
npm install @docusign/esign-rest-api
PHP
For PHP projects, Composer is used to manage dependencies:
composer require docusign/esign-client
Python
Python developers can install the SDK using pip:
pip install docusign-esign
Ruby
Ruby projects use RubyGems for installation:
gem install docusign_esign
After installation, each SDK requires configuration, typically involving an integration key, API account ID, and user ID, along with an access token obtained through an OAuth 2.0 flow. DocuSign supports various OAuth 2.0 grant types, including Authorization Code Grant and JSON Web Token (JWT) Grant, as described in their OAuth 2.0 documentation. For example, JWT Grant is often used for server-to-server integrations where user interaction is not required for authentication, which aligns with common practices for secure API access as outlined by organizations like OAuth.net.
Quickstart example
This Python example demonstrates how to use the DocuSign Python SDK to create and send an envelope with a single document and recipient. Before running this code, ensure you have installed the docusign-esign package and replaced placeholder values with your actual DocuSign credentials and file paths.
import docusign_esign as ds
from docusign_esign.client.api_client import ApiClient
from docusign_esign.client.models import EnvelopeDefinition, Document, Signer, Tabs, SignHere, Recipients
import base64
# --- Configuration Variables ---
# Replace with your actual values
CLIENT_ID = "YOUR_INTEGRATION_KEY" # Your DocuSign Integration Key
IMPERSONATED_USER_ID = "YOUR_API_USER_ID" # The API user ID (GUID) of the user sending envelopes
ACCOUNT_ID = "YOUR_ACCOUNT_ID" # Your DocuSign Account ID
PRIVATE_KEY_PATH = "path/to/your/private_key.pem" # Path to your private key file for JWT
AUTH_SERVER = "account-d.docusign.com" # For demo/sandbox, use 'account-d.docusign.com'; for production, use 'account.docusign.com'
DOC_FILE = "path/to/your/document.pdf" # Path to the document you want to send
RECIPIENT_NAME = "John Doe"
RECIPIENT_EMAIL = "[email protected]"
# --- JWT Authentication (Example) ---
def get_access_token():
api_client = ApiClient()
api_client.set_oauth_host(f"https://{AUTH_SERVER}")
with open(PRIVATE_KEY_PATH, "r") as f:
private_key = f.read()
try:
token_response = api_client.request_jwt_user_token(
client_id=CLIENT_ID,
user_id=IMPERSONATED_USER_ID,
oauth_host=f"https://{AUTH_SERVER}",
private_key_bytes=private_key.encode('ascii'),
expires_in=3600, # 1 hour
scopes=["signature", "impersonation"] # Required scopes
)
return token_response.access_token
except Exception as e:
print(f"Error during JWT authentication: {e}")
return None
# --- Main Function to Send Envelope ---
def send_envelope():
access_token = get_access_token()
if not access_token:
return
# Initialize API Client
api_client = ApiClient(host=f"https://{AUTH_SERVER}/restapi")
api_client.set_default_header("Authorization", f"Bearer {access_token}")
# Create an instance of the EnvelopesApi
envelopes_api = ds.EnvelopesApi(api_client)
# Read the document file and encode it to base64
with open(DOC_FILE, "rb") as file:
content_bytes = file.read()
base64_document = base64.b64encode(content_bytes).decode('utf-8')
# Define the document
document = Document(
document_base64=base64_document,
name="Example Document",
file_extension="pdf",
document_id="1"
)
# Define a 'Sign Here' tab for the recipient
sign_here = SignHere(
document_id="1",
page_number="1",
x_position="100",
y_position="100"
)
# Define the recipient's tabs
tabs = Tabs(sign_here_tabs=[sign_here])
# Define the recipient
signer = Signer(
email=RECIPIENT_EMAIL,
name=RECIPIENT_ID,
recipient_id="1",
routing_order="1",
tabs=tabs
)
# Define the recipients list
recipients = Recipients(signers=[signer])
# Define the envelope
envelope_definition = EnvelopeDefinition(
email_subject="Please sign this document",
documents=[document],
recipients=recipients,
status="sent" # Set to 'sent' to send immediately
)
try:
# Send the envelope
envelope_summary = envelopes_api.create_envelope(ACCOUNT_ID, envelope_definition=envelope_definition)
print(f"Envelope sent successfully! Envelope ID: {envelope_summary.envelope_id}")
except ds.ApiException as e:
print(f"Error sending envelope: {e}")
if __name__ == "__main__":
send_envelope()
This example demonstrates the basic structure for authenticating and sending an envelope. Real-world applications would require more robust error handling, dynamic document and recipient generation, and potentially more complex tab placement. For a complete guide to authentication and advanced features, refer to the DocuSign authentication documentation.
Community libraries
While DocuSign provides a comprehensive set of official SDKs, the developer community also contributes various tools and libraries that can enhance or extend DocuSign integrations. These community-driven projects often address niche use cases, provide wrappers for less common languages, or offer supplementary utilities not covered by the official SDKs. Examples might include client libraries for specific frameworks (e.g., a Django or Rails integration library), specialized webhook handlers, or tools for managing DocuSign templates outside the primary API. However, it's important to note that community libraries may not offer the same level of support, maintenance, or security guarantees as official DocuSign SDKs. Developers should thoroughly vet any third-party library for reliability, active maintenance, and adherence to security best practices before incorporating it into production systems.
For instance, developers might find community-contributed examples or utilities on platforms like GitHub that demonstrate integration with other services or provide helper functions for complex document generation. While DocuSign's official SDKs focus on direct API interaction, community libraries can sometimes bridge gaps for specific workflow automation or unique UI requirements. Always consult the official DocuSign SDKs and Tools page for the most up-to-date information on supported libraries and to ensure compatibility and security when choosing between official and community-contributed resources.