PDF tools

Password-protect a PDF

Returns a copy of one PDF encrypted with AES-256. Set user_password (needed to open the PDF), owner_password with permissions (restrict printing, copying or editing), or both.

Send the PDF in the request (up to 4 MB), or upload it with /pdf/upload-url and pass its key as source_key (up to 150 MB and 5000 pages). Either way it is one request: there is no background job. Passwords are used to write the file and are never stored, logged or returned.

A PDF that is already protected is refused with 422 PDF_ENCRYPTED.

post/pdf/protect

Request

  • Base URL: https://api.podpdf.com
  • URL: https://api.podpdf.com/pdf/protect
  • Auth: API key in header X-API-Key

Request body

source_keystring

Key from /pdf/upload-url. Give this or input.

filenamestring

The name of an uploaded PDF, used for the output name.

user_passwordstring password

Needed to open the PDF. Up to 127 bytes, no control characters.

owner_passwordstring password

Needed to change or remove the protection. Required when permissions restricts anything, and must differ from user_password. On its own it needs at least one restriction.

storeboolean

Store the result and return a download link instead of the file.

Example request

{
  "input": {
    "filename": "contract.pdf"
  },
  "source_key": "pdf-uploads/01HZ…/01J8…pdf",
  "filename": "board-pack.pdf"
}

Response

The protected PDF, or JSON when store is true or the PDF was given by source_key

job_idstring
operation'pdf_protect' | 'pdf_unlock'
status'completed'
input_pagesinteger
output_count1
download_urlstring uri

Signed link, valid one hour.

zip_urlstring nullable

Always null, as there is one output.

download_url_expires_atstring date-time
warningsstring[]

SIGNATURE_INVALIDATED, SOURCE_REPAIRED or NON_ASCII_PASSWORD.

Example response

{
  "job_id": "9f0a4b78-2c0c-4d14-9b8b-123456789abc",
  "input_pages": 12,
  "outputs": [
    {
      "name": "scan-001.pdf",
      "pages": 3,
      "page_range": "1-3",
      "size_bytes": 91822
    }
  ]
}

Changes

No recorded changes to this operation across all 2 revisions of this API.