Download a Completed Document

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 you will remember
  2. Add your listener URL to the Webhook Endpoint URL field.
  3. Check “Document state changed” 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.
1198

Create webhook

Capture Document ID from “completed” event

When your document changes status, you’ll get a postback from the webhook containing a status item:

{
  "data": {
    "id": "tKoqk92d2jiVuxUQH8i9iB",
  ... 
  }
  ...
  "status": "document.completed",
  ...	
}

When the status changes to document.completed, you can proceed to download your document.

🚧

It’s important to wait for the document status to change to completed rather than use the recipient_completed event because recipient_completed occurs multiple times for documents with multiple recipients.

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
where {id} is from the webhook.