API Freaks logoAPI Freaks logo
CTRL+K

    APIs

  • Pricing
  • Resources
  • Tools

  • Contact us
CTRL+K
Sign InGet Started For Free
  • Overview
  • Documentation
  • How to Guides
  • Pricing
  • APIFreaks
  • Organization and Teams
  • Credits Usage API
  • IP Geolocation Lookup
  • Bulk IP Geolocation Lookup
  • Domain WHOIS Lookup
  • IP WHOIS Lookup
  • ASN Lookup
  • Domain WHOIS Historical Lookup
  • Domain WHOIS Reverse Lookup
  • Bulk Domain WHOIS Lookup
  • DNS Lookup
  • Historical DNS Lookup
  • Reverse DNS Lookup
  • Bulk DNS Lookup
  • Email Checker API
  • SSL Certificate Lookup
  • Domain Availability
  • Bulk Domain Availability API
  • Website Screenshot
  • Bulk Screenshot
  • PDF Merge
  • PDF Delete Pages
  • PDF Split & Extract Pages
  • PDF Rotate
  • PDF Compress
  • PDF Linearize
  • PDF Protect
  • PDF Unlock
  • PDF to Image
  • Currencies Exchange Rates
  • Currency Converter
  • Currency Time Series
  • Currency Fluctuation
  • Geolocalized Currency Converter
  • Live Commodity Prices
  • Commodity Historical Prices
  • Commodity Fluctuation
  • Commodity Time Series
  • IBAN Validation
  • SWIFT/BIC Code Lookup & Finder
  • ZIP Code API
  • ZIP Code Search Inside Radius
  • ZIP Code Distance API
  • ZIP Code Search By City
  • Live Weather API
  • Weather Forecast API
  • Historical Weather API
  • Air Quality API
  • Marine Weather API
  • Flood Forecast API
  • Timezone Lookup
  • Timezone Converter
  • User Agent Parser
  • Bulk User Agent Parser
  • Astronomy API

PDF Protect API - Secure Documents with Password & Restrictions

Our Protect PDF API offers enterprise-grade security tools to lock down sensitive information and control how users interact with your documents. Lock PDF files with user and owner passwords using industry standard AES-256 encryption and apply granular restrictions like copying, printing, or making changes. Whether you're protecting confidential reports, securing client contracts, or preventing unauthorized document modifications, our API handles it all through simple REST endpoints.

Built for compliance systems, document management platforms, confidential report generators, and enterprise content security solutions. Password protect sensitive financial documents, prevent copying from legal contracts, restrict printing for internal memos, secure client proposals with editing restrictions, or apply comprehensive protection to intellectual property documents. Control exactly what users can and cannot do with your PDFs while maintaining complete security over your content. With asynchronous request processing and webhook support, you can seamlessly integrate PDF Protection APIs into your automation pipelines.

10K Free Credits, No Credit Card Required

Features

Asynchronous Processing

Upon successful request, our API immediately returns a 200 OK response with a unique Task ID, processing your file in the background. You can track the task progress via our Task Status API using the unique Task ID.

Webhook Notifications

If you don't want to poll for task status, you can simply provide the webhook data in your request. Instead of manually checking status, we will automatically notify your endpoint the moment the task processing is completed.

Zero Data Retention

Your privacy matters. When you set the destroy parameter, your files are permanently wiped from our servers immediately after processing finishes, ensuring complete data security. If destroy is not set, files are retained up to 30 days based on user's plan.

AES-256 Encryption

We don't compromise on security. All PDFs uses industry standard 256-bit AES encryption, providing enterprise-grade security for your PDF files making them virtually impossible to crack without the correct credentials. Your documents are protected with the same encryption standards used by financial institutions and government agencies worldwide.

Dual Password System

Implement flexible security policies with distinct "User" and "Owner" passwords. User passwords restrict document opening, while owner passwords control who can modify security settings and restrictions. You get full flexibility to implement your security requirements.

Granular Permission Control

Apply specific restrictions to prevent copying, printing, editing, form filling and annotation modifications. Control exactly what users can do with your PDFs through distinct restriction types, from blocking high-quality printing to preventing content extraction. This allows you to share documents for viewing while protecting your intellectual property.

Prevent Copying from PDF

Stop unauthorized text and image extraction with content copying restrictions. Perfect for protecting intellectual property, confidential information, and proprietary content from being copied or redistributed without permission.

Large File Support

