> ## Documentation Index
> Fetch the complete documentation index at: https://sourcebot-whoisthey-language-model-input-modalities.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Search code

> Executes a blocking code search and returns all matching file chunks.

## Usage

The `query` field supports literal, regexp, and symbol searches with filters for repository, file, language, branch, and more. See the [search syntax reference](https://docs.sourcebot.dev/docs/features/search/syntax-reference) for the full query language.


## OpenAPI

````yaml /api-reference/sourcebot-public.openapi.json post /api/search
openapi: 3.0.3
info:
  title: Sourcebot Public API
  version: v5.0.4
  description: >-
    OpenAPI description for the public Sourcebot REST endpoints used for search,
    repository listing, and file browsing. Authentication is instance-dependent:
    API keys are the standard integration mechanism, OAuth bearer tokens are
    EE-only, and some instances may allow anonymous access.
servers: []
security:
  - bearerToken: []
  - apiKeyHeader: []
  - {}
tags:
  - name: Search & Navigation
    description: Code search and symbol navigation endpoints.
  - name: Repositories
    description: Repository listing and metadata endpoints.
  - name: Git
    description: Git history, diff, and file content endpoints.
  - name: System
    description: System health and version endpoints.
  - name: Enterprise (EE)
    description: Enterprise endpoints for user management and audit logging.
paths:
  /api/search:
    post:
      tags:
        - Search & Navigation
      summary: Search code
      description: Executes a blocking code search and returns all matching file chunks.
      operationId: search
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicSearchRequest'
      responses:
        '200':
          description: Search results.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicSearchResponse'
        '400':
          description: Invalid request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiServiceError'
        '500':
          description: Unexpected search failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiServiceError'
components:
  schemas:
    PublicSearchRequest:
      type: object
      properties:
        query:
          type: string
        matches:
          type: number
        contextLines:
          type: number
        whole:
          type: boolean
        isRegexEnabled:
          type: boolean
        isCaseSensitivityEnabled:
          type: boolean
      required:
        - query
        - matches
    PublicSearchResponse:
      type: object
      properties:
        stats:
          type: object
          properties:
            actualMatchCount:
              type: number
            totalMatchCount:
              type: number
            duration:
              type: number
            fileCount:
              type: number
            filesSkipped:
              type: number
            contentBytesLoaded:
              type: number
            indexBytesLoaded:
              type: number
            crashes:
              type: number
            shardFilesConsidered:
              type: number
            filesConsidered:
              type: number
            filesLoaded:
              type: number
            shardsScanned:
              type: number
            shardsSkipped:
              type: number
            shardsSkippedFilter:
              type: number
            ngramMatches:
              type: number
            ngramLookups:
              type: number
            wait:
              type: number
            matchTreeConstruction:
              type: number
            matchTreeSearch:
              type: number
            regexpsConsidered:
              type: number
            flushReason:
              type: string
          required:
            - actualMatchCount
            - totalMatchCount
            - duration
            - fileCount
            - filesSkipped
            - contentBytesLoaded
            - indexBytesLoaded
            - crashes
            - shardFilesConsidered
            - filesConsidered
            - filesLoaded
            - shardsScanned
            - shardsSkipped
            - shardsSkippedFilter
            - ngramMatches
            - ngramLookups
            - wait
            - matchTreeConstruction
            - matchTreeSearch
            - regexpsConsidered
            - flushReason
        files:
          type: array
          items:
            type: object
            properties:
              fileName:
                type: object
                properties:
                  text:
                    type: string
                  matchRanges:
                    type: array
                    items:
                      type: object
                      properties:
                        start:
                          type: object
                          properties:
                            byteOffset:
                              type: number
                            lineNumber:
                              type: number
                            column:
                              type: number
                          required:
                            - byteOffset
                            - lineNumber
                            - column
                        end:
                          type: object
                          properties:
                            byteOffset:
                              type: number
                            lineNumber:
                              type: number
                            column:
                              type: number
                          required:
                            - byteOffset
                            - lineNumber
                            - column
                      required:
                        - start
                        - end
                required:
                  - text
                  - matchRanges
              webUrl:
                type: string
              externalWebUrl:
                type: string
              repository:
                type: string
              repositoryId:
                type: number
              language:
                type: string
              chunks:
                type: array
                items:
                  type: object
                  properties:
                    content:
                      type: string
                    matchRanges:
                      type: array
                      items:
                        type: object
                        properties:
                          start:
                            type: object
                            properties:
                              byteOffset:
                                type: number
                              lineNumber:
                                type: number
                              column:
                                type: number
                            required:
                              - byteOffset
                              - lineNumber
                              - column
                          end:
                            type: object
                            properties:
                              byteOffset:
                                type: number
                              lineNumber:
                                type: number
                              column:
                                type: number
                            required:
                              - byteOffset
                              - lineNumber
                              - column
                        required:
                          - start
                          - end
                    contentStart:
                      type: object
                      properties:
                        byteOffset:
                          type: number
                        lineNumber:
                          type: number
                        column:
                          type: number
                      required:
                        - byteOffset
                        - lineNumber
                        - column
                    symbols:
                      type: array
                      items:
                        type: object
                        properties:
                          symbol:
                            type: string
                          kind:
                            type: string
                          parent:
                            type: object
                            properties:
                              symbol:
                                type: string
                              kind:
                                type: string
                            required:
                              - symbol
                              - kind
                        required:
                          - symbol
                          - kind
                  required:
                    - content
                    - matchRanges
                    - contentStart
              branches:
                type: array
                items:
                  type: string
              content:
                type: string
            required:
              - fileName
              - webUrl
              - repository
              - repositoryId
              - language
              - chunks
        repositoryInfo:
          type: array
          items:
            type: object
            properties:
              id:
                type: number
              codeHostType:
                type: string
                enum:
                  - github
                  - gitlab
                  - gitea
                  - gerrit
                  - bitbucketServer
                  - bitbucketCloud
                  - genericGitHost
                  - azuredevops
              name:
                type: string
              displayName:
                type: string
              webUrl:
                type: string
            required:
              - id
              - codeHostType
              - name
        isSearchExhaustive:
          type: boolean
      required:
        - stats
        - files
        - repositoryInfo
        - isSearchExhaustive
    PublicApiServiceError:
      type: object
      properties:
        statusCode:
          type: number
        errorCode:
          type: string
        message:
          type: string
      required:
        - statusCode
        - errorCode
        - message
      description: Structured error response returned by Sourcebot public API endpoints.
  securitySchemes:
    bearerToken:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your API key.
    apiKeyHeader:
      type: apiKey
      in: header
      name: X-Sourcebot-Api-Key
      description: >-
        Header of the form `X-Sourcebot-Api-Key: <token>`, where `<token>` is
        your API key.

````