Developer
E-signature webhooks: events, signature check and retries
A webhook tells your system when an envelope changes, so you do not have to poll. DocAISign sends a signed JSON POST to one https URL for 11 events. Check the HMAC signature on the raw body, answer with a 2xx status within 5 seconds, and skip any delivery id you have already handled. A failed delivery is tried up to five more times over about 11 hours.
Set the webhook
Set the URL on the Developer page of your account, with the CLI command docaisign webhook, or with PUT /api/v1/webhook. Send a list of events, or leave the list empty to receive all of them.
PUT /api/v1/webhook
{"url": "https://example.com/hooks/docaisign", "events": ["recipient-completed", "envelope-completed"]} - The URL must use https, point to a public address and be 500 characters or shorter
- The first PUT returns the signing secret, which starts with whsec_; later PUTs return null for it
- The Developer page shows the current secret and has a New secret button
- DELETE /api/v1/webhook removes the URL but keeps the secret, so setting a URL again does not issue a new one
The 11 events
Subscribe only to what your code acts on. Many integrations need just envelope-completed, envelope-declined, envelope-voided and envelope-expired.
- envelope-sent, envelope-completed, envelope-declined, envelope-voided, envelope-expired
- recipient-sent: it is now this recipient's turn and the invitation is going out
- recipient-delivered: the recipient opened the signing link for the first time
- recipient-completed, recipient-declined
- recipient-corrected: you changed the recipient's name or email
- recipient-reassigned: the recipient passed their part to someone else
What the request contains
Every envelope and recipient event carries the envelope. Recipient events fill recipient with the person concerned. Envelope events fill recipients with a list instead. On envelope-expired, that list holds only the people whose links expired. The sample below is shortened.
Use envelope.metadata to match the event to your own record. For example, a CRM can send a deal number as metadata when it creates the envelope and read it back here.
{
"event": "envelope-completed",
"id": "EVENT_ID",
"at": "2026-11-18T10:15:00.0000000Z",
"envelope": {
"id": "ENVELOPE_ID",
"status": "completed",
"testMode": false,
"metadata": {"dealId": "4411"}
},
"recipient": null,
"recipients": [
{"slot": 1, "name": "Ana Diaz", "email": "[email protected]", "status": "completed"}
]
} Verify the signature
Each request has three headers: X-DocAISign-Event, X-DocAISign-Delivery and X-DocAISign-Signature. The signature is sha256= followed by the lowercase hex HMAC-SHA256 of the raw body, keyed with your secret. Reject the request with a 401 if it does not match.
// Node.js with Express
app.post('/hooks/docaisign', express.raw({ type: 'application/json' }), (req, res) => {
const expected = Buffer.from('sha256=' + crypto.createHmac('sha256', SECRET).update(req.body).digest('hex'));
const received = Buffer.from(req.get('X-DocAISign-Signature') || '');
if (expected.length !== received.length || !crypto.timingSafeEqual(expected, received)) return res.sendStatus(401);
res.sendStatus(200); // then process the event
}); - Common mistake: parsing the JSON and signing it again, which changes the bytes
- Common mistake: comparing with == instead of a constant-time function
- Common mistake: calling timingSafeEqual on values of different lengths, which throws an error in Node.js
Retries and timeouts
A delivery succeeds only on a 2xx status. A timeout after 5 seconds, a connection error, any other status or a redirect counts as a failure, because DocAISign does not follow redirects. Save the event, answer at once, and do slow work such as downloading a PDF in a background job.
After a failure, DocAISign waits 1 minute, 5 minutes, 30 minutes, 2 hours and then 8 hours between tries. That makes six attempts in about 11 hours. After the sixth failure it gives up on that event.
- Check Recent deliveries on the Developer page to see each event's result and number of tries
- After an outage, call GET /api/v1/envelopes?status=completed to find anything you missed
Duplicates and event order
A retry can arrive after you already handled the event, for example when your server finished the work but answered too late. X-DocAISign-Delivery stays the same on every try of one event, so record it and ignore a value you have seen.
Do not depend on arrival order. A retried event can land after a newer one. When order matters, read envelope.status or call GET /api/v1/envelopes/{id} before you change your own record.
Test the whole flow
Start with Send test event on the Developer page. Its event name is test and it has no envelope, so make sure your handler accepts it without crashing. Then send a test envelope and sign it yourself. Test and live events go to the same URL, so branch on envelope.testMode.
When envelope-completed arrives, fetch the file with GET /api/v1/envelopes/{id}/documents/signed and store your own copy, because DocAISign deletes signed files after the retention period on its privacy page.
Common questions
Can one account have several webhook URLs?
No. Each account has one URL, so route events inside your own handler if several systems need them.
What happens when I create a new secret?
The old secret stops verifying at once. Deliveries that fail while you update your server are retried and signed with the new secret.
Does recipient-delivered mean the email reached the inbox?
No. It means the recipient opened the signing link, and it fires only the first time.