🛠️

PDF Protect

Encrypt a PDF with password protection or decrypt a protected PDF

POST 10 credits /v1/pdf/protect
curl -X POST "https://pdf.toolkitapi.io/v1/pdf/protect" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://toolkitapi.io/sensitive-report.pdf",
    "action": "encrypt",
    "user_password": "viewonly123",
    "owner_password": "admin456",
    "allow_printing": true,
    "allow_copying": false
  }'
import httpx

resp = httpx.post(
    "https://pdf.toolkitapi.io/v1/pdf/protect",
    json={
    "url": "https://toolkitapi.io/sensitive-report.pdf",
    "action": "encrypt",
    "user_password": "viewonly123",
    "owner_password": "admin456",
    "allow_printing": true,
    "allow_copying": false
  },
)
print(resp.json())
const resp = await fetch("https://pdf.toolkitapi.io/v1/pdf/protect", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "url": "https://toolkitapi.io/sensitive-report.pdf",
    "action": "encrypt",
    "user_password": "viewonly123",
    "owner_password": "admin456",
    "allow_printing": true,
    "allow_copying": false
  }),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "pdf": "JVBERi0xLjcKMSAwIG9iago8...",
  "action": "encrypt",
  "is_encrypted": true,
  "page_count": 12,
  "file_size": 345200
}

Description

Encrypt a PDF with password protection or decrypt a protected PDF

How to Use

1

1. Provide the PDF via `pdf` (base64) or `url` (public URL).

2

2. Set `action` to `"encrypt"` or `"decrypt"`.

3

3. For encryption: provide at least one of `user_password` or `owner_password`. Optionally set `allow_printing` and `allow_copying` (both default to `true`).

4

4. For decryption: provide the `owner_password` or `user_password` of the encrypted PDF.

About This Tool

PDF Protect lets you add or remove password protection on PDF documents. In encrypt mode, it secures a PDF with user and/or owner passwords and configures permissions (printing, copying). In decrypt mode, it removes encryption from a protected PDF when you provide the correct password.

The user password is required to open the document. The owner password grants full access and controls permission settings. You can set both, or just one — if only a user password is provided, it's also used as the owner password.

Use this to secure sensitive documents before distribution, enforce copy/print restrictions, or unlock protected PDFs for processing in your pipeline.

Why Use This Tool

Frequently Asked Questions

What's the difference between user and owner passwords?
The user password is required to open and view the document. The owner password grants full access and controls permission settings. Many PDF viewers enforce permissions only when the owner password is set differently from the user password.
Can I encrypt without restricting anything?
Yes. Set both `allow_printing` and `allow_copying` to `true` (the defaults). The document will require a password to open but won't restrict what the viewer can do once opened.
What encryption algorithm is used?
The endpoint uses the standard PDF encryption supported by pypdf, which implements AES-128 or RC4 encryption depending on the PDF version. This is compatible with all major PDF viewers.

Start using PDF Protect now

Get your free API key and make your first request in under a minute.