Protect PDF
Add password protection and encryption to PDF documents.
https://api.morphopdf.com/v1/pdf/protectAuthentication
Retrieve your API Key from Dashboard.
Request Body
Provide the PDF file and protection settings.
fileFilePDF file uploaded via multipart/form-data.
urlstringOptionalPublic URL pointing to a PDF file. Alternative to file upload.
userPasswordstringPassword required to open the PDF. Users must enter this password to view the document.
ownerPasswordstringOptionalPassword for owner permissions. If not provided, defaults to userPassword. Required to change permissions or remove protection.
permissionsobjectOptionalObject specifying document permissions. All permissions default to true if not specified.
encryptionLevelstringOptionalDefault: 256-bitEncryption strength: '128-bit' (AES-128) or '256-bit' (AES-256, recommended).
Permissions Object
Configure what users can do with the protected PDF.
modifyingbooleanOptionalDefault: trueAllow modifying document content.
copyingbooleanOptionalDefault: trueAllow copying text and graphics.
annotatingbooleanOptionalDefault: trueAllow adding annotations and comments.
fillingFormsbooleanOptionalDefault: trueAllow filling in form fields.
contentAccessibilitybooleanOptionalDefault: trueAllow content extraction for accessibility purposes.
documentAssemblybooleanOptionalDefault: trueAllow inserting, rotating, or deleting pages.
Query Parameters
formatstringOptionalDefault: jsonResponse format. Use 'binary' to receive the protected PDF directly, or 'json' (default) to receive metadata with a download URL.
Printing Permission
Printing is always enabled at high resolution and cannot be disabled through this API.
Response
When using format=json (default):
successbooleanIndicates whether the operation completed successfully.
messagestringHuman-readable status message.
fileNamestringName of the protected PDF document.
downloadUrlstringPresigned URL to download the file. Valid for 1 hour.
pageCountnumberNumber of pages in the PDF.
encryptedbooleanConfirms the document is encrypted. Always true.
Binary Response
Add ?format=binary to receive the protected PDF directly with these headers:
Content-Type: application/pdfContent-Disposition: attachment; filename="protected.pdf"
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_INPUT | No file provided or invalid file format |
| 400 | MISSING_REQUIRED_FIELD | userPassword is required |
| 401 | AUTHENTICATION_REQUIRED | Missing or invalid API key |
| 413 | FILE_TOO_LARGE | File exceeds maximum size limit |
| 500 | PROCESSING_FAILED | Internal processing error |
/v1/pdf/protectcurl -X POST "https://api.morphopdf.com/v1/pdf/protect?format=binary" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "userPassword=secret123" \
-F "ownerPassword=admin456" \
--output protected.pdf{
"success": true,
"message": "File processed successfully",
"fileName": "protected.pdf",
"downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/protected.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
"pageCount": 5,
"encrypted": true
}