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

# Add Knowledge Base File

> Adds one file to the knowledge base of the Pearl, next to the files it already has. Send it as `multipart/form-data`, in a field named `file`. Accepted formats: .pdf, .docx and .txt.

The knowledge base of a Pearl holds up to 50 files and 25 MB in total, and up to 1,000,000 characters of text for a voice Pearl or 2,000,000 for a text Pearl. The Pearl must have a published version: the file is added to it.

The file is indexed in the background. It appears in `knowledgeBaseFiles` of Get Pearl Settings once the Pearl can use it, usually within a minute.

The file is added to the published version only. If a new version of the Pearl was already being edited on the platform before this call, that version still has the old file list, and publishing it replaces the published list: the file disappears. To avoid this, add files before you start editing the Pearl on the platform, or add them again once the new version is published.



## OpenAPI

````yaml post /v2/Pearl/{pearlId}/KnowledgeBase
openapi: 3.0.1
info:
  title: NLPearl Client API
  description: A sample API that demonstrates features in the OpenAPI specification
  version: v2
servers:
  - url: https://api.nlpearl.ai
    description: Production Environement
security:
  - bearer_auth: []
  - oauth2_client_credentials: []
tags:
  - name: Pearl
    description: >-
      Manage your Pearls, the AI agents that handle your inbound and outbound
      calls. Create and configure Pearls, retrieve their details and settings,
      run or pause them, list and bulk-export their calls, monitor calls in
      progress, get analytics, and reset a customer's conversation memory.
  - name: Speech
    description: >-
      Turn text into speech with your voices, as a single clip or as a stream,
      and clone new voices from a recording.
paths:
  /v2/Pearl/{pearlId}/KnowledgeBase:
    post:
      tags:
        - Pearl
      summary: Add Knowledge Base File
      description: >-
        Adds one file to the knowledge base of the Pearl, next to the files it
        already has. Send it as `multipart/form-data`, in a field named `file`.
        Accepted formats: .pdf, .docx and .txt.


        The knowledge base of a Pearl holds up to 50 files and 25 MB in total,
        and up to 1,000,000 characters of text for a voice Pearl or 2,000,000
        for a text Pearl. The Pearl must have a published version: the file is
        added to it.


        The file is indexed in the background. It appears in
        `knowledgeBaseFiles` of Get Pearl Settings once the Pearl can use it,
        usually within a minute.


        The file is added to the published version only. If a new version of the
        Pearl was already being edited on the platform before this call, that
        version still has the old file list, and publishing it replaces the
        published list: the file disappears. To avoid this, add files before you
        start editing the Pearl on the platform, or add them again once the new
        version is published.
      parameters:
        - name: pearlId
          in: path
          description: The unique identifier of the Pearl.
          required: true
          schema:
            type: string
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                File:
                  type: string
                  description: "The file to add. Required.\r\n            \r\nConstraints:\r\n- Format: .pdf, .docx or .txt, with text that can be read (a scanned PDF without text is refused).\r\n- File name: up to 200 characters. It is kept and shown in `knowledgeBaseFiles` of Get Pearl Settings.\r\n- The knowledge base of the Pearl holds up to 50 files and 25 MB in total, and up to 1,000,000 characters of text for a voice Pearl or 2,000,000 for a text Pearl."
                  format: binary
            encoding:
              File:
                style: form
      responses:
        '200':
          description: >-
            The file was received and is being indexed. Its `id` is the one to
            use to download or delete it.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/KnowledgeBaseFileApiView'
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeBaseFileApiView'
            text/json:
              schema:
                $ref: '#/components/schemas/KnowledgeBaseFileApiView'
        '400':
          description: >-
            The file was refused (format, size, number of files or characters
            over the limit, no readable text), or the Pearl was not found.
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/ValidationProblemDetails'
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationProblemDetails'
            text/json:
              schema:
                $ref: '#/components/schemas/ValidationProblemDetails'
components:
  schemas:
    KnowledgeBaseFileApiView:
      type: object
      properties:
        id:
          type: string
          description: The id of the file. Use it to download or delete the file.
          nullable: true
        name:
          type: string
          description: The original name of the file, with its extension.
          nullable: true
        charCount:
          type: integer
          description: >-
            The number of characters of text read from the file. It counts
            toward the character limit of the knowledge base (1,000,000 for a
            voice Pearl, 2,000,000 for a text Pearl). May be null for older
            files.
          format: int64
          nullable: true
        byteSize:
          type: integer
          description: >-
            The size of the file in bytes. It counts toward the 25 MB limit of
            the knowledge base. May be null for older files.
          format: int64
          nullable: true
      additionalProperties: false
      description: A file of the knowledge base of a Pearl.
    ValidationProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          nullable: true
      additionalProperties: {}
  securitySchemes:
    bearer_auth:
      type: http
      description: >-
        Specify the authorization token.


        For more information, check out the [Authorization
        Guide](/api-reference/authorization).
      scheme: bearer
    oauth2_client_credentials:
      type: oauth2
      description: >-
        OAuth2 client_credentials grant. Use the Id of an OAuth API key as
        `client_id` and its one-time secret as `client_secret`.
      flows:
        clientCredentials:
          tokenUrl: /oauth/token
          scopes:
            pearls:read: List and view Pearls
            pearls:write: >-
              Create and update Pearls (settings, conversation flows, voices);
              implies pearls:read
            pearls:moderate: Run/pause Pearls and reset customer memory; implies pearls:read
            pearls:analytics: Read Pearl analytics; implies pearls:read
            pearls:leads: Manage and read outbound leads; implies pearls:read
            pearls:calls: >-
              Read calls and recordings, make and delete calls; implies
              pearls:read
            pearls:stream: >-
              Create stream tokens and run calls over a WebSocket; implies
              pearls:read
            account:phone_numbers: >-
              Read account phone numbers and text channels, manage custom VoIP
              numbers, import Twilio numbers and delete phone numbers
            account:users: Read account users
            account:advanced: Manage advanced account settings (blacklist)
            account:billing: Read account information and credit balance
            account:audit_log: Read the audit log
            tts: Synthesise speech and clone voices

````

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