## Grep File

`RetrievalGrepPageResponse Beta.Retrieval.Grep(RetrievalGrepParamsparameters, CancellationTokencancellationToken = default)`

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

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

### Parameters

- `RetrievalGrepParams parameters`

  - `required string fileID`

    Body param: ID of the file to grep.

  - `required string indexID`

    Body param: ID of the index the file belongs to.

  - `required string pattern`

    Body param: Regex pattern to search for.

  - `string? organizationID`

    Query param

  - `string? projectID`

    Query param

  - `Long? contextChars`

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

  - `Long? pageSize`

    Body param: 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.

  - `string? pageToken`

    Body param: A page token, received from a previous list call. Provide this to retrieve the subsequent page.

### Returns

- `class RetrievalGrepPageResponse:`

  Paginated grep results for a file.

  - `required IReadOnlyList<RetrievalGrepResponse> Items`

    The list of items.

    - `required string Content`

      Matched text content.

    - `required Long EndChar`

      End character offset of the match.

    - `required Long StartChar`

      Start character offset of the match.

  - `string? NextPageToken`

    A token, which can be sent as page_token to retrieve the next page. If this field is omitted, there are no subsequent pages.

  - `Long? TotalSize`

    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.

### Example

```csharp
RetrievalGrepParams parameters = new()
{
    FileID = "file_id",
    IndexID = "idx-abc123",
    Pattern = "revenue|profit",
};

var page = await client.Beta.Retrieval.Grep(parameters);
await foreach (var item in page.Paginate())
{
    Console.WriteLine(item);
}
```

#### Response

```json
{
  "items": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
```
