API mocks
DocuSign
A mock compatible with the DocuSign eSignature REST API v2.1. Your app authenticates, creates envelopes, embeds signing and downloads the signed documents as it does with DocuSign; a hosted signing page lets your tests (or a browser in CI) sign, decline or abandon each envelope, and Connect notifications arrive signed with HMAC. Nothing is legally signed. Envelopes, signatures and certificates of completion produced by the mock have no legal effect; use sample documents only. PDF documents up to 1 MB are kept with the envelope, for your plan's retention, so you can download them back.
Testlie is not affiliated with, endorsed by or sponsored by DocuSign. The name is a trademark of its owner, used here only to say which API this mock is compatible with.
Connect
Create a DocuSign mock under API mocks → Business tools. A mock is one DocuSign account with its own integration key, API user id, account id, secret key, RSA key pair and Connect HMAC key.
Use the mock's base URL for both hosts DocuSign uses:
| DocuSign | Mock |
|---|---|
https://account-d.docusign.com/oauth/... |
<base URL>/oauth/... |
https://demo.docusign.net/restapi/v2.1/accounts/{accountId}/... |
<base URL>/restapi/v2.1/accounts/{accountId}/... |
GET /oauth/userinfo returns the account with base_uri set to the mock's base URL, so apps that read base_uri (as DocuSign recommends) only need the OAuth host changed.
Authentication
- JWT grant:
POST /oauth/tokenwithgrant_type=urn:ietf:params:oauth:grant-type:jwt-bearerand an RS256 assertion signed with the mock's RSA private key (issthe integration key,subthe API user id,audaccount-d.docusign.com,scopeincludingsignature). Errors are DocuSign's:invalid_grantwithno_valid_keys_or_signatures,issuer_not_found,user_not_found,expired,consent_required. - Authorization code grant:
GET /oauth/auth?response_type=code&client_id=...&redirect_uri=...&scope=signature&state=...shows a consent page; redeem the code at/oauth/tokenwithAuthorization: Basic base64(integrationKey:secretKey). You get a refresh token too. - REST calls take
Authorization: Bearer <access token>. A bad token answers401 AUTHORIZATION_INVALID_TOKEN; another account id answersUSER_LACKS_MEMBERSHIP.
The SDKs' requestJWTUserToken only speaks HTTPS to an OAuth host, so build the assertion yourself (for example with jsonwebtoken) and post it, then give the access token to the SDK's ApiClient with setBasePath("<base URL>/restapi").
Envelopes
| Endpoint | |
|---|---|
POST /envelopes |
Create an envelope as a draft (status: "created") or sent, with base64 documents, recipients (signers, carbonCopies) and an optional eventNotification |
GET /envelopes/{id} |
The envelope (?include=recipients,documents) |
GET /envelopes?from_date=... |
List, filtered by status, envelope_ids, with count and start_position |
PUT /envelopes/{id} |
Send a draft (status: "sent") or void (status: "voided", voidedReason) |
GET /envelopes/{id}/recipients |
Recipients with their status and timestamps |
POST /envelopes/{id}/views/recipient |
Embedded signing URL for a signer with a clientUserId |
GET /envelopes/{id}/documents |
The document list |
GET /envelopes/{id}/documents/{documentId} |
A document as PDF; combined and certificate (certificate of completion) work too |
Validation follows DocuSign: ENVELOPE_IS_INCOMPLETE without documents, signers or subject; INVALID_EMAIL_ADDRESS_FOR_RECIPIENT; PDF_VALIDATION_FAILED for PDFs that are not PDFs; ENVELOPE_DOES_NOT_EXIST; UNKNOWN_ENVELOPE_RECIPIENT and RECIPIENT_NOT_IN_SEQUENCE for recipient views; ENVELOPE_CANNOT_VOID_INVALID_STATE.
Signers sign in routingOrder. The envelope goes sent → delivered (a signer opened it) → completed when everyone signed; declined when a signer declines; voided when you void it.
Signing
The url from a recipient view opens the mock's signing page with these choices, each returning to your returnUrl like DocuSign:
| Choice | Return |
|---|---|
| Finish | ?event=signing_complete |
| Finish later | ?event=cancel |
| Session times out | ?event=ttl_expired |
| Decline to sign | ?event=decline (the signer's declinedReason is what you typed) |
Remote signers (no clientUserId) would get an email from DocuSign. Here, GET /envelopes/{id}/testlie/signing_urls returns a signing page URL for each signer.
For tests without a browser, the everything is approved scenario signs every envelope for all signers as soon as it is sent, and everything is rejected has the first signer decline it.
Connect
Notifications go to the envelope's eventNotification.url, or else to the mock's webhook URL, in Connect's JSON format (event, apiVersion, uri, retryCount, configurationId, generatedDateTime, data with accountId, userId, envelopeId, recipientId and envelopeSummary). eventNotification.events (or the legacy envelopeEvents and recipientEvents) chooses which events are sent: envelope-sent, envelope-delivered, envelope-completed, envelope-declined, envelope-voided, recipient-sent, recipient-delivered, recipient-completed, recipient-declined.
Each notification carries X-DocuSign-Signature-1: the base64 HMAC-SHA256 of the body with the mock's Connect HMAC key.
Not supported
Templates and composite templates (answered with TEMPLATE_ID_INVALID), multipart document uploads, tab values, correction and sender views, bulk send and envelope locks. Documents over 1 MB are kept as a generated stand-in PDF.