Handle heavy documents and high-resolution assets with ease. Our API supports a massive 1GB payload size per request, allowing you to process even the largest PDF files without worrying about size restrictions.

Documentation

Encrypt PDF API

API Endpoint

POST

https://api.apifreaks.com/v1.0/pdf/encrypt

Test
LANGUAGE
Python
PHP
Java
Node
Ruby
JavaScript
C#
$ pip install requests

API Request

File Upload

File uploads must use multipart/form-data format. PDF API accepts a single file upload.

ParameterRequiredTypeDefaultDescription
fileNomultipart/form-data-The PDF file to process. Only used if you're uploading a file instead of using file_id.

Input Priority Rule:

If both file and file_id are provided, the multipart file upload takes priority and file_id is ignored.

Query parameters

All parameters must be included as query parameters. Any parameters sent in the form data will be ignored.

ParameterRequiredTypeDefaultDescription
user_passwordYesString-Set user password for the PDF file. Password must be between 6 and 128 characters.
owner_passwordNoString-Set owner password for the PDF file. If not provided, user password will also be used as owner password. Password must be between 6 and 128 characters.
file_passwordNoString-Password to unlock the input file if it's protected. Either the owner or user password can be provided. The owner password takes precedence.
file_idNoString-The unique ID of a file already present on our server. Use this instead of uploading the file again.
outputNoStringencrypted_outputName of the output PDF (without extension).
destroyNoBooleanfalseIf true, we delete the input file immediately after generating the output.

Restrict PDF API

API Endpoint

POST

https://api.apifreaks.com/v1.0/pdf/restrict

Test
LANGUAGE
Python
PHP
Java
Node
Ruby
JavaScript
C#
$ pip install requests

API Request

File Upload

File uploads must use multipart/form-data format. PDF API accepts a single file upload.

ParameterRequiredTypeDefaultDescription
fileNomultipart/form-data-The PDF file to process. Only used if you're uploading a file instead of using file_id.

Input Priority Rule:

If both file and file_id are provided, the multipart file upload takes priority and file_id is ignored.

Query parameters

All parameters must be included as query parameters. Any parameters sent in the form data will be ignored.

ParameterRequiredTypeDefaultDescription
restrictionsYesArray-A list of restrictions to apply. These define what the end user is not allowed to do with the PDF. See available restrictions below table.
user_passwordYesString-Sets the password users will use to open the PDF. Password must be between 6 and 128 characters. If not set, only owner password will be set and anyone can open the PDF with the provided restrictions enabled.
owner_passwordNoString-Sets the password that allows full access (e.g., removing restrictions). If not provided, user_password (if set) is used as the owner password. Password must be between 6 and 128 characters.
file_passwordNoString-Password to unlock the input file if it is already secured. Provide the owner password if available, otherwise the user password. Owner password takes precedence.
file_idNoString-The unique ID of a file already present on our server. Use this instead of uploading the file again.
outputNoStringrestricted_outputName of the output PDF (without extension).
destroyNoBooleanfalseIf true, we delete the input file immediately after generating the output.

Available Restrictions

RestrictionDescription
print_high
Disables high-quality printing.
print_low
Disables low-resolution printing.
edit_document_assembly
Prevents reordering or inserting pages.
fill_form_fields
Disallows filling in PDF form fields.
edit_annotations
Disables adding or modifying annotations or comments.
modify_content
Prevents modifying existing content in the PDF.
copy_and_extract_content
Disables copying text or images from the PDF.
use_accessibility
Prevents screen readers or accessibility tools from accessing content.

Webhook Support

Webhook Parameters

ParameterRequiredTypeDefaultDescription
webhook_urlNoString-The URL where we'll send the webhook notification after the task completes. Authentication parameters in the URL (e.g., ?auth=token123) are passed as-is.
webhook_failure_notificationNoBooleanfalseIf true, we'll send an email notification if the webhook request fails after 3 retries. The email goes to the requesting user or their org admin if user is part of an organization.

Webhook Headers

HeaderRequiredTypeDefaultDescription
X-Webhook-AuthorizationNoString-
Custom authorization header sent with the webhook request. Format: Key:Value (e.g., Authorization:Bearer token123).

API Response

Explore detailed response fields including field names, data types, requirements, and descriptions in the interactive Response Tables below. For PDF Encrypt API click here, and for PDF Restrict API click here.

Utility & Resource APIs

Use these endpoints to manage files and check task status.

Task Status API

