Integrating DocuSign with ServiceNow: A Step-by-Step Technical Guide

Published on

in

ServiceNow provides a DocuSign eSignature Spoke via IntegrationHub, which allows users to automate document signing workflows using Flow Designer and other low-code tools. This spoke supports sending documents for signature, managing envelopes, and syncing templates directly within ServiceNow.

However, if you are not using the spoke, whether due to licensing constraints, customisation requirements, or preference for direct API integration, this guide walks through the manual integration of DocuSign with ServiceNow using OAuth 2.0 and JWT authentication.

It is designed for developers and system administrators who want to enable secure digital signing workflows within ServiceNow without relying on the prebuilt spoke.

Note: This implementation was completed using the Washington release of ServiceNow and remains applicable as of the Yokohama release. The steps and configurations described here continue to work reliably in current environments.

Disclaimer: All keys, credentials, and configuration values shown in this guide are sample data only. Do not use them in your configuration. Always generate your own secure credentials and follow your organisation’s security policies.


Step 1: Set Up Your DocuSign Developer Account and Integration App

Before integrating DocuSign with ServiceNow, you need to set up a DocuSign Developer Account. This account gives you access to the sandbox environment where you can test API calls, authentication flows, and envelope creation without affecting live data.

Once your integration is working in development, you can promote your keys to production using this guide from DocuSign.

Create an Integration App

This app acts as the bridge between ServiceNow and DocuSign. It provides the credentials needed for authentication and API access.

StepAction
1Navigate to Settings > Apps and Keys in your DocuSign Developer Account
2Click Add App and Integration Key
3Save the credentials you obtain. These are required for OAuth and JWT setup

The keys below are for illustration only. They show the format and type of credentials you’ll need to copy from your own DocuSign integration app.

Credential TypeSample ValuePurpose
Integration Keyd2a87889-d1fb-4670-bf13-81dcfbebfe8bIdentifies your app when making API requests
Secret Keyaae0827b-a407-4a99-9467-6fde72aa77b9Authenticates your app securely during token exchange

These credentials are required for both OAuth 2.0 and JWT authentication flows. Keep them secure and never expose them in client-side code or public repositories.

Generate RSA Keypair

After creating your DocuSign Integration App, you need to generate an RSA keypair. This keypair is used to digitally sign JWT tokens, which ServiceNow will use to authenticate securely with DocuSign without requiring user interaction.

This step is essential for enabling JWT Bearer Grant authentication, which is ideal for server-to-server integrations.

StepAction
1Click Generate RSA Keypair in your DocuSign Integration App settings
2Copy the following values:
RSA Keypair ID: 3cd29b51-c6ba-4b93-b85e-b1f94bd24f06 (sample only)
Public Key and Private Key (used later to sign JWT tokens)

The keys shown above are for illustration only. They show the format and type of values you’ll need to copy from your own DocuSign setup. Keep your private key secure and never expose it publicly.

Configure Redirect URIs

Redirect URIs are a required part of the OAuth 2.0 Authorization Code Grant flow. They tell DocuSign where to send the authorization code after a user successfully grants access. This URI must match exactly between your DocuSign Integration App and your ServiceNow instance configuration.

FieldValue / ExamplePurpose / Description
Redirect URIhttps://yourinstancename.service-now.com/oauth_redirect.doReplace yourinstancename with your actual ServiceNow instance name. This is where DocuSign will redirect the user after authorisation.

This URI must be registered in your DocuSign Integration App settings. If it doesn’t match exactly, the OAuth flow will fail and ServiceNow won’t be able to retrieve the access token.

Configure Authentication Method and Allowed HTTP Methods

These settings define how your DocuSign Integration App will authenticate and what types of HTTP requests it can accept. This is essential for enabling secure communication between ServiceNow and DocuSign.

Authentication Method

SettingValuePurpose / Description
Secure Client Secret StorageYesConfirms that your application (ServiceNow) can securely store the client secret
Authentication MethodAuthorization Code GrantEnables OAuth 2.0 Authorization Code flow, which is used for user-authorised access

This ensures that DocuSign will issue tokens using the Authorization Code Grant flow, which is compatible with ServiceNow’s OAuth setup.

Allowed HTTP Methods

MethodPurpose / Description
GETUsed for retrieving data, such as checking connection or fetching envelope status
POSTUsed for sending data, such as creating envelopes or submitting documents
(Others)You may enable additional methods depending on your use case (e.g., PUT, DELETE)

These methods define what types of API calls your integration app can handle. For most ServiceNow-to-DocuSign interactions, GET and POST are sufficient.

