Password protect a PDF
A rendered PDF is only as private as its bytes. One field on the same POST that renders the document encrypts the result with AES-256, so the file never exists unencrypted anywhere outside the render.
What password protection actually is
A PDF password is not a lock on a cloud copy. It is encryption inside the file: a user password is required to open the document at all, and an owner password governs what a reader is allowed to do once it is open (print, copy, edit). We write both into the file with qpdf using AES-256, the current PDF encryption standard.
That distinction matters when you are choosing what to send. A user password is the right control for a document going to one recipient over a channel you do not fully trust, including email. An owner password alone is a permissions marker, not a secret: readers that respect it will honour the restrictions, and a determined reader can strip them. Encrypt for confidentiality, not for DRM.
One call, one field
The field is encryption. It takes userPassword and, optionally, ownerPassword. Everything else in the request is the render you were already making.
curl -X POST https://webcapture.io/v1/convert \
-H "Authorization: Bearer wc_your_key" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/invoice/1042",
"encryption": {"userPassword": "open-sesame",
"ownerPassword": "keep-the-permissions"}}'
The response is the same receipt as any other render, with bytes and a download URL. The file behind that URL is encrypted. There is no second request and no intermediate unencrypted file to fetch.
Why it runs last, and what that rules out
Encryption is the final step of the post-process chain: blank-page removal, then the watermark stamp, then metadata, then encryption. Encrypting first would make the bytes opaque to everything after it, so the order is not a preference.
The consequence for the caller: anything you want baked into the document has to be in the same request. You cannot encrypt here and add a watermark later, because nothing can read the file back without the password.
- PDF output only. A PNG or a markdown extraction has no encryption layer, so the field is refused with a 422 rather than ignored.
userPassword1 to 255 characters;ownerPasswordthe same, optional.- A password may not begin with a dash. Passwords are values, and a leading dash would parse as a command-line flag in the encrypter.
- The deployment must carry
qpdf. Where it does not, the request answers 503 and says the feature is unavailable, rather than shipping an unencrypted file that looks protected.
Why not do it in the browser
Client-side tools can encrypt, but they cannot render. The browser equivalents of this workflow either upload your document to their server (the same trust question, answered by someone else) or rasterise it through a canvas, which loses selectable text and the print CSS you spent the day on. Doing both steps in one render removes the choice: the HTML is fetched and printed by Chromium server-side, and the bytes that leave are already encrypted.
If the document is a public page and confidentiality is not the issue, the free URL to PDF tool renders without a key. Password protection is a keyed parameter, documented in full at the API reference.
Frequently asked questions
Can I password protect a PDF without paying?
The free tools render documents without an account but do not expose encryption: the anonymous endpoint accepts a field allowlist, and encryption is not on it. The keyed API includes 50 free renders a month, and encryption is available on every render in that allowance.
Does the password get stored anywhere?
No. Passwords are parsed at admission, handed to the encrypter as an argument, and never written to the job record, the conversion row, the receipt or the audit log. They are not recoverable from us, so keep your own copy.
What happens if I lose the user password?
The document cannot be opened by us or by anyone else. Re-render it: the request is deterministic enough to reproduce, so keep the JSON body you sent and send it again with a new password.
Related
Render your first page in seconds
Mint a key, POST a URL, and the finished document comes back in the same response; pass ?wait=false for a job ticket with poll and download URLs. The first 50 renders a month are free, and there is no credit card. Not ready for a key? The free URL to PDF tool renders public pages without one.