Check real-time status and retrieve input/output file ID(s) using the unique task_id. The response includes creation and expiry timestamps to help you track result availability, along with specific error details if a task fails. Results are retained for up to 7 days, depending on the operation.
Try Task Status API

File Status API

Retrieve detailed metadata for any file using its unique file_id. Returns details including file name, size, type, and creation/deletion timestamps. Generated or uploaded files are retained up to 30 days based on user's plan, unless destroy is enabled to delete them immediately. You can use this endpoint to check if the file has expired using its file_id.
Try File Status API

File Download API

Download any file from API Freaks server using its file ID. Works for both processed PDF files and ZIP archives containing multiple output files.
Try File Download API

PDF Delete API

Permanently delete a specific file you uploaded or generated using the file ID which you no longer need.
Try PDF Delete API

Files List API

Retrieve a list of all your PDF files stored on API Freaks server, with their file names and corresponding file IDs. Organization admins and maintainers can view all files in their organization, while members see only their own.
Try Files List API

File Upload API

Upload one or multiple PDF files in a single multipart/form-data request. Each file receives a unique file_id that can be used with the PDF APIs.
Try File Upload API

Upload Binary API

Upload a single large as a raw binary stream. This method eliminates multipart boundary overhead, offering faster upload speeds for larger files. Returns a unique file_id for uses with the PDF APIs.
Try Upload Binary API

HTTP Error Codes

Encrypt PDF Error Codes

HTTP StatusReasons
400
Invalid PDF File: Please provide a valid PDF file. We don't support other types.
400
Missing File or ID: You must provide either a file or a file ID.
400
Invalid Parameter: The value for 'param_name' is invalid.
404
File ID Not Found: Please provide a valid file ID.
500
File Saving Exception: An unknown error occurred while saving. Try again later.
500
Internal Server Error: Internal Server Error Occurred.
400
Missing PDF Password Exception: Please provide a user password for security operations.
400
Weak Password Provided: Please provide a strong password. Refer to the documentation for password requirements.

Restrict PDF Error Codes

HTTP StatusReasons
400
Invalid PDF File: Please provide a valid PDF file. We don't support other types.
400
Missing File or ID: You must provide either a file or a file ID.
400
Invalid Parameter: The value for 'param_name' is invalid.
404
File ID Not Found: Please provide a valid file ID.
500
File Saving Exception: An unknown error occurred while saving. Try again later.
500
Internal Server Error: Internal Server Error Occurred.
400
Missing PDF Password Exception: Please provide a password for security operations.
400
Weak Password Provided: Please provide a strong password. Refer to the documentation for password requirements.

Task Processing Error Messages

These errors might appear in the task-status response if the background job fails.

ErrorDescription
Invalid PDF File
The provided file is not a valid PDF file.
File Saving Exception
An unknown error occurred while saving the file. Try again later.
PDF Generation Exception
An unknown error occurred while generating the PDF. Try again later.
Internal Server Error
Internal Server Error Occurred.
Encrypted PDF Provided
The provided PDF file is encrypted. Please decrypt it first to perform operations.
Invalid File Password
Please provide the correct file password for security operations. Refer to documentation for valid password selection.
Missing Owner Password
Please provide an owner password for security operations. You have provided a user password which is not valid for this operation.
ZIP File Creation Error
An error occurred while creating the ZIP file. Please try again later.

How-To-Guides

Password Protect PDF

Step 1: Upload and Encrypt PDF

Encrypt your PDF with password protection by uploading a file directly (multipart upload) or referencing a file_id of a stored file. Set a user password to control who can open the document, and optionally set an owner password for managing restrictions.

curl -X 'POST' \ 'https://api.apifreaks.com/v1.0/pdf/encrypt?user_password=MySecurePass123&owner_password=AdminPass456&output=protected_document' \ -H 'X-apiKey: YOUR_API_KEY' \ -F 'file=@/path/to/document.pdf'
# Standard Response { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "inputIds": [ "7a9e4b12-f3c8-4d56-b7e1-8c2f9d0a3e6f" ] } # Response with destroy=true (No File IDs as they are deleted right away) { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d" }

Notes:

  • The API accepts only one PDF file per request (multipart file takes priority over file_id)
  • You can use Upload Binary API to upload file faster if your PDF has a large size.
  • Password length must be between 6 and 128 characters
  • All encryption uses 256-bit AES encryption standard
  • If owner_password is not provided, user_password will be used as owner password
  • Use file_password parameter if the input PDF is already password-protected
  • Use the destroy=true parameter to delete input file after encryption completes (returns only taskId)
  • File IDs must reference valid, active files stored on the API Freaks server. You can verify if a file is still available using the File Status API

