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

# Search KB

> <strong>(Convocore agents only)</strong> Searches an agent knowledge base with either a text query or a precomputed embedding vector. This route must use the new V3 [endpoints](/api-reference/v3/intro).

## Example: Search with Text

```json theme={null}
{
  "searchQuery": "refund policy for annual subscriptions",
  "max_chunks": 3,
  "with_payload": true
}
```

## Example: Search with a Vector

```json theme={null}
{
  "vector": [0.12, -0.03, 0.91],
  "vectorDb": "postgres",
  "max_chunks": 5,
  "similarity_threshold": 0.2
}
```

<Tip>
  Use `searchQuery` for most requests. The API will create the embedding for you and search the agent KB automatically.
</Tip>

<Note>
  Results are chunk-level matches, so a single source document may appear multiple times if several chunks are relevant.
</Note>


## OpenAPI

````yaml POST /agents/{agentId}/kb/search
openapi: 3.0.3
info:
  title: Convocore OpenAPI
  description: Full API reference for Convocore
  version: 1.0.4
servers:
  - url: https://eu-gcp-api.vg-stuff.com/v3
    description: EU Node.js API server
  - url: https://na-gcp-api.vg-stuff.com/v3
    description: NA Node.js API server
security: []
paths:
  /agents/{agentId}/kb/search:
    post:
      tags:
        - KB
      summary: Search Agent Knowledge Base
      description: >-
        Search an agent knowledge base using a text query or a precomputed
        vector
      operationId: kbRouter-searchAgentKB
      parameters:
        - name: agentId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                vector:
                  type: array
                  items:
                    type: number
                searchQuery:
                  type: string
                  minLength: 1
                vectorDb:
                  type: string
                  enum:
                    - firebase
                    - postgres
                  default: postgres
                defaultDimension:
                  type: integer
                  exclusiveMinimum: true
                  minimum: 0
                  default: 1536
                max_chunks:
                  type: integer
                  minimum: 1
                  maximum: 100
                  default: 5
                similarity_threshold:
                  type: number
                  minimum: 0
                  maximum: 1
                  default: 0
                with_payload:
                  type: boolean
                  default: true
                with_vector:
                  type: boolean
                  default: false
              additionalProperties: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        namespace:
                          type: string
                        payload:
                          type: object
                          properties:
                            text:
                              type: string
                            chunk_index:
                              type: number
                            doc_id:
                              type: string
                            doc_name:
                              type: string
                            url:
                              type: string
                            urlDescription:
                              type: string
                          additionalProperties: true
                        vector:
                          type: array
                          items:
                            type: number
                        tags:
                          type: array
                          items:
                            type: string
                        similarity:
                          type: number
                      required:
                        - id
                      additionalProperties: false
                required:
                  - success
                  - message
                  - data
                additionalProperties: false
        default:
          $ref: '#/components/responses/error'
      security:
        - Authorization: []
components:
  responses:
    error:
      description: Error response
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
              code:
                type: string
              issues:
                type: array
                items:
                  type: object
                  properties:
                    message:
                      type: string
                  required:
                    - message
                  additionalProperties: false
            required:
              - message
              - code
            additionalProperties: false
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer

````