---
updatedAt: 2026-04-15T15:59:51.000Z
agentTools:
  projectIndex: https://developers.pandadoc.com/llms.txt
---

# How to Download Completed Document

Get a protected PDF copy of document after they've been completed by all signers using webhook notifications.

## Problem

You need to automatically download protected PDF copies of document immediately after they've been completed by all signers, rather than manually checking document status or polling the API.

## Prerequisites

* Active PandaDoc API account with authentication ([OAuth](https://developers.pandadoc.com/reference/authentication-process) or [API key](https://developers.pandadoc.com/reference/api-key-authentication-process))
* Webhook endpoint configured to receive notifications (see [How to Set Up Webhook Notifications](../docs/webhook-setup))
* Basic understanding of webhook processing and PDF handling

<Callout icon="💡" theme="default">
  ### **Quick Check Alternative**: For simple use cases or testing, you can download completed documents without webhooks by periodically checking document status using the [Get Document Status](https://developers.pandadoc.com/reference/document-status) and downloading when `status` is `document.completed`.
</Callout>

## Solution

### Step 1: Configure Webhook for PDF Ready Event

Set up a webhook subscription to receive `document_completed_pdf_ready` events:

1. **Using Developer Dashboard**:

   * Navigate to [API Configuration](https://app.pandadoc.com/a/#/api-dashboard/configuration)
   * Click "Create webhook" in the Webhooks section
   * Add your webhook endpoint URL
   * Check "PDF of completed document available for download" under "Subscribe to events"
   * Save the configuration

2. **Using API**:
   ```bash
   curl -X POST "https://api.pandadoc.com/public/v1/webhook-subscriptions" \
     -H "Authorization: Bearer YOUR_API_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "name": "PDF Download Webhook",
       "url": "https://your-domain.com/webhook-handler",
       "triggers": ["document_completed_pdf_ready"],
       "active": true
     }'
   ```

### Step 2: Handle the Webhook Event

Process the incoming webhook to extract the document ID:

```json
[
  {
    "event": "document_completed_pdf_ready",
    "data": {
      "id": "tKoqk92d2jiVuxUQH8i9iB",
      "name": "Contract Agreement",
      "status": "document.completed",
      ...
    }
  }
]
```

Extract the document `id` from the `data` object for use in the download request.

### Step 3: Choose Download Method

Select the appropriate endpoint based on your needs:

* **Protected PDF** (recommended): `/download-protected` - Returns digitally sealed PDF
* **Regular PDF**: `/download` - Supports watermarks and customization options

### Step 4: Download the PDF

Use the document ID to download the PDF with your chosen method:

**For Protected PDF (recommended):**

```bash
curl -X GET "https://api.pandadoc.com/public/v1/documents/{document_id}/download-protected" \
  -H "Authorization: API-Key YOUR_API_TOKEN" \
  -o "completed-document.pdf"
```

**For Regular PDF:**

```bash
curl -X GET "https://api.pandadoc.com/public/v1/documents/{document_id}/download" \
  -H "Authorization: API-Key YOUR_API_TOKEN" \
  -o "completed-document.pdf"
```

Replace `{document_id}` with the document ID from the webhook payload.

<Callout icon="📝" theme="default">
  ### **Note**: The `/download-protected` endpoint always returns the same digitally sealed PDF file, while `/download` allows for watermark customization.
</Callout>

## Verification

To confirm your setup is working:

1. **Test webhook delivery**: Create a test document and complete it to trigger the webhook
2. **Check webhook history**: Monitor delivery status in the [Webhooks History tab](https://app.pandadoc.com/a/#/settings/api-dashboard/webhooks)
3. **Verify PDF download**: Confirm your application successfully downloads and processes the PDF file
4. **Test file integrity**: Ensure the downloaded PDF opens correctly and contains expected content

## Troubleshooting

Common issues and solutions:

**Webhook not received**:

* Verify webhook subscription is active and configured for `document_completed_pdf_ready`
* Check endpoint accessibility
* See [How to Debug and Monitor Webhooks](../docs/webhook-debugging) for detailed troubleshooting

**PDF download fails**:

* Confirm document ID is correctly extracted from webhook payload
* Verify API authentication is valid
* Check that document is actually completed (status: "document.completed")

**File corruption or access issues**:

* Ensure proper binary handling when saving PDF files
* Verify sufficient disk space and write permissions
* Check network connectivity for complete file transfer

## Related

* [How to Set Up Webhook Notifications](../docs/webhook-setup) - Configure webhook subscriptions
* [How to Debug and Monitor Webhooks](../docs/webhook-debugging) - Troubleshooting and monitoring
* [Webhook Events Reference](../docs/webhook-events) - Complete event specifications
* [Download Protected Document API](https://developers.pandadoc.com/reference/download-protected-document) - API reference
* [Download Document API](https://developers.pandadoc.com/reference/download-document) - Alternative download method