# Password-Protect Generated PDFs


You can generate password-protected PDFs by passing a `_password` key in the document's **metadata**. The generated file is encrypted with AES-256 and requires the password to open. If you omit `_password`, documents generate without encryption as usual.

## Setting the password via the API

Include the `_password` key inside the `meta` object when you [create](../api/documents.md#create-a-document) a document:

```bash
curl https://api.pdfmonkey.io/api/v1/documents \
  -X POST \
  -H 'Authorization: Bearer YOUR_SECRET_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "document": {
      "document_template_id": "YOUR_TEMPLATE_ID",
      "status": "pending",
      "payload": { "name": "Jane Doe" },
      "meta": {
        "_password": "s3cur3-p@ss!"
      }
    }
  }'
```

You can combine `_password` with other meta keys like [`_filename`](./custom-filename.md):

```json
{
  "meta": {
    "_filename": "contract-jane-doe.pdf",
    "_password": "s3cur3-p@ss!"
  }
}
```

## Setting the password from the Dashboard

1. Open a document in the Document Editor.
2. Switch to the **Meta data** tab.
3. Enter the `_password` key and your desired password:

```json
{
  "_password": "s3cur3-p@ss!"
}
```

4. Click **Save**, then **Generate**.

For a full walkthrough, see [Generate Documents from the Dashboard](./using-the-dashboard.md).

## How it works

When `_password` is present in the meta, PDFMonkey encrypts the generated PDF with **AES-256** after rendering. The recipient needs the exact password to open the document. Without it, the content stays locked.

- **Any template works.** Code editor, Builder, existing templates -- password protection works with all of them.
- **No configuration needed.** You don't need to enable anything on the template or your account.
- **Works with all integrations.** Zapier, Make, Workato, n8n, Bubble, Glide, direct API -- anywhere you can set the `meta` field.
- **Per-document control.** One document can be password-protected while the next one isn't.
- **Available on all plans.** Free plan included.

## Frequently asked questions

**What happens if I don't set a password?**

Documents generate without encryption, exactly as before. Password protection is opt-in.

**Can I use dynamic data in the password?**

Not directly inside the `_password` value. However, in most integration platforms (Zapier, Make, n8n) you can use dynamic fields or expressions to build the password string before passing it to PDFMonkey.

**Does password protection work with image output formats?**

No. Password protection only applies to PDF output. Image formats (PNG, WebP, JPG) do not support encryption.

## Related pages

- [Custom Filename](./custom-filename.md) -- another meta key that controls generation behavior
- [API Documents reference](../api/documents.md) -- full parameter documentation for `meta` and other fields
- [Generate PDFs with the API](./api-pdf-generation.md) -- end-to-end generation workflow
- [Generate Documents from the Dashboard](./using-the-dashboard.md) -- using the Meta data tab


## FAQ

**How do I password protect a PDF with PDFMonkey?**

Pass a "_password" key in the document's meta field. Via the API, include it in the meta object when creating a document: "meta": { "_password": "your-password" }. The generated PDF will be encrypted with AES-256 and require the password to open.

**What encryption does PDFMonkey use for password-protected PDFs?**

PDFMonkey uses AES-256 encryption. The PDF is encrypted after generation, and the recipient needs the exact password you specified to open the document.

**Can I generate PDFs without a password?**

Yes. If you don't include the _password field in your meta, PDFs generate exactly as before: no encryption, no password. Password protection is entirely opt-in, per document.
