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

# Query Knowledge Base

> Query Knowledge Base.

### Authorizations

<ParamField header="X-Api-Key" type="string" required>
  Your Agni API key used to authenticate the request. Pass it in the `X-Api-Key` header. Find or rotate it from your Ravan AI account settings.
</ParamField>

***

### Body

<ParamField body="org_id" type="string" required>
  The organization ID that owns the resource. Use the organization ID from your Agni account.
</ParamField>

<ParamField body="kb_id" type="string" required>
  The unique knowledge base ID. Use the ID returned by the knowledge base create or list endpoint.
</ParamField>

<ParamField body="query" type="string" required>
  The natural-language question or search query to run against the knowledge base.
</ParamField>

***

### Response

<ResponseField name="success" type="boolean">
  Whether the request succeeded.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable status message.
</ResponseField>

<ResponseField name="data" type="object">
  Returned data.

  <Expandable title="data">
    <ResponseField name="results" type="array">
      Array of matching results

      <Expandable title="result item">
        <ResponseField name="text" type="string">
          Matched text chunk
        </ResponseField>

        <ResponseField name="score" type="number">
          Relevance score
        </ResponseField>

        <ResponseField name="doc_id" type="string">
          Source document ID
        </ResponseField>

        <ResponseField name="metadata" type="object">
          Chunk metadata
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>


## OpenAPI

````yaml POST /api/v1/rag/query
openapi: 3.0.1
info:
  title: Agni API
  version: 1.0.0
  description: >-
    Agni API for managing agents, tools, widget settings, telephony, and
    integrations.
servers:
  - url: https://api.ravan.ai
security:
  - X-Api-Key: []
tags:
  - name: AgentService
  - name: AgentToolService
  - name: WidgetSettingsService
  - name: PhoneService
  - name: AppointmentService
  - name: GHLService
  - name: CalComService
  - name: CampaignService
  - name: ContactService
  - name: CallingService
  - name: RAGService
  - name: ModelService
  - name: HealthService
paths:
  /api/v1/rag/query:
    post:
      tags:
        - RAGService
      summary: Query Knowledge Base
      operationId: QueryKnowledgeBase
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryKnowledgeBaseRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryKnowledgeBaseResponse'
components:
  schemas:
    QueryKnowledgeBaseRequest:
      type: object
      required:
        - org_id
        - kb_id
        - query
      properties:
        org_id:
          type: string
          description: Organization ID
        kb_id:
          type: string
          description: Knowledge Base ID
        query:
          type: string
          description: Search query
    QueryKnowledgeBaseResponse:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
        data:
          type: object
          properties:
            results:
              type: array
              items:
                type: object
                properties:
                  text:
                    type: string
                    description: Matched text chunk
                  score:
                    type: number
                    description: Relevance score
                  doc_id:
                    type: string
                    description: Source document ID
                  metadata:
                    type: object
                    description: Chunk metadata
  securitySchemes:
    X-Api-Key:
      type: apiKey
      in: header
      name: X-Api-Key

````