Protect PDF
POST https://api.getdocuforge.dev/v1/pdf/protect
Add password protection and permission controls to a PDF document.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
pdf | string | Yes | Base64-encoded PDF document |
owner_password | string | Yes | Owner password (grants full access) |
user_password | string | No | User password (required to open the document) |
permissions | object | No | Permission flags (see below) |
output | string | No | "url" (default) or "base64" |
Permissions
| Parameter | Type | Default | Description |
|---|---|---|---|
printing | boolean | true | Allow printing the document |
copying | boolean | false | Allow copying text and images |
modifying | boolean | false | Allow modifying the document |
Example
Response (URL mode)
Response (base64 mode)
Errors
| Status | Code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Missing owner password or PDF exceeds size limit |
| 401 | UNAUTHORIZED | Invalid or missing API key |
| 429 | RATE_LIMITED | Too many requests |
| 500 | INTERNAL_ERROR | Server error during protection |

