---
title: "Grep for a pattern within a source"
method: POST
path: "/v1/rag/managed_indexes/{index_name}/grep"
tags: ["beta.rag.managed_indexes"]
---

# Grep for a pattern within a source

`POST /v1/rag/managed_indexes/{index_name}/grep`

Lexical substring match within a single source, in reading order. PHRASE mode matches the pattern literally (whitespace-sensitive, case-insensitive); TERM mode requires every whitespace-split token present in any order. A 200 with an empty list means the source exists but no chunk matched; a 404 means the source has no chunks at all.

## Path parameters

- `index_name` string, required

## Request body

- GrepRequest
  - `source_id` string, required
  - `pattern` string, required
  - `mode` 'phrase' | 'term'
  - `top_k` integer
  - `content_type` string

## Response `200`

Successful Response

- NavigationResponse — Unranked chunk list in reading order (ascending start_offset).
  - `chunks` NavigationChunkResponse[], required
    - `id` string, required
    - `source_id` string, required
    - `locator` string, required
    - `start_offset` integer, nullable, required
    - `end_offset` integer, nullable, required
    - `chunk_type` string, required
    - `parent_ref` string, nullable
    - `content` string, required
    - `metadata` object

## Other responses

- `404` — Index not found, or source/chunk does not exist in the index
- `409` — Index is not ready for search
- `422` — Validation Error
- `500` — Navigation query failed during execution

## Changes

- **2026-09-23** `fa73befe1c61` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/mistral/apis/mistral-ai-api/changes/v1/rag/managed_indexes/:index_name/grep/post.md)

---

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