Backend API that integrates with the DocuSign eSignature API to create envelopes and generate embedded signing URLs for recipients.
This application exposes endpoints used by a frontend form/signing flow.
Main workflow:
- A user fills out a form in the frontend.
- The backend creates a DocuSign envelope.
- The backend generates an embedded signing URL for the recipient.
- The frontend receives that URL and redirects the user to the DocuSign signing page.
The signing process uses embedded signing via a generated recipient view URL.
This backend follows Clean Architecture to keep responsibilities separated and code easier to maintain.
In short: Presentation handles HTTP, Application runs use cases, Domain defines contracts, and Infrastructure integrates with DocuSign and external services.
Creates a new DocuSign envelope based on submitted form data.
Behavior:
- Requires authenticated DocuSign context via middleware.
- Returns the created
envelopeIdas JSON.
Generates an embedded signing URL for the specified recipient.
Path parameters:
envelopeId: DocuSign envelope identifier.email: recipient email.name: recipient full name.role: currently expected assigner.
Behavior:
- Backend validates role.
- Backend returns JSON with signing URL (no HTTP redirect):
{
"signingUrl": "https://..."
}Note:
- The project also keeps a compatibility route:
GET /signature/:envelopeId/:email/:name/:role.
This codebase currently reads the following variables:
| Variable | Required | Description |
|---|---|---|
APP_PORT |
Yes | Port where the backend runs (example: 3000). |
BASE_PATH |
Yes | DocuSign REST base path (example: https://demo.docusign.net/restapi). |
INTEGRATION_KEY |
Yes | DocuSign Integration Key (client ID). |
USER_ID |
Yes | DocuSign user GUID used for JWT impersonation. |
ACCOUNT_ID |
Yes | DocuSign account GUID used in API requests. |
CLIENT_USER_ID |
Yes | Embedded signing client user ID for recipient view. |
TEMPLATE_ID |
Yes | DocuSign template ID used for envelope creation. |
ORIGIN |
Yes | Allowed frontend origin for CORS and signing return URL fallback. |
RETURN_URL |
Yes | Frontend URL used after embedded signing is completed. |
SESSION_SECRET |
Yes | Secret used by express-session. |
Before running the project, grant consent for the integration key/user in your DocuSign developer environment.
Open this URL in your browser and replace placeholders:
https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature%20impersonation&client_id=(YOUR%20INTEGRATION%20KEY)&redirect_uri=http://localhost:3000/
Steps:
- Replace
(YOUR INTEGRATION KEY)with your DocuSign Integration Key. - Replace the
redirect_uriif your app runs on a different URL. - Open the URL in your browser.
- Sign in with your DocuSign developer account.
- Grant permission to the application.
- After authorization, DocuSign redirects with an authorization code in the URL.
This consent step allows the backend to interact with the DocuSign API on behalf of the configured user.
- Clone the repository.
- Enter the project folder.
- Install dependencies.
- Create and configure
.env. - Place
private.keyin the project root. - Authorize the DocuSign integration (consent step above).
- Start the server.
Example:
git clone <repository-url>
cd docusign-integration
npm install
npm run dev- Node.js
- Express
- TypeScript
- Jest
- Clean Architecture principles
- DocuSign eSignature API
