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:

Configure your event listener

To create a new Pandadoc webhook:

  1. Open https://app.pandadoc.com/a/#/api/configuration
  2. Use the “Create webhook” button in the Webhooks section
2764

Create webhook

  1. Give your webhook a friendly name that says what the webhook is for
  2. Add your listener URL to the Webhook Endpoint URL field.
  3. Check “PDF of completed document available for download” under the “Subscribe to events” section.
  4. Optionally, use other features offered in the webhook configuration that are described outside the scope of this recipe.
  5. Save your changes when you are finished.
Create webhook

Create webhook

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.