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

# Create Knowledge Base

> Create a knowledge base for agent context.

Changes state - verify before retry
A knowledge base is a named collection of your own content that an agent can draw on to answer questions accurately. Create one knowledge base per topic or product area, then attach it to the agents that should use it.

## When to use this

Use this endpoint to spin up a knowledge base before uploading documents to it - for example, one knowledge base per product line, or one per customer in a multi-tenant setup. The name must be unique within your workspace: a duplicate returns `409 Conflict`. It may be up to 150 characters and must not be blank; a blank name or a longer one returns `400 Bad Request`.

## Minimal request

```json theme={null}
{
  "name": "Loan qualification FAQ"
}
```

## Verify and continue

Store the returned `kb_` ID, list knowledge bases to confirm the record, add content with [Upload Knowledge Base Document](https://dialnexa.com/docs/api-reference/v1/knowledge-base/upload-document.md) (or in the dashboard), then attach the ID to an agent version with `knowledge_base_ids`. If creation times out, list by name before retrying so you do not create a duplicate.


## OpenAPI

````yaml POST /v1/knowledge-base
openapi: 3.0.0
info:
  title: DialNexa API
  description: Public `/v1` REST API for the DialNexa voice AI platform.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: Agents
  - name: Batch Calls
  - name: Calls
  - name: Knowledge Base
  - name: Languages
  - name: LLMs
  - name: Phone Numbers
  - name: Organization Folders
  - name: Transcribers
  - name: Webhooks
  - name: Voices
  - name: Workflows
  - name: Workflow Leads
  - name: Authentication
  - name: Agent Builder
  - name: Agent Evaluations
paths:
  /v1/knowledge-base:
    post:
      tags:
        - Knowledge Base
      summary: Create Knowledge Base
      description: >-
        Creates an empty knowledge base that can be populated and attached to
        agent versions.
      operationId: createKnowledgeBase
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKnowledgeBaseRequest'
            examples:
              request:
                summary: Request example
                value:
                  name: Product Documentation
      responses:
        '201':
          description: Knowledge base created successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                  - statusCode
                  - message
                  - data
                  - timestamp
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  error:
                    type: boolean
                    enum:
                      - false
                  statusCode:
                    type: integer
                    example: 201
                  message:
                    type: string
                    example: Success
                  data:
                    $ref: '#/components/schemas/KnowledgeBase'
                  timestamp:
                    type: string
                    format: date-time
              examples:
                success:
                  summary: Successful response
                  value:
                    success: true
                    error: false
                    statusCode: 201
                    message: Success
                    data:
                      id: kb_abc123
                      name: Loan FAQ
                      org_id: o14XKPP84rt22g
                      is_deleted: false
                      created_at: '2026-07-03T10:30:00.000Z'
                      updated_at: '2026-07-03T10:45:00.000Z'
                    timestamp: '2026-09-07T06:00:00.000Z'
        '400':
          description: >-
            Invalid request body, for example a blank name or one over 150
            characters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 400 Bad Request
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: name must not be blank
                    errors:
                      - name must not be blank
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 401 Unauthorized
                  value:
                    statusCode: 401
                    error: true
                    success: false
                    data: []
                    message: Invalid API key
                    errors: []
        '409':
          description: Knowledge base name already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 409 Conflict
                  value:
                    statusCode: 409
                    error: true
                    success: false
                    data: []
                    message: >-
                      A knowledge base named "Support FAQ" already exists in
                      this workspace
                    errors: []
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 500 Internal Server Error
                  value:
                    statusCode: 500
                    error: true
                    success: false
                    data: []
                    message: Internal server error
                    errors: []
      security:
        - bearer: []
components:
  schemas:
    CreateKnowledgeBaseRequest:
      type: object
      properties:
        name:
          type: string
          maxLength: 150
          pattern: \S
          description: Knowledge base name, at most 150 characters and not blank.
          example: Product Documentation
      required:
        - name
    KnowledgeBase:
      type: object
      properties:
        id:
          type: string
          example: kb_abc123
          description: Signed knowledge base ID.
        name:
          type: string
          example: Loan FAQ
          maxLength: 150
        org_id:
          type: string
          example: o14XKPP84rt22g
          description: Owning organization.
        is_deleted:
          type: boolean
          description: Whether the knowledge base has been deleted.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - name
    ErrorResponse:
      type: object
      description: Error body on endpoints without response filtering.
      properties:
        statusCode:
          type: integer
          example: 404
        error:
          type: boolean
          enum:
            - true
        success:
          type: boolean
          enum:
            - false
        data:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                  description: Machine-readable refusal code.
            - type: array
              items: {}
          description: >-
            For a coded refusal, an object with code and the details listed for
            that code. Otherwise an empty array.
        message:
          type: string
        errors:
          type: array
          items:
            type: string
          description: Validation messages for a 400. Empty for other errors.
        validation_errors:
          type: array
          description: >-
            Present when uploaded rows fail number validation (batch and
            workflow lead uploads): one group per distinct error.
          items:
            type: object
            properties:
              error:
                type: string
              rows:
                type: array
                items:
                  type: integer
                description: Row numbers with this error.
              phone_numbers:
                type: array
                items:
                  type: string
        invalid_row_count:
          type: integer
          description: 'Present with validation_errors: how many rows failed.'
      required:
        - statusCode
        - error
        - success
        - data
        - message
        - errors
  securitySchemes:
    bearer:
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.