You may refer to this ServiceNow KB article, but not all steps are required if you’re not using ServiceNow Spokes.


Step 2: Generate the JKS File for JWT Authentication

To enable JWT authentication in ServiceNow, you need to create a Java Key Store (JKS) file that contains your DocuSign private key. This file allows ServiceNow to securely sign JWT tokens when authenticating with DocuSign.

JWT authentication is ideal for server-to-server integrations where user interaction is not required. It allows ServiceNow to impersonate a DocuSign user and perform actions like sending envelopes or retrieving status updates.

Tools Required

ToolPurposeDownload / Source
OpenSSL for WindowsUsed to generate a certificate and export it to PKCS12 formatDownload here
OpenSSL Wiki
Java JDKRequired to run the keytool command, which converts PKCS12 to JKS formatDownload here

You’ll use OpenSSL to generate a certificate from your private key, then convert it to a JKS file using Java’s keytool utility. This JKS file will later be uploaded to ServiceNow as part of the JWT configuration.

Steps to Generate the JKS File for JWT Authentication

This process converts your DocuSign private key into a Java Key Store (JKS) file, which ServiceNow uses to sign JWT tokens securely. The JKS file is a required component for enabling JWT Bearer Grant authentication.

Step-by-Step Instructions

StepActionPurpose / Description
1Create a private key file
Copy the private key from your DocuSign Integration App and save it as privatekey.key. Move this file to C:\certificate.
This file will be used to generate a certificate for signing JWT tokens.
2Generate a certificate using OpenSSL
Open Command Prompt as Administrator and run:
cd "C:\Program Files\OpenSSL-Win64\bin"
openssl req -new -x509 -key C:\certificate\privatekey.key -out cacert.pem -days 1095
This creates a self-signed certificate (cacert.pem) from your private key.
3Enter certificate details when prompted
Examples: Country, State, Organization, Email
These details are embedded in the certificate and help identify the source of the key.
4Export to PKCS12 format
Run:
openssl pkcs12 -export -in cacert.pem -inkey C:\certificate\privatekey.key -certfile cacert.pem -out testkeystore.p12
Converts the certificate and key into a .p12 file. You’ll be prompted to create a secure export password. Store it safely.
5Convert to JKS format using Java keytool
Change directory:
cd "C:\Program Files\Java\jdk-22\bin"
Then run:
keytool -importkeystore -srckeystore "C:\Program Files\OpenSSL-Win64\bin\testkeystore.p12" -srcstoretype pkcs12 -destkeystore ranDocusign.jks -deststoretype JKS
Converts the .p12 file into a .jks file. You’ll be prompted for the password you created in the previous step.
6Locate the JKS file
The file ranDocusign.jks will be created in your Java bin directory.:

C:\Program Files\Java\jdk-22\bin>
This file will be uploaded to ServiceNow in the next step to configure JWT authentication.

The JKS file securely stores your private key and certificate. It is essential for ServiceNow to sign JWT tokens and authenticate with DocuSign without user interaction.


Step 3: Configure ServiceNow for OAuth and JWT

Create Certificate in ServiceNow

The certificate in ServiceNow stores your DocuSign private key securely in a Java Key Store (JKS) format. This is required for signing JWT tokens during authentication. Without this certificate, ServiceNow cannot generate valid JWTs to communicate with DocuSign.

StepField / ActionDetails
1NavigationGo to System Definition > Certificates
2Create CertificateClick New
3NameDocuSign Certificate – This is a label for your keystore.
4TypeJava Key Store – Select this to match the format of the .jks file you generated.
5PasswordEnter the password used when converting the PKCS12 file to JKS using the keytool command.
This password unlocks the keystore and allows ServiceNow to access the private key for JWT signing.
Important: Store this password securely.
6Upload FileUpload the .jks file you generated earlier.
7TroubleshootingIf ServiceNow does not allow the upload, proceed to the next troubleshooting step (not specified).

This certificate is a critical part of the JWT authentication flow. It ensures that ServiceNow can securely sign tokens using your DocuSign private key.

Create JWT Key in ServiceNow

JWT (JSON Web Token) authentication allows ServiceNow to securely communicate with DocuSign without requiring user interaction each time. The JWT Key configuration tells ServiceNow how to sign tokens using the certificate you uploaded earlier.

