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

# Upload data sources

> Uploads files or text to an existing knowledge base as data sources. Send them as multipart form data.



## OpenAPI

````yaml POST /api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources
openapi: 3.1.0
info:
  title: WotNot API
  version: 1.0.0
  description: 'WotNot API: Upload data sources.'
servers:
  - url: https://api.wotnot.io
    description: Production
security:
  - bearerAuth: []
paths:
  /api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources:
    post:
      summary: Upload data sources
      description: >-
        Uploads files or text to an existing knowledge base as data sources.
        Send them as multipart form data.
      operationId: addTextFileDataSources
      parameters:
        - name: knowledge_base_id
          in: path
          required: true
          description: The ID of the knowledge base to add the data sources to.
          schema:
            type: string
      requestBody:
        required: true
        description: >-
          Send files and text as multipart form data. Give each form field a
          unique key, and put either a file or text in it.
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file_data_source_name:
                  type: string
                  format: binary
                  description: >-
                    A form field that holds a file. Its value is the location of
                    the file to upload. Give each form field its own unique key.
                text_data_source_name:
                  type: string
                  description: >-
                    A form field that holds text. Its value is the text content
                    to add. Give each form field its own unique key.
                  example: Text content
              additionalProperties:
                description: >-
                  Add more form fields the same way, each with its own unique
                  key. Each one holds either a file or text.
                oneOf:
                  - type: string
                    format: binary
                    title: File
                  - type: string
                    title: Text
      responses:
        '200':
          description: >-
            Returns `ok` set to `true`, the knowledge base's ID, and the new
            data sources grouped by the form field they came from (`q1` and `d2`
            in the example). Each one starts with `status` set to `in-progress`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - knowledge_base_id
                  - ok
                properties:
                  knowledge_base_id:
                    type: integer
                    description: >-
                      The ID of the knowledge base the data sources were added
                      to.
                    example: 876
                  ok:
                    type: boolean
                    description: '`true` when the request worked. Errors return `false`.'
                    example: true
                additionalProperties:
                  type: array
                  description: >-
                    The data sources created from one form field. The key is
                    that form field's name.
                  items:
                    $ref: '#/components/schemas/UploadedSource'
              example:
                q1:
                  - id: 330783
                    type: text
                    name: sample.txt
                    status: in-progress
                    errors: null
                  - id: 330784
                    type: text
                    name: sample2.txt
                    status: in-progress
                    errors: null
                  - id: 330785
                    type: file
                    name: File.pdf
                    status: in-progress
                    errors: null
                d2:
                  - id: 330786
                    type: file
                    name: File2.pdf
                    status: in-progress
                    errors: null
                knowledge_base_id: 876
                ok: true
        '400':
          description: >-
            The knowledge base doesn't belong to your account. Check the
            `knowledge_base_id`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodedError'
              example:
                ok: false
                error: BAD_REQUEST
                code: BAD_REQUEST
                status: 400
                message: Knowledge base does not belong to the account(876)
        '401':
          description: >-
            Your token is invalid, or this feature isn't available on your
            account. Check `error` to see which.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/CodedError'
                    title: Error with code
                  - $ref: '#/components/schemas/Error'
                    title: Error
              examples:
                invalid_jwt:
                  summary: Invalid token
                  value:
                    ok: false
                    error: JWT_SIGNATURE_EXCEPTION
                    message: Invalid JWT token
                    status: 401
                feature:
                  summary: Feature not available
                  value:
                    ok: false
                    error: UNAUTHORIZED_FEATURE
                    code: UNAUTHORIZED_FEATURE
                    status: 401
                    message: Please reach out to support to use this feature
        '404':
          description: >-
            The knowledge base or your account details weren't found. Check
            `error` to see which.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodedError'
              examples:
                kb_not_found:
                  summary: Knowledge base not found
                  value:
                    ok: false
                    error: KNOWLEDGE_BASE_NOT_FOUND
                    message: KnowledgeBase Not Found in DB!
                    code: KNOWLEDGE_BASE_NOT_FOUND
                    status: 404
                account:
                  summary: Account details not found
                  value:
                    ok: false
                    error: ACCOUNT_DETAILS_NOT_FOUND
                    code: ACCOUNT_DETAILS_NOT_FOUND
                    status: 404
                    message: Account Details are Not Found!
components:
  schemas:
    UploadedSource:
      type: object
      description: One data source created from your upload.
      required:
        - id
        - type
        - name
        - status
        - errors
      properties:
        id:
          type: integer
          description: The new data source's ID. Use it to check its training status.
          example: 330783
        type:
          type: string
          description: >-
            Whether it was added as text or as a file, for example `text` or
            `file`.
          example: text
        name:
          type: string
          description: The data source's name, for example the file name `sample.txt`.
          example: sample.txt
        status:
          type: string
          description: >-
            Where the data source is in training: `in-progress`, `trained` or
            `failed`. It starts as `in-progress`. Use Get training status to
            follow it.
          example: in-progress
        errors:
          type:
            - string
            - 'null'
          description: Problems with this data source, if any. `null` when there are none.
          example: null
    CodedError:
      type: object
      description: An error with a short code that says what went wrong.
      required:
        - ok
        - message
        - error
        - code
      properties:
        ok:
          type: boolean
          description: Always `false` when something went wrong.
          example: false
        message:
          type: string
          description: What went wrong, in plain words.
          example: Please reach out to support to use this feature
        error:
          type: string
          description: >-
            A short error code in capital letters, for example
            `UNAUTHORIZED_FEATURE`. Check this in your code to tell errors
            apart.
          example: UNAUTHORIZED_FEATURE
        code:
          type: string
          description: A code for the result. In these examples it matches `error`.
          example: UNAUTHORIZED_FEATURE
        status:
          type: integer
          description: >-
            The HTTP status code, repeated in the body. Not every error includes
            it.
          example: 401
    Error:
      type: object
      description: Returned whenever a request fails.
      required:
        - error
        - ok
        - status
        - message
      properties:
        error:
          type: string
          description: >-
            A short error code in capital letters, for example `UNAUTHORIZED`.
            Check this in your code to tell errors apart.
          example: UNAUTHORIZED
        ok:
          type: boolean
          description: Always `false` when something went wrong.
          example: false
        status:
          type: integer
          description: The HTTP status code, repeated in the body, for example `401`.
          example: 401
        message:
          type: string
          description: What went wrong and how to fix it, in plain words.
          example: Invalid token. Provide the valid account token.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        All of WotNot's APIs use Bearer token authentication. Send your account
        token as `Bearer <token>`. You can find it in Settings > Account
        Settings > Developer. Keep it on your server: anyone who has it can call
        the API as your account.

````

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