Protect Document
Security → Protect Document
The Protect Document API adds password protection and permissions to a PDF. You send the PDF as Base64 (docContent), docName, password, pdfPermission (e.g. All), and optionally async. The API returns a password-protected PDF with the specified permissions. Use the tester below to try it; more details are in the sections that follow.
Try the Protect Document API
Endpoint: POST /api/v2/Protect · Required: api-key, docContent, docName, password, pdfPermission
Use the form below to send your API key, PDF (Base64), password, and permissions. The response is the password-protected PDF. No code required—fill the fields and click Send request.
Overview, parameters, and use cases
- Overview
- Parameters
- Use cases
What is Protect Document?
This endpoint protects a PDF with a password and sets document permissions. You provide the PDF (Base64), docName, password (user/owner password), and pdfPermission (e.g. All). The API returns a PDF that requires the password to open and enforces the chosen permissions (e.g. printing, copying). Use it to restrict access or editing.
Key features
- Password protection – password is required to open the PDF; content is encrypted.
- Permissions – pdfPermission controls what users can do (e.g. All or restricted).
- Async – Use async for large PDFs.
- Single request – Send docContent (Base64), docName, password, pdfPermission; no extra steps.
Use when you need to restrict who can open or edit a PDF. To remove protection use Unlock PDF with the correct password.
API parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api-key | string | Yes | Your PDF4me API key, Base64 encoded. Get it from the dashboard. |
| docContent | base64 | Yes | PDF file content (Base64). |
| docName | string | Yes | Output PDF file name (e.g. output.pdf). |
| password | string | Yes | Password for the protected PDF. |
| pdfPermission | string | Yes | PDF permissions (e.g. All). |
| async | boolean | No | Enable asynchronous processing. |
When to use Protect Document
- Confidential documents – Add a password so only authorized users can open the PDF.
- Restrict editing – Set permissions to prevent printing, copying, or editing.
- Distribution – Protect sensitive PDFs before sharing or emailing.
- Compliance – Enforce access control for regulated documents.
For request/response schemas and code samples, see Protect Document in the PDF4me API docs.
Prerequisites
Before using this endpoint, make sure you have:
- A valid PDF4me API key (Get your API Key)
- A PDF file in Base64 format
Response Format
The API returns a password-protected PDF file with the specified permissions applied.