SnapPDF
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

NameTypeRequiredDescription
filemultipart filerequiredSource PDF.
userPasswordstringoptionalRequired to open the document.
ownerPasswordstringoptionalRequired to change permissions. At least one password is required.
permissionscsvoptionalAllowed actions — printing, copying, etc.
encryption"aes-128" | "aes-256"optionalCipher 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.pdf
JavaScript
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"})