Step 2: Check Task Status

After submitting a encryption or restriction task, check its progress using the Task Status API with your taskId. The task goes through these statuses: queued, processing, completed, and failed.

curl -X GET "https://api.apifreaks.com/v1.0/pdf/task-status?taskId=04a06cd5-158d-4191-a45b-6f58249c599d" \ -H "X-apikey: YOUR_API_KEY"
# Response (completed) { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "status": "completed", "outputFileId": "9b2e7f3a-5c8d-4e1b-a6f9-0d3c8e7b2a5f", "outputFileName": "processed_document.pdf", "createdAt": "2025-01-26 10:30:00", "expiresAt": "2025-01-27 10:30:00" } # Response (failed) { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "status": "failed", "error": "Invalid PDF File", "message": "The provided file is not a valid PDF file.", "createdAt": "2025-01-26 10:30:00" }

Step 3: Download Protected PDF

Once the task status shows “completed”, download your protected PDF using the File Download API with the outputFileId from the task status response.

curl -X GET "https://api.apifreaks.com/v1.0/pdf/download?fileId=9b2e7f3a-5c8d-4e1b-a6f9-0d3c8e7b2a5f" \ -H "X-apikey: YOUR_API_KEY" \ --output output.pdf

Apply PDF Restrictions

Secure your PDF with permission restrictions by uploading a file directly or using a stored file_id. Define specific restrictions to prevent copying, printing, editing, and other actions. Optionally set passwords to enforce these restrictions and control document access.

curl -X 'POST' \ 'https://api.apifreaks.com/v1.0/pdf/restrict?restrictions=copy_and_extract_content&restrictions=print_high&restrictions=modify_content&user_password=UserPass123&owner_password=AdminPass456&output=restricted_document' \ -H 'X-apiKey: YOUR_API_KEY' \ -F 'file=@/path/to/document.pdf'
# Standard Response { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d", "inputIds": [ "7a9e4b12-f3c8-4d56-b7e1-8c2f9d0a3e6f" ] } # Response with destroy=true (No File IDs as they are deleted right away) { "taskId": "04a06cd5-158d-4191-a45b-6f58249c599d" }

Notes:

  • The API accepts only one PDF file per request (multipart file takes priority over file_id)
  • The restrictions parameter is required and can contain multiple restriction values
  • Available restrictions: print_high, print_low, edit_document_assembly, fill_form_fields, edit_annotations, modify_content, copy_and_extract_content, use_accessibility which are explained in the table above.
  • Password length must be between 6 and 128 characters
  • All encryption uses 256-bit AES encryption standard
  • If owner_password is not provided, user_password will be used as owner password
  • Use file_password parameter if the input PDF is already password-protected
  • Use the destroy=true parameter to delete input file after restriction completes (returns only taskId)
  • File IDs must reference valid, active files stored on the API Freaks server. You can verify if a file is still available using the File Status API

Pricing

To use the PDF Protect APIs, API credits are required. Charges apply only for successful queries, defined by a 2xx status code. If a request results in a 4xx or 5xx status code, no credits will be deducted, and any credits already charged will be refunded.

For each successful request, 200 credit will be charged. 1 extra credit will be charged per MB beyond 50 MB.

Utilize the Credits Usage API to efficiently monitor your recent consumption of both one-off and subscription credits. This API provides a streamlined way to track and manage your credit usage, ensuring you stay informed about your remaining balance and can optimize your resource allocation effectively.

Price Estimation Calculator

Ready to get started?

Sign Up for Free

APIFreaks

API Catalog

  • Geolocation APIs
  • WHOIS APIs
  • DNS APIs
  • Email Validation APIs
  • SSL APIs
  • Domain APIs
  • Screenshot APIs
  • PDF APIs
  • Currency APIs
  • Commodity APIs
  • Financial APIs
  • ZIP Code APIs
  • Weather APIs
  • Timezone APIs
  • User Agent APIs
  • Other APIs

Tools Catalog

  • Code Formatters
  • Data & Query Tools
  • Text Tools
  • Email Utilities
  • DNS Tools
  • Viewers
  • Converters
  • PDF Tools

Docs

  • APIs
  • Swagger Docs

Pricing & Accounts

  • Pricing
  • Sign up
  • Sign In

Company

  • About Us
  • Resources
  • Terms
  • Privacy

Copyright © 2026

Made in Pakistan