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

# Agent Response

> Returns cited Markdown responses, sourced exclusively from corporate disclosures, in response to natural language queries.
    This endpoint provides AI-generated answers with proper citations to source documents, making it ideal for building Q&A interfaces or research tools.
    
    **Response Behavior:**
    - When relevant documents are found: Returns an AI-generated response with citations in the `sourceMap` field
    - When no relevant documents are found: Returns an informative message explaining why no documents were found, with an empty `sourceMap` field (HTTP 200 status)
    
    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 POST /api/v2/rag/agent-response
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/agent-response:
    post:
      tags:
        - Retrieval Augmented Generation
      summary: Get agent response (v2)
      description: >-
        Returns cited Markdown responses, sourced exclusively from corporate
        disclosures, in response to natural language queries.
            This endpoint provides AI-generated answers with proper citations to source documents, making it ideal for building Q&A interfaces or research tools.
            
            **Response Behavior:**
            - When relevant documents are found: Returns an AI-generated response with citations in the `sourceMap` field
            - When no relevant documents are found: Returns an informative message explaining why no documents were found, with an empty `sourceMap` field (HTTP 200 status)
            
            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: agent_response_api_v2_rag_agent_response_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentRequest'
        required: true
      responses:
        '200':
          description: Agent response generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentResponse'
              examples:
                with_sources:
                  summary: Response with found documents
                  value:
                    content: >-
                      Zscaler's net dollar retention rates for the last two
                      quarters are as follows:


                      - Q3 2025 (trailing 12 months ended April 30, 2025):
                      **114%**  

                      - Q2 2025 (trailing 12 months ended January 31, 2025):
                      **115%**  


                      These figures reflect Zscaler's ability to retain and
                      expand recurring revenue from existing customers over the
                      respective periods [#eaf60040].
                    sourceMap:
                      '#eaf60040':
                        pageNumber: 41
                        excerpt: >-
                          For the trailing 12 months ended January 31, 2025 and
                          2024, the dollar-based net retention rate was 115% and
                          117%, respectively.
                        documentMetadata:
                          id: eaf63939-0da6-4fc7-ba06-adbd46e546a9
                          title: Zscaler Q2 2025 Form 10-Q
                          documentCategory: interim-financial-report
                          date: '2025-03-10'
                          fiscalQuarter: 2
                          fiscalYear: 2025
                          companyName: Zscaler, Inc.
                          tickers:
                            - ZS
                no_sources:
                  summary: Response when no documents found
                  value:
                    content: >-
                      I couldn't find any relevant documents in our database to
                      answer your query. This could be because:


                      - The company or topic you're asking about isn't covered
                      in our document collection

                      - The specific information you're looking for isn't
                      mentioned in the available documents

                      - Your query might need to be more specific or use
                      different terminology


                      Try rephrasing your question or asking about a different
                      company or topic that might be covered in our financial
                      disclosure database.
                    sourceMap: {}
        '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:
    AgentRequest:
      properties:
        query:
          type: string
          minLength: 1
          title: Query
          description: The natural language query
        documentIds:
          anyOf:
            - type: string
            - type: 'null'
          title: Documentids
          description: >-
            Comma-separated string of document file IDs. If provided and
            non-empty, skips document and company selection and goes directly to
            retrieval.
      type: object
      required:
        - query
      title: AgentRequest
      description: Request model for agent queries.
    AgentResponse:
      properties:
        content:
          type: string
          title: Content
          description: The agent's response in markdown format
        sourceMap:
          additionalProperties:
            $ref: '#/components/schemas/Chunk'
          type: object
          title: Sourcemap
          description: >-
            Mapping of citation reference IDs to chunk metadata. Empty when no
            relevant documents are found.
      type: object
      required:
        - content
        - sourceMap
      title: AgentResponse
      description: Response model for agent queries.
    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

````