## Grep File

**post** `/api/v1/retrieval/files/grep`

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

### Query Parameters

- `organization_id: optional string`

- `project_id: optional string`

### Cookie Parameters

- `session: optional string`

### Body Parameters

- `file_id: string`

  ID of the file to grep.

- `index_id: string`

  ID of the index the file belongs to.

- `pattern: string`

  Regex pattern to search for.

- `context_chars: optional number`

  Number of characters of context to include before and after the matched pattern in the content field of the response

- `limit: optional number`

  Maximum number of matches to return.

### Returns

- `matches: array of object { content, end_char, start_char }`

  Regex matches found in the file.

  - `content: string`

    Matched text content.

  - `end_char: number`

    End character offset of the match.

  - `start_char: number`

    Start character offset of the match.

### Example

```http
curl https://api.cloud.llamaindex.ai/api/v1/retrieval/files/grep \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
    -d '{
          "file_id": "file_id",
          "index_id": "idx-abc123",
          "pattern": "revenue|profit"
        }'
```

#### Response

```json
{
  "matches": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ]
}
```
