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

# Search Documents By Name

> Search documents by filename using full-text search.

`request.filters` accepts the same operator set as `/retrieve/chunks`: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`,
`$lte`, `$in`, `$nin`, `$exists`, `$type`, `$regex` (with optional `i` flag), `$contains`, and the logical
operators `$and`, `$or`, `$nor`, `$not`. Comparison clauses honor typed metadata (`number`, `decimal`,
`datetime`, `date`).



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/morphik/openapi.documented.yml post /search/documents
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /search/documents:
    post:
      summary: Search Documents By Name
      description: >-
        Search documents by filename using full-text search.


        `request.filters` accepts the same operator set as `/retrieve/chunks`:
        `$eq`, `$ne`, `$gt`, `$gte`, `$lt`,

        `$lte`, `$in`, `$nin`, `$exists`, `$type`, `$regex` (with optional `i`
        flag), `$contains`, and the logical

        operators `$and`, `$or`, `$nor`, `$not`. Comparison clauses honor typed
        metadata (`number`, `decimal`,

        `datetime`, `date`).
      operationId: search_documents_by_name_search_documents_post
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchDocumentsRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Document'
                title: Response Search Documents By Name Search Documents Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Morphik from 'morphik';

            const client = new Morphik({
              apiKey: process.env['MORPHIK_API_KEY'], // This is the default and can be omitted
            });

            const documents = await client.search.documents({ query: 'x' });

            console.log(documents);
        - lang: cURL
          source: |-
            curl https://api.morphik.ai/search/documents \
                -H 'Content-Type: application/json' \
                -H "Authorization: Bearer $MORPHIK_API_KEY" \
                -d '{
                      "query": "x"
                    }'
components:
  schemas:
    SearchDocumentsRequest:
      properties:
        query:
          type: string
          minLength: 1
          title: Query
          description: Search query for document names/filenames
        limit:
          type: integer
          maximum: 100
          minimum: 1
          title: Limit
          description: Number of documents to return
          default: 10
        filters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Filters
          description: Optional metadata filters for documents
        folder_name:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Folder Name
          description: >-
            Optional folder scope. Accepts a folder PATH (e.g.,
            '/Company/Reports') or list of paths.
        folder_depth:
          anyOf:
            - type: integer
            - type: 'null'
          title: Folder Depth
          description: >-
            Folder scope depth: 0/None exact, -1 all descendants, n>0 include
            descendants up to n levels.
        end_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: End User Id
          description: Optional end-user scope for the search
      type: object
      required:
        - query
      title: SearchDocumentsRequest
      description: Request model for searching documents by name
    Document:
      properties:
        external_id:
          type: string
          title: External Id
        content_type:
          type: string
          title: Content Type
        filename:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        metadata_types:
          additionalProperties:
            type: string
          type: object
          title: Metadata Types
        storage_info:
          additionalProperties: true
          type: object
          title: Storage Info
        system_metadata:
          additionalProperties: true
          type: object
          title: System Metadata
        additional_metadata:
          additionalProperties: true
          type: object
          title: Additional Metadata
        chunk_ids:
          items:
            type: string
          type: array
          title: Chunk Ids
        summary_storage_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary Storage Key
        summary_version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Summary Version
        summary_bucket:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary Bucket
        summary_updated_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary Updated At
        folder_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Name
        end_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: End User Id
        app_id:
          anyOf:
            - type: string
            - type: 'null'
          title: App Id
        folder_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Path
        folder_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Id
      type: object
      required:
        - content_type
      title: Document
      description: Represents a document stored in the database documents collection
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````