HomeDocsAPI Reference › Security Endpoints

Security Endpoints

Protect, compress, repair, redact, and linearize PDF documents via the REST API.

Overview

The security endpoints provide tools to protect PDFs with passwords and permissions, compress files to reduce size, repair damaged documents, permanently redact sensitive content, and linearize PDFs for fast web viewing. All endpoints return the processed PDF in the response body.

Info
All security endpoints require authentication. Include your X-Api-Key and X-Api-Secret headers on every request. See Authentication for details.

Protect PDF

POST /api/pdf/protect

Adds password protection and permission restrictions to a PDF document. You can set an open password (required to view the document) and a permissions password (required to change security settings).

NameTypeRequiredDescription
fileFileYesThe PDF file to protect.
openPasswordStringNoPassword required to open and view the document. If omitted, no open password is set.
permissionsPasswordStringNoPassword required to change permissions and security settings. At least one password must be provided.
allowPrintingBooleanNoAllow printing the document. Default: true.
allowCopyingBooleanNoAllow copying text and images from the document. Default: true.
allowEditingBooleanNoAllow modifying the document content. Default: false.
allowAnnotationsBooleanNoAllow adding annotations and form filling. Default: true.
encryptionStringNoEncryption level: aes128 (default), aes256, rc4-128.
currentPasswordStringNoCurrent password if the PDF is already protected.
outputFileNameStringNoCustom name for the output PDF file.
curl -X POST https://pdf.mapsoft.com/api/pdf/protect \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "X-Api-Secret: YOUR_API_SECRET" \
  -F "file=@document.pdf" \
  -F "openPassword=ViewerPass123" \
  -F "permissionsPassword=OwnerPass456" \
  -F "allowPrinting=true" \
  -F "allowCopying=false" \
  -F "allowEditing=false" \
  -F "encryption=aes256" \
  -o protected.pdf

Compress PDF

POST /api/pdf/compress

Reduces the file size of a PDF document by compressing images, removing unused objects, and optimizing the internal structure.

NameTypeRequiredDescription
fileFileYesThe PDF file to compress.
qualityStringNoCompression quality: low (smallest file), medium (default, balanced), high (best quality, larger file).
imageResolutionIntegerNoTarget DPI for embedded images. Default: 150. Range: 72–300.
removeMetadataBooleanNoStrip metadata to reduce file size. Default: false.
outputFileNameStringNoCustom name for the output PDF file.
passwordStringNoPassword to open the PDF, if it is password-protected.
curl -X POST https://pdf.mapsoft.com/api/pdf/compress \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "X-Api-Secret: YOUR_API_SECRET" \
  -F "file=@large-document.pdf" \
  -F "quality=medium" \
  -F "imageResolution=150" \
  -o compressed.pdf

Repair PDF

POST /api/pdf/repair

Attempts to repair a damaged or corrupted PDF document by rebuilding the cross-reference table, fixing broken object references, and recovering readable content.

NameTypeRequiredDescription
fileFileYesThe damaged PDF file to repair.
outputFileNameStringNoCustom name for the repaired PDF file.
passwordStringNoPassword to open the PDF, if it is password-protected.
curl -X POST https://pdf.mapsoft.com/api/pdf/repair \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "X-Api-Secret: YOUR_API_SECRET" \
  -F "file=@damaged.pdf" \
  -o repaired.pdf

Redact PDF

POST /api/pdf/redact

Permanently removes sensitive content from a PDF document by applying redaction annotations. Redacted content is irreversibly replaced with black rectangles and cannot be recovered.

Warning
Redaction is permanent and irreversible. The original text and images under redacted areas are completely removed from the file. Always keep a backup of the original document.
NameTypeRequiredDescription
fileFileYesThe PDF file to redact.
searchTextStringNoText to search for and redact. All occurrences will be redacted.
searchRegexStringNoRegular expression pattern to match text for redaction (e.g., \b\d{3}-\d{2}-\d{4}\b for SSNs).
pagesStringNoPages to redact (e.g., 1-5). Defaults to all pages.
redactColorStringNoColor of redaction boxes as hex code. Default: #000000 (black).
outputFileNameStringNoCustom name for the output PDF file.
passwordStringNoPassword to open the PDF, if it is password-protected.
curl -X POST https://pdf.mapsoft.com/api/pdf/redact \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "X-Api-Secret: YOUR_API_SECRET" \
  -F "file=@sensitive-document.pdf" \
  -F "searchRegex=\b\d{3}-\d{2}-\d{4}\b" \
  -F "redactColor=#000000" \
  -o redacted.pdf

Linearize PDF

POST /api/pdf/linearize

Linearizes a PDF document for "fast web view." Linearized PDFs are optimized so that the first page can be displayed immediately while the rest of the document continues loading in the background. This is especially useful for large documents served over the web.

NameTypeRequiredDescription
fileFileYesThe PDF file to linearize.
outputFileNameStringNoCustom name for the output PDF file.
passwordStringNoPassword to open the PDF, if it is password-protected.
curl -X POST https://pdf.mapsoft.com/api/pdf/linearize \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "X-Api-Secret: YOUR_API_SECRET" \
  -F "file=@document.pdf" \
  -o linearized.pdf