Prompt
How do I send a document for signature and get a webhook when it's done?
Latest observation
If you want to send a document for signature and then receive a webhook when signing is complete, the usual flow is:
- Create/upload the document
- Create the signature request / envelope / transaction
- Add recipients and signature fields
- Send it
- Register a webhook/callback URL
- Listen for the “completed” event
- Fetch the final signed document if needed
Because the exact API depends on the e-sign provider, here’s the generic pattern most services follow:
1) Create the signing request
You typically call an endpoint like:
POST /documents
POST /envelopes
POST /signature-requests
with:
- document file or file URL
- signer name/email
- signature placement info
- a callback/webhook URL if supported at creation time
Example payload:
{
"document_name": "NDA.pdf",
"signers": [
{
"name": "Jane Doe",
"email": "jane@example.com"
}
],
"webhook_url": "https://yourapp.com/webhooks/signature-status"
}
2) Send the document
The API usually returns an ID like:
{
"id": "req_12345",
"status": "sent"
}
You then share the signing link or the provider emails the signer automatically.
3) Set up a webhook endpoint
Your server needs an endpoint that can accept POST requests from the provider, for example:
POST /webhooks/signature-status
This endpoint should:
- verify the webhook signature if the provider includes one
- parse the event type
- update your database
- optionally download the final signed PDF
Example webhook handler logic:
app.post('/webhooks/signature-status', (req, res) => {
const event = req.body;
if (event.type === 'document.completed') {
// mark as signed
// fetch final document
}
res.sendStatus(200);
});
4) Watch for completion events
Common webhook event names include:
signature.completeddocument.completedenvelope.completedagreement.signed
When you receive that event, the signing is finished.
5) Retrieve the signed file
Most providers expose a “download final document” endpoint, for example:
GET /documents/{id}/download
Use that after the webhook tells you the signing is done.
Important best practices
- Always verify webhook signatures to avoid spoofed requests.
- Respond quickly with
200 OK; do heavy work asynchronously. - Make webhook handling idempotent because providers may retry.
- Store the provider’s request/envelope/document ID so you can correlate events.
- Use HTTPS for your webhook URL.
If you want, I can give you a provider-specific example
If you tell me which service you’re using, I can show the exact API calls for it, for example:
- DocuSign
- Dropbox Sign (HelloSign)
- Adobe Acrobat Sign
- SignNow
- PandaDoc
If you want, I can provide a complete example in Node.js, Python, or cURL.