Secure
protect, unlock, watermark, page-numbers.
Four operations to lock down and stamp documents. All take a base64 pdf
and return the resulting PDF binary.
PDF=$(base64 -w0 input.pdf) # macOS: base64 -i input.pdfProtect (encrypt)
POST /v1/pdf/protect — password-encrypt a PDF:
curl -X POST https://api.pdf-forge.dev/v1/pdf/protect \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"pdf\": \"$PDF\", \"password\": \"s3cret\"}" \
--output protected.pdfUnlock (decrypt)
POST /v1/pdf/unlock — remove the protection, given the correct password:
curl -X POST https://api.pdf-forge.dev/v1/pdf/unlock \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"pdf\": \"$PDF\", \"password\": \"s3cret\"}" \
--output unlocked.pdfA wrong password returns 400 invalid_request.
Watermark
POST /v1/pdf/watermark — stamp text or an image across pages:
# Text watermark
curl -X POST https://api.pdf-forge.dev/v1/pdf/watermark \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"pdf\": \"$PDF\", \"text\": \"CONFIDENTIAL\", \"opacity\": 0.3}" \
--output watermarked.pdf
# Image watermark (base64 PNG/JPG)
curl -X POST https://api.pdf-forge.dev/v1/pdf/watermark \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"pdf\": \"$PDF\", \"image\": \"$(base64 -w0 logo.png)\", \"opacity\": 0.2}" \
--output watermarked.pdf| Field | Type | Description |
|---|---|---|
pdf | string | Required. Base64 PDF. |
text | string | Watermark text (either text or image is required). |
image | string | Base64 PNG/JPG watermark. |
opacity | number | 0..1. |
color | string | Text colour (text watermarks). |
size | number | Font size in points (text watermarks). |
diagonal | boolean | Classic diagonal stamp — default true. |
position | string | Placement when not diagonal. |
rotation | number | Custom angle in degrees. |
pages | string[] | Limit to pages/ranges, e.g. ["1", "3-5"]. |
To remove an overlay watermark, see
True redaction — strip-watermark is documented
there.
Page numbers
POST /v1/pdf/page-numbers — stamp page numbers:
curl -X POST https://api.pdf-forge.dev/v1/pdf/page-numbers \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"pdf\": \"$PDF\", \"position\": \"bottom-center\"}" \
--output numbered.pdfOptional fields: format (number pattern), position, size (points),
pages (selection).
Generation-time alternative
If you are generating the PDF yourself, watermark and password are also
request fields on /v1/generate/html —
one call instead of two.
Next steps
- True redaction — physically remove sensitive content.
- Compress — lighten before sending.
- Inspect — check
encryptedand other properties.