LogoDOCS
OverviewAuthenticationRate LimitsErrors
Logo
Sign in →

Protect PDF

The Protect PDF endpoint secures a PDF document by applying password protection and permission restrictions.

You can encrypt the PDF using AES-128 or AES-256, set user and owner passwords, and control which actions are allowed, such as printing, copying, or editing.

Request Body
filefilerequired if documentId is not provided

File type: .pdf

The PDF file to be processed. Used when uploading a new file directly.

documentIdstringrequired if uploaded file is not provided

The ID of an already uploaded file stored on our server.

algorithmstring

Default: AES256

Acceptable values:
AES256AES128

Specifies the encryption algorithm. AES256 offers the highest security, while AES128 ensures better compatibility with older PDF readers.

userPasswordstring

Password required to open the PDF. If not provided, the document will be accessible without a password unless restrictions depend on the owner password.

ownerPasswordstring

Password that grants full control over the PDF, including the ability to change permissions or remove restrictions. Must not be empty if AES256 is used and a userPassword is defined.

disablePrintboolean

When true, prevents the PDF from being printed.

disableCopyboolean

When true, disables copying or text/image extraction from the document.

disableEditingboolean

When true, prevents modifications to the document (e.g., form editing or annotation changes).

encryptMetadataboolean

Default: false

Determines whether the document metadata (title, author, keywords, etc.) should be encrypted. If set to false, metadata remains visible without decryption.

jsonResponseboolean

Default: false

Returns JSON response instead of file stream.

preSignedUrlExpiresInnumber

Minimum: 60 seconds

Maximum: 86400 seconds (24 hours)

Use this to control temporary authorized access to files. After this duration, the URL automatically expires and can no longer be used to download the PDF. The value must be provided in seconds.

If you need to generate a new pre-signed URL for an existing document, use the Get Document endpoint.

metadataobject

Sets custom data to your document record.

POST/protect/pdf
CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
1curl -X POST "https://api.pdfgate.com/protect/pdf" \2  -H "Authorization: Bearer YOUR_API_KEY" \3  -F "file=@YOUR_FILE.pdf" \4  -F "ownerPassword=ownerPassword" \5  -F "userPassword=userPassword" \6  -F "disablePrint=true" \7  -F "disableCopy=true" \8  -F "disableEditing=true" \9  --output protected.pdf
File stream response
1File stream
JSON response - Document object
1{2  "id" : "6642381c5c61",3  "status" : "completed",4  "fileUrl" : "https://api.pdfgate.com/file/open/:preSignedUrlToken",5  "size" : 1620006,6  "type" : "encrypted",7  "derivedFrom" : "68f920bacfe16de217f019as",8  "createdAt" : "2024-02-13T15:56:12.607Z"9}