PDF Protect
Encrypt a PDF with password protection or decrypt a protected PDF
/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
{
"pdf": "JVBERi0xLjcKMSAwIG9iago8...",
"action": "encrypt",
"is_encrypted": true,
"page_count": 12,
"file_size": 345200
}
Description
How to Use
1. Provide the PDF via `pdf` (base64) or `url` (public URL).
2. Set `action` to `"encrypt"` or `"decrypt"`.
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. 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
- Document security — Password-protect sensitive PDFs before emailing or sharing
- Print restriction — Allow viewing but prevent printing of confidential documents
- Copy prevention — Block text copying from proprietary reports
- Batch decryption — Unlock protected PDFs in bulk for processing or migration
- Compliance — Enforce encryption on documents containing personal or financial data
Frequently Asked Questions
What's the difference between user and owner passwords?
Can I encrypt without restricting anything?
What encryption algorithm is used?
Start using PDF Protect now
Get your free API key and make your first request in under a minute.