---
title: "Search and redact PDF server-side | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/document-engine/redaction/search-and-redact/"
md_url: "https://www.nutrient.io/guides/document-engine/redaction/search-and-redact.md"
last_updated: "2026-06-11T00:00:00.000Z"
description: "Document Engine lets you create redactions using simple text search rules. Any piece of text matching a provided query will be covered by redaction annotations."
---

# Search and redact PDFs

Document Engine lets you create redactions using simple text search rules. Any piece of text matching a provided query will be covered by redaction annotations. To create redactions, use the [`createRedactions` action](https://www.nutrient.io/api/reference/document-engine/upstream/#model/BuildInstructions) with a `text` strategy.

To learn more about redaction strategies, go to the [API reference](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API/#create-redactions).

You can configure some visual aspects of the redaction annotation, including its background color and overlay text, by passing an optional `content` object to the `createRedactions` action. To learn more about all configurable options, refer to the [API reference](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API/#create-redactions).

The following example redacts any occurrence of the phrase ACME Bank:

```json

{
  type: "createRedactions",
  strategy: "text",
  strategyOptions: {
    text: "ACME Bank"
  }
}

```

## Matching wrapped text with `word_based`

Use the `word_based` strategy when the text you want to redact may wrap across line breaks, tables, or columns. This strategy ignores whitespace between characters — including spaces, tabs, newlines, and Unicode space variants — but punctuation must still match exactly. Queries must be at least three characters long.

For example, a query for `Smith, John` matches `Smith,\nJohn`, but it won’t match `Smith John` because the comma is missing in the document text:

```json

{
  type: "createRedactions",
  strategy: "word_based",
  strategyOptions: {
    word_based: "Smith, John"
  }
}

```

<!-- This partial is rendered in guide articles describing redaction strategies. -->

### Applying redactions

After redaction annotations are created, they need to be applied to the document to effectively and permanently remove the covered content. You can achieve this by adding the [`applyRedactions` action](https://www.nutrient.io/api/reference/document-engine/upstream/#model/BuildInstructions) to the `/build` [instructions](https://www.nutrient.io/api/reference/document-engine/upstream/#model/BuildInstructions).

- Ensure [Document Engine is up and running](https://www.nutrient.io/sdk/document-engine/getting-started.md).

- Send a [multipart POST request](https://www.baeldung.com/postman-form-data-raw-x-www-form-urlencoded) with [instructions](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API) to Document Engine’s `/api/build` endpoint.

For more information, refer to the [API reference](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API) to learn about the `/api/build` endpoint and all the actions you can perform on PDFs with Document Engine.

For an overview of multipart requests, refer to the [brief tour of multipart requests](https://www.nutrient.io/blog/a-brief-tour-of-multipart-requests/) blog post.









## Creating and Applying Redactions in a File on Disk

Send a multipart request to the [`/api/build` endpoint](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Document-Editing/operation/build-document) attached with the input file and the [`instructions` JSON](https://www.nutrient.io/api/reference/document-engine/upstream/#model/BuildInstructions):

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F file=@/path/to/example-document.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "document",
      "actions": [

        {
          type: "createRedactions",
          strategy: "text",
          strategyOptions: {
            text: "ACME Bank"
          }
        },

        {
          "type": "applyRedactions"
        }
      ]
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="file"; filename="example-document.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "document",
      "actions": [

        {
          type: "createRedactions",
          strategy: "text",
          strategyOptions: {
            text: "ACME Bank"
          }
        },

        {
          "type": "applyRedactions"
        }
      ]
    }
  ]
}
--customboundary--

```

This creates redaction annotations and applies them to the file, removing the content beneath them.

## Creating and Applying Redactions in a File from a URL

Send a request to the [`/api/build` endpoint](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Document-Editing/operation/build-document) and include a URL pointing to the file you want to redact:

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F instructions='{
  "parts": [
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/credit-card-application.pdf"
      },
      "actions": [

        {
          type: "createRedactions",
          strategy: "text",
          strategyOptions: {
            text: "ACME Bank"
          }
        },

        {
          "type": "applyRedactions"
        }
      ]
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/credit-card-application.pdf"
      },
      "actions": [

        {
          type: "createRedactions",
          strategy: "text",
          strategyOptions: {
            text: "ACME Bank"
          }
        },

        {
          "type": "applyRedactions"
        }
      ]
    }
  ]
}
--customboundary--

```

This creates redaction annotations and applies them to the file, removing the content beneath them.
---

## Related pages

- [PDF Redaction Server](/guides/document-engine/redaction.md)
- [Introduction to PDF redaction](/guides/document-engine/redaction/introduction.md)
- [Redact PDFs using RegEx](/guides/document-engine/redaction/regex-patterns.md)
- [Preset pattern redaction](/guides/document-engine/redaction/preset-patterns.md)

