---
title: "Find search term inside a document (page + rectangle)"
method: GET
path: "/documents/ocr-search-hits"
tags: ["Document AI — DMS"]
---

# Find search term inside a document (page + rectangle)

`GET /documents/ocr-search-hits`

## Request

- Base URL: `https://api.paperoffice.ai/latest`
- URL: `https://api.paperoffice.ai/latest/documents/ocr-search-hits`
- Auth: HTTP bearer

Find where a search term occurs inside ONE document: returns each occurrence with page number, percent rectangle (box = exact OCR rectangle, x/y/w/h = padded display marker) and a snippet. Read-only, no OCR run. Pricing: API minimum...

## Query parameters

- `pofid` string, required
- `query` string, required
- `match` 'auto' | 'phrase' | 'any'

## Response `200`

Success

- object: Occurrences of a search term inside one document with page and rectangle
  - `status` 'success', required
  - `pofid` string, required
  - `total_pages` integer: Pages of the document
  - `query` string, required: Normalized query
  - `match` 'auto' | 'phrase' | 'any': Requested mode
  - `match_mode` 'phrase' | 'tokens' | 'none', required: Mode that produced the hits
  - `coordinates` 'percent_of_page'
  - `total` integer, required: Number of occurrences found (before the 2000 cap)
  - `truncated` boolean: true when hits were capped; the first hit of every page is kept
  - `pages_truncated` boolean: true when more than 2000 pages matched
  - `page_count` integer: Distinct pages with at least one hit
  - `hits` object[], required
    - `index` integer, required: 0-based position in reading order
    - `page` integer, required: 1-based page number
    - `has_box` boolean, required: false: text present on the page but no coordinates
    - `x` number: Display marker left, percent
    - `y` number: Display marker top, percent
    - `w` number: Display marker width, percent
    - `h` number: Display marker height, percent
    - `box` object: Rectangle in percent of the page, origin top-left
      - `x` number
      - `y` number
      - `w` number
      - `h` number
    - `box_scope` 'word' | 'line': word: cut to the term inside the OCR line (tags stripped, character-width estimate); line: whole OCR line (right-to-left script)
    - `snippet` string, required: Up to 90 characters of context
    - `text_matches` integer: Only when has_box=false: occurrences in the page text

## Other responses

- `4XX`: Error
- `5XX`: Error

---

[API](https://skmtc.dev/paperoffice/apis/paperoffice-ai-api.md) · [All operations](https://skmtc.dev/paperoffice/apis/paperoffice-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/paperoffice/apis/paperoffice-ai-api/revisions/c6a6228a4509?raw)