StepField / ActionDetails
1NavigationGo to System OAuth > JWT Keys
2Create JWT KeyClick New
3NameDocuSign JWT Keys – This is a label for your JWT key configuration.
4Signing KeystoreSelect the certificate you created earlier (e.g., DocuSign Certificate)
5Signing AlgorithmRSA 256 – This is the algorithm used for signing JWTs.
6Signing KeyEnter the password used when creating the JKS file via the keytool command.
This password allows ServiceNow to access the private key stored in the keystore.
Important: Store this password securely. It is required for JWT token signing with DocuSign.

Create JWT Provider in ServiceNow

The JWT Provider in ServiceNow defines how the platform will generate and manage JWT tokens when authenticating with DocuSign. It links the signing configuration (your JWT Key) with the logic that builds the token and sets its expiration.

To configure it:

StepField / ActionDetails
1NavigationGo to System OAuth > JWT Providers
2Create JWT ProviderClick New
3NameDocuSign JWT Provider – This is a label for your configuration.
4Signing ConfigurationSelect the JWT Key you created earlier (e.g., DocuSign JWT Keys)
This tells ServiceNow which keystore and algorithm to use for signing the token.
5JWT API ScriptJWTTokenInternal – This is the default script used to generate the JWT payload.
6Expiry Interval60 seconds – Defines how long the token is valid before it expires.
A short interval like 60 seconds is typical for secure, short-lived tokens.
7Security NoteImportant: The JWT Provider enables ServiceNow to authenticate with DocuSign using JWT Bearer Grant. It ensures tokens are signed correctly and securely using your private key.

Add Standard Claims

These claims are required for JWT authentication:

ClaimDescriptionSample Value
audAudience – the intended recipient of the token. For DocuSign, this is usually the base URL of the API you’re calling.account-d.docusign.com
issIssuer – the Integration Key from your DocuSign app. This identifies the application making the request.d2a87889-d1fb-4670-bf13-81dcfbebfe8b
subSubject – the user ID (GUID) of the DocuSign user on whose behalf the request is made. This user must have admin privileges.cfd62061-463a-41b7-b58a-859cbb026ae6
scopePermissions requested. For signing documents, use signature impersonation.signature impersonation

For more details, refer to:


Step 4: Create OAuth Profile in ServiceNow

The OAuth Profile defines how ServiceNow connects to DocuSign using the Authorization Code Grant method. This setup allows ServiceNow to securely obtain access and refresh tokens after a user authorises the connection. It is essential for enabling authenticated API calls to DocuSign.

FieldValue / ExamplePurpose / Description
NameDocuSign OAuthA label for your OAuth configuration
Client IDd2a87889-d1fb-4670-bf13-81dcfbebfe8b (sample only)The Integration Key from your DocuSign app. Identifies the application making the request
Client Secretaae0827b-a407-4a99-9467-6fde72aa77b9 (sample only)The Secret Key from your DocuSign app. Used to authenticate the app securely
OAuth API ScriptOAuthUtilThe default script used to handle OAuth token exchange
Default Grant TypeAuthorization CodeEnables user-based authorisation flow
Accessible FromAll application scopesMakes the profile usable across your ServiceNow instance
Authorization URLhttps://account-d.docusign.com/oauth/authWhere users are redirected to authorise access
Token URLhttps://account-d.docusign.com/oauth/tokenWhere ServiceNow exchanges the authorisation code for an access token
Redirect URLhttps://{instance}.service-now.com/oauth_redirect.doReplace {instance} with your actual ServiceNow instance name. DocuSign sends the authorization code here after user consent

This profile is required for ServiceNow to initiate and manage OAuth 2.0 connections with DocuSign using the Authorization Code Grant flow.

Add Entity Profiles

Entity Profiles in ServiceNow define how each OAuth or JWT credential will be used. They act as a bridge between your OAuth Profile and the actual credentials used in IntegrationHub or REST API calls. You can have multiple profiles for different grant types (e.g., Authorization Code vs JWT Bearer), and specify which one is the default.

NameGrant TypeIs DefaultPurpose / Description
DocuSign OAuth ProfileAuthorization CodeTrueUsed for user-authorised access. This profile is the default for flows requiring user consent
DocuSign JWT ProfileJWT BearerFalseUsed for server-to-server authentication without user interaction. Ideal for background automation

These profiles allow ServiceNow to choose the correct authentication method when making API calls to DocuSign, depending on the use case.


Step 5: Create Credentials in IntegrationHub

Credentials in IntegrationHub allow ServiceNow to authenticate securely when making REST API calls to DocuSign. You need to create two credentials: one for OAuth (Authorization Code Grant) and one for JWT (JWT Bearer Grant). These credentials reference the entity profiles you configured earlier and are used by Flow Designer, Scripted REST APIs, or custom integrations.

