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

# Chunk Retrieval

> Search for relevant document chunks based on a query. Under the hood, Captide's RAG system uses a combination of LLMs and vector databases to find the most relevant chunks of text from corporate disclosures that are most relevant to the query.
    This endpoint returns chunks of text from corporate disclosures that are most relevant to the query, along with metadata about their source documents. This endpoint is useful for building search interfaces or retrieving specific content from documents.
    
    This v2 endpoint supports newer document categories in source mappings (e.g., earnings-presentation, investor-event-presentation, shareholder-meeting-circular, etc.). Agent response quality is exactly the same compared to v1.



## OpenAPI

````yaml GET /api/v2/rag/chunks
openapi: 3.1.0
info:
  title: Captide REST API
  description: >-
    API for accessing financial disclosures and AI-powered financial document
    analysis.
  version: 0.3.13
servers:
  - url: https://rest-api.captide.co
    description: Prod server
security: []
paths:
  /api/v2/rag/chunks:
    get:
      tags:
        - Retrieval Augmented Generation
      summary: Search document chunks (v2)
      description: >-
        Search for relevant document chunks based on a query. Under the hood,
        Captide's RAG system uses a combination of LLMs and vector databases to
        find the most relevant chunks of text from corporate disclosures that
        are most relevant to the query.
            This endpoint returns chunks of text from corporate disclosures that are most relevant to the query, along with metadata about their source documents. This endpoint is useful for building search interfaces or retrieving specific content from documents.
            
            This v2 endpoint supports newer document categories in source mappings (e.g., earnings-presentation, investor-event-presentation, shareholder-meeting-circular, etc.). Agent response quality is exactly the same compared to v1.
      operationId: search_chunks_api_v2_rag_chunks_get
      parameters:
        - name: query
          in: query
          required: true
          schema:
            type: string
            minLength: 1
            description: The natural language query
            examples:
              - What is Zscaler's net dollar retention rate?
            title: Query
          description: The natural language query
        - name: document_ids
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Comma-separated string of document file IDs. If provided and
              non-empty, skips document and company selection and goes directly
              to retrieval.
            title: Document Ids
          description: >-
            Comma-separated string of document file IDs. If provided and
            non-empty, skips document and company selection and goes directly to
            retrieval.
      responses:
        '200':
          description: Chunks found successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChunksResponse'
              example:
                relevantChunks:
                  - pageNumber: 2
                    documentMetadata:
                      id: 2dfd0c2a-fb6d-486a-ad62-3b1830eb30bf
                      title: ASML 2024 Annual Report
                      documentCategory: annual-financial-report
                      date: '2024-12-31'
                      fiscalQuarter: 4
                      fiscalYear: 2024
                      companyName: ASML HOLDING NV
                      tickers:
                        - ASML
                        - ASML.AS
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - APIKeyHeader: []
components:
  schemas:
    ChunksResponse:
      properties:
        relevantChunks:
          items:
            $ref: '#/components/schemas/Chunk'
          type: array
          title: Relevantchunks
          description: List of relevant document chunks
      type: object
      required:
        - relevantChunks
      title: ChunksResponse
      description: Response model for chunk search results.
    ErrorResponse:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: ErrorResponse
      description: Standard error response model for all API endpoints.
    Chunk:
      properties:
        content:
          type: string
          title: Content
          description: Text content of the chunk
        pageNumber:
          type: integer
          title: Pagenumber
          description: Page number in the document
        excerpt:
          anyOf:
            - type: string
            - type: 'null'
          title: Excerpt
          description: >-
            Specific part of the chunk that the agent used to answer the user's
            question. Used for source linking and highlighting.
        documentMetadata:
          $ref: '#/components/schemas/SourceDocument'
          description: Metadata for the chunk's document
      type: object
      required:
        - content
        - pageNumber
        - documentMetadata
      title: Chunk
      description: A chunk of document content with metadata.
    SourceDocument:
      properties:
        id:
          type: string
          title: Id
          description: Unique document ID
        title:
          type: string
          title: Title
          description: Document title
        documentCategory:
          type: string
          title: Documentcategory
          description: >-
            Document categories. For detailed category descriptions, please
            refer to [this page](/coverage)
        formType:
          anyOf:
            - type: string
            - type: 'null'
          title: Formtype
          description: >-
            Document SEC form type (only applicable if the document is an SEC
            filing)
        date:
          type: string
          title: Date
          description: >-
            Date the document relates to (e.g., the press release date for a
            current report, or the fiscal period end date for annual and interim
            reports)
        fiscalQuarter:
          anyOf:
            - type: integer
            - type: 'null'
          title: Fiscalquarter
          description: Fiscal quarter the document relates to (from 1 to 4)
        fiscalYear:
          anyOf:
            - type: integer
            - type: 'null'
          title: Fiscalyear
          description: Fiscal year the document relates to (e.g., 2024)
        companyName:
          type: string
          title: Companyname
          description: Name of the company filing the document
        tickers:
          items:
            type: string
          type: array
          title: Tickers
          description: Tickers of the company filing the document
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Metadata for the document
      type: object
      required:
        - id
        - title
        - documentCategory
        - date
        - companyName
        - tickers
      title: SourceDocument
      description: Source document metadata model.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````