Password-protect PDFs by API with AES-256
Encrypt a PDF with AES-256 and a password in one API call. Open and owner passwords, what happens to the password, and how to deliver it to the recipient safely.
Payslips, medical letters, bank statements and contracts often go out as password-protected PDFs. The PDF Protect API encrypts a PDF with AES-256, the strongest encryption the PDF format supports, in one call.
curl https://api.justapi.tech/v1/pdf/protect \
-H "Authorization: Bearer ak_live_..." \
-H "Content-Type: application/json" \
-d '{"source": {"url": "https://files.example.com/payslip-2026-11.pdf"}, "options": {"password": "a-long-unique-password"}}'
Open and owner passwords
A PDF can have two passwords:
- The open password (
password) is needed to open the file at all. - The owner password (
owner_password) is needed to change its permissions. If you do not send one, it is the same as the open password.
With only an open password, anyone who can open the file can also print and copy it, unless you turn that off. See what blocking print and copy really does.
What happens to the password
The password travels to the API once, over HTTPS, inside the request. It is used in memory to encrypt the file. It is not written to the database, the logs or the job record; the job only notes that a password was set. The encrypted result is stored for up to 24 hours, like every result, or until you acknowledge the download.
Choosing the password
Use a different password per document or per person. A shared password for every payslip means one leak opens all of them. Common patterns:
- A random password per file, sent separately (SMS, or a portal the person logs into).
- A value only the recipient knows, like their date of birth plus employee number. Easy to remember, but guessable by colleagues; fine for low-risk documents only.
Never put the password in the same email as the PDF.
AES-256 and old readers
AES-256 is supported by Acrobat since version 9 and by every current browser, Preview and mobile viewer. Very old readers from before 2008 cannot open it. That is the right trade today.
Errors and cost
A signed PDF is refused with signed_pdf: encrypting it would invalidate the signature. An already encrypted PDF is refused with encrypted_pdf; unlock it first. A missing password is an invalid_request. None are charged. A successful call costs $0.005 at the first tier.
Try it with the free PDF password tool, and see the PDF Protect API reference for every option.