OAuth Credential

FieldValue / ExamplePurpose / Description
NameDocuSign OAuth CredentialA label for the credential
OAuth Entity ProfileDocuSign OAuth ProfileLinks to the entity profile using Authorization Code Grant
Applies ToAll MID serversEnsures the credential is available across all integration points
Order100Determines priority if multiple credentials exist

After saving, click Get OAuth Token to verify the setup. If successful, ServiceNow will retrieve a valid access and refresh token from DocuSign.

JWT Credential

Repeat previous stem, click Create New, select OAuth 2.0 and enter the following information:

FieldValue / ExamplePurpose / Description
NameDocuSign JWT CredentialA label for the credential
OAuth Entity ProfileDocuSign JWT ProfileLinks to the entity profile using JWT Bearer Grant
Applies ToAll MID serversEnsures the credential is available across all integration points
Order100Determines priority if multiple credentials exist

After saving, click Get OAuth Token to verify the JWT setup. If successful, ServiceNow will generate a signed JWT, exchange it for an access token, and confirm the connection to DocuSign.

These credentials are essential for enabling secure, token-based communication between ServiceNow and DocuSign. They allow your flows and scripts to authenticate without hardcoding sensitive information.


Step 6: Test the Integration

Once your OAuth and JWT credentials are configured, it’s important to verify that ServiceNow can successfully connect to DocuSign and perform key operations. This test script does two things:

  1. Confirms connectivity by calling the DocuSign login endpoint.
  2. Creates and sends an envelope using a sample PDF attachment stored in ServiceNow.

This helps ensure that your authentication setup and REST message configurations are working correctly.

Use the following script to test login and envelope creation. This script verifies that your DocuSign integration is functional. If the connection and envelope creation succeed, your setup is complete and ready for use in production workflows.

// Test connection to DocuSign
var r = new sn_ws.RESTMessageV2('global.DocuSign_Login', 'Default GET');
var response = r.execute();
gs.info("connectToDocuSign: " + response.getStatusCode());

// Prepare document from sys_attachment
var gr = new GlideRecord('sys_attachment');
gr.get('fad537d73387c6108c66e6b45d5c7b83'); // Replace with your actual sys_id
var sa = new GlideSysAttachment();
var binData = sa.getBytes(gr);
var encData = GlideStringUtil.base64Encode(binData);

// Create envelope and send for signature
var createEnvelope = new sn_ws.RESTMessageV2('global.DocuSign_Create_Envelope', 'Default POST');
var jsonBody = {
  emailSubject: "Please sign the document",
  documents: [{
    name: "sample.pdf",
    documentId: "1",
    documentBase64: encData
  }],
  recipients: {
    signers: [{
      deliveryMethod: "Email",
      name: "Arlene H1",
      email: "myemail1@example.com",
      routingOrder: "1",
      recipientId: "1"
    }],
    carbonCopies: [{
      email: "myemail2@example.com",
      name: "Arlene H2",
      routingOrder: "2",
      recipientId: "2"
    }]
  },
  status: "sent",
  messageLock: "true"
};

createEnvelope.setRequestBody(JSON.stringify(jsonBody));
var createEnvelopeResponse = createEnvelope.execute();
gs.info("createEnvelopeResponse: " + createEnvelopeResponse.getStatusCode());
gs.info("createEnvelopeResponseBody: " + createEnvelopeResponse.getBody());

Final Thoughts

This integration enables secure, automated document signing workflows directly within ServiceNow. By using both OAuth and JWT, you can support impersonated signing, delegated access, and other advanced use cases.

Reminder: Replace all sample keys, secrets, and user IDs with your own secure credentials.

Leave a Reply


Hey!

Hey there and welcome! This space is where I share what I’ve learned from years of analysing problems, designing solutions, and building systems, from Microsoft technologies to ServiceNow to Oracle and beyond.

I’m fascinated by how ideas turn into working solutions. It’s not just about integrations or tools but about understanding what people need, finding the right balance between logic and usability, and shaping designs that actually work in the real world.

If you enjoy exploring how technology, process, and design come together to solve problems, you’ll feel right at home here. Grab a coffee, take a look around, and maybe you’ll find something that inspires your next build or sparks a new idea.


Stay Connected

I share stories, lessons, and discoveries from years of analysing and designing systems. Check back for fresh ideas and practical insights.


Categories


Discover more from arleneh

Subscribe now to keep reading and get access to the full archive.

Continue reading