> ## 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.

# Retrieve Documents

> Retrieve relevant documents.

`request.filters` supports equality checks (including scalar-to-array matches) and the same operator set as
`/retrieve/chunks`: logical composition via `$and`, `$or`, `$nor`, `$not`, plus field predicates `$eq`, `$ne`,
`$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`, `$type`, `$regex`, and `$contains`. Use the same JSON
structure as `/retrieve/chunks` when expressing complex logic. Comparison operators require metadata typed as
`number`, `decimal`, `datetime`, or `date`.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/morphik/openapi.documented.yml post /retrieve/docs
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /retrieve/docs:
    post:
      summary: Retrieve Documents
      description: >-
        Retrieve relevant documents.


        `request.filters` supports equality checks (including scalar-to-array
        matches) and the same operator set as

        `/retrieve/chunks`: logical composition via `$and`, `$or`, `$nor`,
        `$not`, plus field predicates `$eq`, `$ne`,

        `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`, `$type`,
        `$regex`, and `$contains`. Use the same JSON

        structure as `/retrieve/chunks` when expressing complex logic.
        Comparison operators require metadata typed as

        `number`, `decimal`, `datetime`, or `date`.
      operationId: retrieve_documents_retrieve_docs_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/RetrieveRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DocumentResult'
                title: Response Retrieve Documents Retrieve Docs 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 response = await client.retrieve.createDocs();

            console.log(response);
        - lang: cURL
          source: |-
            curl https://api.morphik.ai/retrieve/docs \
                -H 'Content-Type: application/json' \
                -H "Authorization: Bearer $MORPHIK_API_KEY" \
                -d '{}'
components:
  schemas:
    RetrieveRequest:
      properties:
        query:
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
          title: Query
          description: >-
            Natural-language query used to retrieve relevant chunks or
            documents.
        query_image:
          anyOf:
            - type: string
            - type: 'null'
          title: Query Image
          description: >-
            Base64-encoded image to use as query for Morphik multimodal
            retrieval. Requires use_colpali=True. Mutually exclusive with
            'query'.
        filters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Filters
          description: >-
            Metadata filters supporting logical operators ($and/$or/$not/$nor)
            and field predicates
            ($eq/$ne/$gt/$gte/$lt/$lte/$in/$nin/$exists/$type/$regex/$contains).
        k:
          type: integer
          exclusiveMinimum: 0
          title: K
          description: Maximum number of chunks or documents to return.
          default: 4
        min_score:
          type: number
          title: Min Score
          description: Minimum similarity score a result must meet before it is returned.
          default: 0
        use_reranking:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Reranking
          description: >-
            When provided, overrides the workspace reranking configuration for
            this request.
        use_colpali:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Colpali
          description: >-
            When provided, uses Morphik's finetuned ColPali style embeddings
            (recommended to be True for high quality retrieval).
        output_format:
          anyOf:
            - $ref: '#/components/schemas/OutputFormat'
            - type: 'null'
          description: >-
            How to return image chunks: base64 (default), url, or text (markdown
            format)
          default: base64
        padding:
          type: integer
          minimum: 0
          title: Padding
          description: >-
            Number of additional chunks/pages to retrieve before and after
            matched chunks (ColPali only)
          default: 0
        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 or None = exact folder only, -1 = include all
            descendants, n > 0 = include descendants up to n levels deeper.
        end_user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: End User Id
          description: Optional end-user scope for the operation
      type: object
      title: RetrieveRequest
      description: Base retrieve request model
    DocumentResult:
      properties:
        score:
          type: number
          title: Score
        document_id:
          type: string
          title: Document Id
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        content:
          $ref: '#/components/schemas/DocumentContent'
        additional_metadata:
          additionalProperties: true
          type: object
          title: Additional Metadata
      type: object
      required:
        - score
        - document_id
        - metadata
        - content
        - additional_metadata
      title: DocumentResult
      description: Query result at document level
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    OutputFormat:
      type: string
      enum:
        - base64
        - url
        - text
      title: OutputFormat
      description: Output format for image chunks in retrieval results.
    DocumentContent:
      properties:
        type:
          type: string
          enum:
            - url
            - string
          title: Type
        value:
          type: string
          title: Value
        filename:
          anyOf:
            - type: string
            - type: 'null'
          title: Filename
          description: Filename when type is url
      type: object
      required:
        - type
        - value
      title: DocumentContent
      description: Represents either a URL or content string
    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

````