> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Search for text content in files

> Searches for text content inside files. Returns each matching line, with the lines around it when contextLines is set.



## OpenAPI

````yaml /reference/sandbox-api/openapi.json get /filesystem-content-search/{path}
openapi: 3.0.0
info:
  description: API for manipulating filesystem, processes and network.
  title: Sandbox API
  contact: {}
  version: 0.0.1
servers:
  - url: https://{sandbox_host}
    description: >-
      Host from the sandbox's returned url, without the scheme or trailing
      slash.
    variables:
      sandbox_host:
        default: sandbox.example.com
security:
  - BearerAuth: []
paths:
  /filesystem-content-search/{path}:
    get:
      tags:
        - filesystem
      summary: Search for text content in files
      description: >-
        Searches for text content inside files. Returns each matching line, with
        the lines around it when contextLines is set.
      parameters:
        - description: Directory path to search in
          name: path
          in: path
          required: true
          schema:
            type: string
        - description: Text to search for
          name: query
          in: query
          required: true
          schema:
            type: string
        - description: 'Case sensitive search (default: false)'
          name: caseSensitive
          in: query
          schema:
            type: boolean
        - description: 'Maximum number of results to return (default: 100)'
          name: maxResults
          in: query
          schema:
            type: integer
        - description: File pattern to include (e.g., *.go)
          name: filePattern
          in: query
          schema:
            type: string
        - description: >-
            Comma-separated directory names to skip (default:
            node_modules,vendor,.git,dist,build,target,__pycache__,.venv,.next,coverage)
          name: excludeDirs
          in: query
          schema:
            type: string
        - description: >-
            Lines to include before and after each match in its context field
            (default: 0, max: 20; invalid values count as 0)
          name: contextLines
          in: query
          schema:
            type: integer
      responses:
        '200':
          description: Content search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContentSearchResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ContentSearchResponse:
      type: object
      required:
        - matches
        - query
        - total
      properties:
        matches:
          type: array
          items:
            $ref: '#/components/schemas/ContentSearchMatch'
        query:
          type: string
          example: searchText
        total:
          type: integer
          example: 5
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Error message
    ContentSearchMatch:
      type: object
      required:
        - column
        - line
        - path
        - text
      properties:
        column:
          type: integer
          example: 10
        context:
          description: >-
            The matching line with up to contextLines lines before and after it,
            newline-separated; omitted when contextLines is 0
          type: string
          example: |-
            previous line
            current line
            next line
        line:
          type: integer
          example: 42
        path:
          type: string
          example: src/main.go
        text:
          type: string
          example: const searchText = 'example'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Sandbox access token created through POST /v1/token.

````