endpoint
Protect
POST /api/v1/protect
Password-protect a PDF with AES-128 or AES-256 and apply permission restrictions.
credits: 1returns: application/pdf
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file | multipart file | required | Source PDF. |
| userPassword | string | optional | Required to open the document. |
| ownerPassword | string | optional | Required to change permissions. At least one password is required. |
| permissions | csv | optional | Allowed actions — printing, copying, etc. |
| encryption | "aes-128" | "aes-256" | optional | Cipher strength.default: aes-256 |
Examples
curl
curl -X POST https://api.snappdf.au/api/v1/protect \
-H "Authorization: Bearer $SNAPPDF_API_KEY" \
-F "file=@doc.pdf" -F "userPassword=secret" -F "encryption=aes-256" \
-o protected.pdfJavaScript
await snap.pdf.protect({ file: bytes, userPassword: 'secret', encryption: 'aes-256' });Python
snap.pdf.protect(file=bytes, user_password="secret", encryption="aes-256")PHP
$snap->pdf->protect(file: $bytes, userPassword: 'secret');Ruby
snap.pdf.protect(file: bytes, user_password: 'secret')Go
client.Protect(ctx, &snappdf.ProtectInput{File: bytes, UserPassword: "secret", Encryption: "aes-256"})