Protect PDF

Add password protection and encryption to PDF documents.

POSThttps://api.morphopdf.com/v1/pdf/protect

Authentication

AuthorizationBearer

Retrieve your API Key from Dashboard.

Request Body

Provide the PDF file and protection settings.

fileFile

PDF file uploaded via multipart/form-data.

urlstringOptional

Public URL pointing to a PDF file. Alternative to file upload.

userPasswordstring

Password required to open the PDF. Users must enter this password to view the document.

ownerPasswordstringOptional

Password for owner permissions. If not provided, defaults to userPassword. Required to change permissions or remove protection.

permissionsobjectOptional

Object specifying document permissions. All permissions default to true if not specified.

encryptionLevelstringOptionalDefault: 256-bit

Encryption strength: '128-bit' (AES-128) or '256-bit' (AES-256, recommended).

Permissions Object

Configure what users can do with the protected PDF.

modifyingbooleanOptionalDefault: true

Allow modifying document content.

copyingbooleanOptionalDefault: true

Allow copying text and graphics.

annotatingbooleanOptionalDefault: true

Allow adding annotations and comments.

fillingFormsbooleanOptionalDefault: true

Allow filling in form fields.

contentAccessibilitybooleanOptionalDefault: true

Allow content extraction for accessibility purposes.

documentAssemblybooleanOptionalDefault: true

Allow inserting, rotating, or deleting pages.

Query Parameters

formatstringOptionalDefault: json

Response 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):

successboolean

Indicates whether the operation completed successfully.

messagestring

Human-readable status message.

fileNamestring

Name of the protected PDF document.

downloadUrlstring

Presigned URL to download the file. Valid for 1 hour.

pageCountnumber

Number of pages in the PDF.

encryptedboolean

Confirms the document is encrypted. Always true.

Binary Response

Add ?format=binary to receive the protected PDF directly with these headers:

  • Content-Type: application/pdf
  • Content-Disposition: attachment; filename="protected.pdf"

Error Responses

StatusCodeDescription
400INVALID_INPUTNo file provided or invalid file format
400MISSING_REQUIRED_FIELDuserPassword is required
401AUTHENTICATION_REQUIREDMissing or invalid API key
413FILE_TOO_LARGEFile exceeds maximum size limit
500PROCESSING_FAILEDInternal processing error
POST/v1/pdf/protect
curl -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
200OK
{
  "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
}