Skip to main content
All posts
protect unlock PDF API security

How to Password Protect a PDF, and Unlock One Again

Add a password to a PDF, stop it being printed or copied, and remove the password from a file you hold the password for. In the dashboard or with one API call.

PodPDF Team October 13, 2026 7 min read

A payslip goes out by email. A board pack is shared with people who should read it but not pass it on. A price list should not be copied into a competitor’s spreadsheet. Each of these is the same job: the PDF needs a password before it leaves.

Then there is the reverse. The bank statement arrives locked, the supplier’s invoice will not merge into the month-end pack, and the scan from head office cannot be split because somebody protected it three systems ago.

PodPDF now does both, in the dashboard and through the API: Protect adds a password to a PDF, and Unlock removes it for someone who has the password.

Two Passwords, Two Jobs

A PDF can carry two passwords, and they do different things.

What it doesWho needs it
Password to openThe PDF cannot be read without itEveryone who should read the document
Owner passwordChanges or removes the protectionOnly you

That gives three ways to protect a file:

  • A password to open, and nothing else. The usual choice for a payslip or a statement. Anyone with the password can read, print and copy it.
  • A password to open, plus restrictions. Readers need the password, and even then cannot print or copy. The owner password is what lifts the restrictions, so it has to be a different one.
  • Restrictions only. The PDF opens for anyone, but printing, copying or editing is switched off. Handbooks and price lists are often shared this way.

Files are encrypted with AES-256, which every current PDF reader, browser and phone opens.

Protect a PDF in the Dashboard

Open PDF Tools → Protect and add your PDF. It is checked straight away, and a file that is already protected is flagged before you type anything.

  1. Enter a password to open, or leave it empty if you only want restrictions.
  2. Turn on Restrict what readers can do to switch off printing, copying, editing, commenting, form filling or page changes, and give it an owner password.
  3. Click Protect PDF and download the result.

PodPDF uses the password to write the file and then forgets it. It is never stored or logged, which also means it cannot be recovered: keep it somewhere safe, along with the original file.

Protect a PDF with the API

One call, with the file and the password:

curl -X POST https://api.podpdf.com/pdf/protect \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@payslip.pdf" \
  -F "user_password=correct-horse-battery" \
  -o payslip-protected.pdf

To restrict what readers can do, add an owner password and the permissions to change. Everything you leave out stays allowed:

curl -X POST https://api.podpdf.com/pdf/protect \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@board-pack.pdf" \
  -F "user_password=correct-horse-battery" \
  -F "owner_password=a-different-one" \
  -F 'permissions={"print": "none", "copy": false}' \
  -o board-pack-protected.pdf
PermissionValuesWhat it controls
printfull, low, nonePrinting; low allows a rough copy only
copytrue, falseCopying text and images
modifytrue, falseEditing the document
annotatetrue, falseComments and annotations
fill_formstrue, falseFilling in form fields
assembletrue, falseInserting, deleting and rotating pages

Screen readers can always read the text, whatever else is restricted.

In a Pipeline

If your system already generates the document, protecting it is one more step before it is sent:

async function protectPdf(pdf, password) {
  const form = new FormData();
  form.append('file', new Blob([pdf], { type: 'application/pdf' }), 'payslip.pdf');
  form.append('user_password', password);

  const response = await fetch('https://api.podpdf.com/pdf/protect', {
    method: 'POST',
    headers: { 'X-API-Key': process.env.PODPDF_API_KEY },
    body: form,
  });
  if (!response.ok) throw new Error(JSON.stringify(await response.json()));
  return Buffer.from(await response.arrayBuffer());
}

What Restrictions Really Do

A password to open is enforced by mathematics: without it, the content cannot be decrypted. Restrictions are enforced by the PDF reader. Acrobat, Preview and the browsers respect them, and a reader that chooses not to can ignore them.

So restrictions are the right tool for “please do not print this”, and the wrong one for anything confidential. If it matters who reads the document, set a password to open.

The strength of that password is yours to choose. A four-word passphrase is far harder to guess than a date of birth, and a payslip protected with the employee’s birthday is protected from very little.

Unlock a PDF

Open PDF Tools → Unlock, add the protected PDF and enter its password. The copy you get back has no password and no restrictions.

With the API:

curl -X POST https://api.podpdf.com/pdf/unlock \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@statement.pdf" \
  -F "password=correct-horse-battery" \
  -o statement-unlocked.pdf

Unlocking always needs the password. Which one depends on the file:

  • A PDF that needs a password to open is unlocked by that password, or by its owner password.
  • A PDF that opens without a password but will not print or copy is protected by an owner password only. Removing those restrictions takes that owner password.

PodPDF removes protection for the person who holds the password. It does not guess, break or skip one. A wrong password is refused with PDF_PASSWORD_INCORRECT and costs nothing.

It reads old protection as well as new: the 40-bit locks that scanners and accounting packages wrote years ago are unlocked the same way as AES-256.

Why Merge and Split Refuse Your File

Merge, split and the editor refuse a protected PDF with PDF_ENCRYPTED. That is deliberate: copying the pages of an encrypted file without decrypting them produces pages that look blank, and nobody notices until a customer does.

Unlock is the way through. A month-end pack built from files that arrive locked becomes:

  1. POST /pdf/unlock for each protected file, with its password
  2. POST /pdf/merge with the unlocked copies
  3. POST /pdf/protect on the result, if it is going out again

Protect comes last for the same reason: once a file is protected, it has to be unlocked before anything else can be done to it.

Large PDFs

In the dashboard, add files up to 150 MB and 5000 pages. Through the API, a file up to 4 MB goes in the request, as above. A larger one is uploaded first:

  1. POST /pdf/upload-url with content_length_bytes — you get an upload_url and an s3_key
  2. PUT the file to upload_url with Content-Type: application/pdf
  3. POST /pdf/protect or /pdf/unlock with {"source_key": "<the s3_key>", ...} and the passwords

There is no queue and no job to poll. A scan of well over a hundred megabytes is protected in a few seconds, and the response carries a download_url for the result.

What Is Worth Knowing

  • Your document is not changed. Pages, form fields, bookmarks and links stay as they were. Only the protection is added or removed.
  • Digital signatures stop validating, because the file is rewritten. The response carries the warning SIGNATURE_INVALIDATED when that applies.
  • A protected PDF cannot be protected again. Unlock it with the current password, then protect it with the new one.
  • Certificate protection is different. A PDF encrypted for a digital certificate, rather than with a password, cannot be unlocked with one.

Common Errors

CodeWhat to do
PDF_ENCRYPTEDThe file is already protected. Unlock it first
PDF_PASSWORD_INCORRECTCheck the password. A PDF that opens without one needs its owner password
PDF_NOT_ENCRYPTEDThe file has no protection; use it as it is
INVALID_PARAMETERdetails.parameter names the field, such as restrictions without an owner password

Pricing

Protect and unlock are each billed once per file, at the same price as a merge or a split, based on the number of pages. A wrong password is not charged. See pricing.

Get Started

protect unlock PDF API security
Back to blog

PodPDF is built by XAD Labs, which builds custom PDF processing pipelines at scale.

Start generating PDFs today

$0.005 per PDF on a monthly plan, or $0.01 from one-off credit packs.