LM-Kit OneDocs2026.8.10lm-kit.com
Document Utilities

PDF Redaction

Permanently removes content from a PDF (redaction).#

POST/lmkit/v1/pdf-redact

Redacts a PDF by permanently deleting the underlying content, not merely drawing a black box over it. Text glyphs are removed from content streams, image pixels are scrubbed and re-encoded, vector graphics are trimmed, intersecting annotations are deleted, and content nested inside Form XObjects is processed per instance. The removed content cannot be recovered from the output by text extraction, raw stream inspection, or rendering. Specify what to remove with 'search_terms' (every occurrence of each string is redacted), 'areas' (explicit page regions in points), and/or 'apply_existing_annotations' (apply the document's pre-existing /Redact marks). Surviving content is untouched: text is removed at glyph granularity, and shared resources are cloned before editing so only the targeted instance changes. The redacted document is stored on the server and returned as a file ID together with a report of what was removed. This is a pure document processing operation that does not require an AI model. Returns 422 Unprocessable Entity with an ErrorResponse body if the input file cannot be processed. The 'error' field contains one of: 'password_required' (encrypted PDF), 'invalid_format' (not a valid PDF), 'unsupported_security' (unsupported encryption), 'page_error' (content error).

Request body

application/json ·

PropertyTypeDescription
inputrequiredstring

The source PDF document. When input_format is 'Base64EncodedFile', provide a base64-encoded PDF payload. When 'FileIdentifier', provide the file ID previously returned by the lmkit/v1/files/upload endpoint.

input_format

How the input is provided. Accepted values: 'Base64EncodedFile' or 'FileIdentifier'. 'Base64EncodedFile' expects a base64-encoded PDF file. 'FileIdentifier' references a file previously uploaded via lmkit/v1/files/upload. Defaults to 'Base64EncodedFile'.

search_termsstring[]

Text strings to search for and redact. Every occurrence of each term found anywhere in the document is removed. Combine with 'areas' and 'apply_existing_annotations'; everything matched is redacted in a single pass.

areas[]

Explicit rectangular regions to redact, in page points (top-left origin). Use these to redact a figure, a signature, or any region regardless of its content.

apply_existing_annotationsboolean

When true, the document's pre-existing /Redact annotations (for example marks created in Acrobat or another tool) are applied and consumed as part of this request. Defaults to false.

case_sensitiveboolean

Whether term matching is case-sensitive. Applies only to 'search_terms'. Defaults to false.

whole_wordboolean

When true, a term only matches when bounded by non-word characters on both sides. Applies only to 'search_terms'. Defaults to false.

draw_fill_boxesboolean

When true (default), an opaque box is drawn over each redacted region after its content is removed.

fill_colorstring

Fill-box color as a hex string '#RRGGBB'. Ignored when 'draw_fill_boxes' is false. Defaults to '#000000' (black).

redact_imagesboolean

When true (default), image pixels intersecting a redacted region are scrubbed. An intersecting image that cannot be decoded is removed entirely; redacted pixel data never survives.

redact_vector_graphicsboolean

When true (default), vector path content intersecting a redacted region is removed.

remove_annotationsboolean

When true (default), annotations whose rectangle intersects a redacted region are removed. Annotation payloads (markup contents, link targets, form field values) often duplicate the content being redacted.

recurse_into_formsboolean

When true (default), redaction descends into Form XObjects. The affected form instance is cloned before editing, so the same form referenced from other pages keeps its original content.

passwordstring

Password used to open the source document when it is encrypted. The output is always written unencrypted.

Responses

StatusTypeDescription
200

OK

202

Accepted

422

Unprocessable Entity

400

Bad Request

curl -X POST "$LMKIT_ONE_URL/lmkit/v1/pdf-redact" \
  -H "Authorization: Bearer $LMKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "",
  "input_format": "Base64EncodedFile",
  "search_terms": [
    "string"
  ],
  "areas": [
    {
      "page_index": "string",
      "left": "string",
      "top": "string",
      "width": "string",
      "height": "string"
    }
  ],
  "apply_existing_annotations": false
}'