---
title: "Grep File"
method: POST
path: "/api/v1/retrieval/files/grep"
tags: ["Retrieval"]
---

# Grep File

`POST /api/v1/retrieval/files/grep`

Grep within a file's parsed content using a regex pattern.

## Query parameters

- `project_id` string, uuid, nullable
- `organization_id` string, uuid, nullable

## Cookies

- `session` string, nullable

## Request body

- FileGrepParams — Grep within a specific file's parsed content.
  - `page_size` integer, nullable — The maximum number of items to return. The service may return fewer than this value. If unspecified, a default page size will be used. The maximum value is typically 1000; values above this will be coerced to the maximum.
  - `page_token` string, nullable — A page token, received from a previous list call. Provide this to retrieve the subsequent page.
  - `index_id` string, required — ID of the index the file belongs to.
  - `file_id` string, required — ID of the file to grep.
  - `pattern` string, required — Regex pattern to search for.
  - `context_chars` integer, nullable — Number of characters of context to include before and after the matched pattern in the content field of the response

## Response `200`

Successful Response

- FileGrepResult — Paginated grep results for a file.
  - `items` FileGrepMatch[], required — The list of items.
    - `start_char` integer, required — Start character offset of the match.
    - `end_char` integer, required — End character offset of the match.
    - `content` string, required — Matched text content.
  - `next_page_token` string, nullable — A token, which can be sent as page_token to retrieve the next page. If this field is omitted, there are no subsequent pages.
  - `total_size` integer, nullable — The total number of items available. This is only populated when specifically requested. The value may be an estimate and can be used for display purposes only.

## Other responses

- `422` — Validation Error

## Changes

- **2026-06-09** `b17341164de9` — 2 info
  - added the optional property `detail/items/ctx` to the response with the `422` status
  - added the optional property `detail/items/input` to the response with the `422` status
- **2026-05-23** `34da5826db1c` — 1 info
  - endpoint added
- **2026-05-21** `fb63fb8d662c` — 1 breaking
  - api path removed without deprecation
- **2026-05-20** `b6390803e961` — 1 breaking, 1 warning, 5 info
  - removed the required property `matches` from the response with the `200` status
  - removed the request property `limit`
  - added the new optional request property `page_size`
  - added the new optional request property `page_token`
  - …3 more
- **2026-05-19** `64b8ab5b0a0a` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/run-llama/apis/llama-platform/changes/api/v1/retrieval/files/grep/post.md)

---

[API](https://skmtc.dev/run-llama/apis/llama-platform.md) · [All operations](https://skmtc.dev/run-llama/apis/llama-platform/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/run-llama/llama-platform/revisions/b17341164de9/schema)
