Redact PDF

Redact PDF API

File Tools

Black out text and images in a PDF for real: redacted pages are flattened so the hidden content is gone, not just covered. Find emails, phone numbers and more.

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

20 requests per minute

Endpoints

1 endpoint available

Overview

Permanently remove text and areas from a PDF. Find text with preset patterns and plain search terms, and/or give exact areas. Every page with a redaction is replaced by a picture of the page with the redacted areas filled in, so the text, images and drawings underneath are removed from the file, not just covered. Those pages lose selectable text.

Pages without redactions keep their text but lose annotations (comments, links, form fields). The output also drops document metadata, bookmarks, attachments and scripts.

Finding text

  • presets: comma-separated, any of email, phone, id-number (SIN/SSN), card (13 to 19 digit card numbers), date, url.
  • terms: a JSON array of plain text to find. Spaces also match line breaks. Regular expressions are not supported in the API.
  • Only real text is found. Scanned pages (pictures of text) need areas. Boxes are placed from estimated character widths with some padding, so check the result.

Areas

areas is a JSON array of boxes in PDF points (72 per inch), measured from the top-left corner of the page as displayed (after rotation), x to the right and y down: [{"page": 1, "x": 50, "y": 80, "width": 200, "height": 20}].

Response

The redacted PDF. Headers: X-Redacted-Pages (e.g. 1-2, 5) and X-Match-Count (text matches found). If nothing matches and no areas are given, the request fails with 422 rather than returning an unredacted file.

Limits

  • One PDF up to 25 MB and 500 pages; redactions on at most 100 pages per request.
  • Up to 50 search terms and 1000 areas.

Endpoints

POST
https://opentools.ca/api/v1/tools/redact-pdf
Redact text patterns, search terms and areas from a PDF

Request Body

Content-Type: multipart/form-data

ParameterTypeRequiredDescription
file
file
Required
The PDF to redact.
presets
string
OptionalComma-separated patterns to find: email, phone, id-number, card, date, url.
terms
string (JSON array)
OptionalPlain text to find, e.g. ["Jane Doe", "Project Bluebird"]. Up to 50 terms of 500 characters.
caseSensitive
boolean
OptionalMatch terms with exact case. Presets always ignore case.Default: false
areas
string (JSON array)
OptionalBoxes to redact: [{"page": 1, "x": 50, "y": 80, "width": 200, "height": 20}]. page starts at 1; the rest are points from the top-left of the displayed page.
color
string
OptionalFill colour as #rrggbb.Default: #000000
dpi
integer
Enum: 150, 200, 300
OptionalResolution of the redacted pages.Default: 200
format
string
Enum: jpg, png
OptionalImage format of the redacted pages. png is sharper for text, jpg smaller.Default: jpg

Response Example

The redacted PDF (Content-Type: application/pdf, filename <name>-redacted.pdf). Headers: X-Redacted-Pages, X-Match-Count.

Error Codes

400
Bad Request - missing or invalid fields (see details)
401
Unauthorized - missing or invalid API key
403
Forbidden - API key inactive or expired, or request IP not allowed
413
Payload Too Large - a file is over 25 MB
415
Unsupported Media Type - the file is not a PDF
422
Unprocessable - the PDF is damaged or password-protected, nothing matched and no areas were given, an area is on a page that does not exist, or redactions fall on more than 100 pages
429
Too Many Requests - more than 20 requests per minute for this key
500
Internal Server Error

Code Examples

curl -X POST https://opentools.ca/api/v1/tools/redact-pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@statement.pdf" \
  -F "presets=email,phone,card" \
  -F 'terms=["Jane Doe"]' \
  -F 'areas=[{"page": 1, "x": 400, "y": 40, "width": 150, "height": 60}]' \
  -D headers.txt \
  -o statement-redacted.pdf

Ready to get started?

Create an API key to start using the Redact PDF API.

Rather use it in your browser? Open the Redact PDF