---
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

---

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