Download a Completed Document
How to get a protected PDF copy of the document once it's completed by all signers
This recipe assumes that:
- You have authenticated via OAuth (see Authentication process) or have an API key (see API key authentication process)
Configure your event listener
To create a new Pandadoc webhook:
- Open https://app.pandadoc.com/a/#/api/configuration
- Use the “Create webhook” button in the Webhooks section
- Give your webhook a friendly name that says what the webhook is for
- Add your listener URL to the Webhook Endpoint URL field.
- Check “PDF of completed document available for download” under the “Subscribe to events” section.
- Optionally, use other features offered in the webhook configuration that are described outside the scope of this recipe.
- Save your changes when you are finished.
Capture Document ID from “completed” event
Once document is completed and the async PDF generation is done, you'll receive a webhook like this:
{
"event": "document_completed_pdf_ready",
"data": {
"id": "tKoqk92d2jiVuxUQH8i9iB",
...
},
"status": "document.completed",
...
}
Get the "id" of the document from the payload and use it to download the file.
Download Document
Using the ID from the webhook above, you can leverage the document download endpoint to retrieve your completed document.
GET https://api.pandadoc.com/public/v1/documents/{id}/download-protected
where {id} is document id from the webhook.
If you wish to add a watermark to the PDF, you should use simple /download endpoint, while /download-protected always return the same PDF file which is digitally sealed.
Updated 3 months ago