Skip to main content
The /highlight endpoint is the core of the RAG PDF Highlighter API. You give it a publicly accessible URL to a PDF and a list of text chunks retrieved from your RAG pipeline, and it downloads the PDF, locates each chunk on its target page, applies yellow highlights, and streams the annotated file back to you as a binary PDF download.

Request

Method: POST
Path: /highlight
Content-Type: application/json

Body Parameters

string
required
A publicly accessible URL pointing to the PDF you want to annotate. The service downloads this file at request time, so the URL must be reachable from the host running the service.
array
required
A list of document chunk objects to locate and highlight in the PDF. Each element must conform to the DocumentPayload shape.
Page numbers in metadata.page are 0-indexed. The first page of your PDF is page 0, the second is page 1, and so on. If your RAG pipeline stores 1-indexed page numbers, subtract 1 before sending them to this API.

Examples

Responses

200 OK

The highlights were applied successfully. The response body is a binary PDF file. Write the raw response bytes to a .pdf file to view the result.

400 Bad Request

Returned when the request is structurally valid but the service cannot complete it. See the Errors page for specific causes including PDFDownloadError and NoDocumentsError.

422 Unprocessable Entity

Returned by Pydantic when required fields (pdf_url or documents) are missing or have the wrong type.

500 Internal Server Error

An unexpected error occurred during processing. Check the service logs for details.
If a chunk’s text cannot be found on its target page, the service silently skips that chunk and continues processing the remaining documents. No error is raised and the returned PDF will simply not contain a highlight for that chunk. See Chunks not highlighted for common causes.