ZBrain Documentation
  • ZBrain Documentation
    • Components of ZBrain
    • Getting started with ZBrain
    • 📚Knowledge base
      • How to create a knowledge base?
      • Knowledge source
      • Information schema
      • File summary
      • Automated reasoning
      • Retrieval testing
      • Knowledge base settings
    • 📱APP
      • How to create a new app?
      • How to set up and customize your app?
      • How to access the app reporting dashboard?
    • 🤖ZBrain AI agents
      • Get started with agents on ZBrain
      • Deploying pre-built agents
      • Creating custom AI agents
        • Agent setup
        • Define input sources
        • Define Flow
          • Key elements of a Flow
          • Flow Components
            • Activepieces Platform
            • AITable
            • Airtable
            • Amazon S3
            • Amazon SNS
            • Amazon SQS
            • Amazon Textract
            • Apify
            • Apollo
            • Approval
            • Asana
            • Azure Communication Services
            • Azure Cosmos DB
            • Azure Document Intelligence
            • Azure OpenAI
            • Azure Translation
            • Bannerbear
            • Baserow
            • Beamer
            • Bedrock Claude
            • Bettermode
            • Binance
            • Bing Search
            • Blackbaud
            • Bonjoro
            • Box
            • Brevo
            • Brilliant Directories
            • Bubble
            • CSV
            • Calendly
            • Certopus
            • Clearout
            • Clockodo
            • Code
            • Confluence
            • Connections
            • Constant Contact
            • Contiguity
            • Contentful
            • Customer.io
            • Crypto
            • Databricks
            • Data Mapper
            • Date Helper
            • DeepL
            • Delay
            • Discord
            • Discourse
            • Drip
            • Dropbox
            • Dust
            • Facebook Pages
            • Figma
            • Files Helper
            • Flowise
            • Flowlu
            • Formbricks
            • Frame
            • Freshdesk
            • Freshsales
            • GCloud Pub/Sub
            • GenerateBanners
            • GhostCMS
            • GitHub
            • GitLab
            • Gmail
            • Google Calendar
            • Google Contacts
            • Google Docs
            • Google Drive
            • Google Forms
            • Google Gemini
            • Google My Business
            • Google Search
            • Google Search Console
            • Google Sheets
            • Google Tasks
            • Groq
            • Hacker News
            • Heartbeat
            • HubSpot
            • HTTP
            • Image Helper
            • Inputs
            • Instagram for Business
            • Intercom
            • Invoice Ninja
            • Jira Cloud
            • Jotform
            • Kimai
            • Kizeo Forms
            • LeadConnector
            • Line Bot
            • Linear
            • LinkedIn
            • LinkedIn Actions
            • LLMRails
            • Lusha
            • MailerLite
            • Mailchimp
            • Mautic
            • Microsoft Dynamics 365 Business Central
            • Microsoft Dynamics CRM
            • Microsoft Excel 365
            • Microsoft OneDrive
            • Microsoft Outlook Calendar
            • Microsoft Teams
            • Mixpanel
            • MongoDB
            • Notion
            • Odoo
            • OpenAI
            • OpenRouter
            • Pastebin
            • PDF
            • Postgres
            • PostHog
            • Pushover
            • Qdrant
            • Queue
            • Razorpay
            • Router
            • Salesforce
            • SendGrid
            • ServiceNow
            • SFTP
            • SharePoint
            • Slack
            • SMTP
            • Snowflake
            • SOAP
            • Spotify
            • Stability AI
            • Stable Diffusion Web UI
            • Storage
            • Stripe
            • SurrealDB
            • SurveyMonkey
            • Taskade
            • Telegram Bot
            • Text Helper
            • Trello
            • Twilio
            • Twitter
            • Utilities
            • WhatsApp Business
            • WordPress
            • XML
            • YouTube
            • ZBrain
            • Zendesk
            • ZeroBounce
            • Zoho Books
            • Zoho CRM
            • Zoho Invoice
            • Zoom
          • How to Define a Flow?
          • How to Test Each Step in the Flow?
        • Configure Additional Settings
        • Test and Deploy Agents
        • How to access, monitor, and manage agent performance and tasks?
    • Settings
    • 📖API Tutorials
      • 📚Knowledge base
        • Automated Reasoning
      • 📱APP
      • 🤖Agents
Powered by GitBook
On this page
  • Create knowledge base
  • Get Knowledge bases
  • Get Knowledge base by Id
  • Knowledge base import creation types
  • Using FILE
  • Using WEBSITE url
  • Using API
  • Update Knowledge base
  • Delete Knowledge base
  • Delete Import
  • Get Import Status
  • Create a new chunk in the knowledge base import
  • Update metadata of knowledge base import
  1. ZBrain Documentation
  2. API Tutorials

Knowledge base

Create knowledge base

To create a knowledge base on ZBrain, send a POST request to a given URL with their specific information. They ensure that the payload includes an optional description and the name of the knowledge base while confirming that the necessary headers are correctly incorporated.

  • Request URL: https://app.zbrain.ai:3000/api/knowledge-base

  • Request Method: POST

  • Request Payload:

    1. name: Knowledge Base Name

    2. description: Description (Optional)

    3. retrieval: Retrieval Object (Optional)

    4. searchMethod: Currently we support only 'SEMANTIC_SEARCH' (Optional)

    5. topK: Maximum number of chunks for similar context in App. (Optional)

    6. scoreThreshold: Adjust this value to filter search results based on relevance. (Optional)

    7. scoreThresholdEnabled: Value will be boolean. (Optional)

  • Request Headers:

    1. Authorization: Bearer <<API Key >>

    2. Content-Type: application/json

Parameters

Authorization

description

description about knowledge base

name

name to the knowledge base

  • Sample Request Body Payload:

    {
        "name": "KnowledgeBaseName",
        "description": "description",
         "retrieval": {
             "searchMethod": "SEMANTIC_SEARCH",
              "topK": 50,
              "scoreThresholdEnabled": false,
              "scoreThreshold": 0.1
         }
    }
  • Code snippets:

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://app.zbrain.ai:3000/api/knowledge-base',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "name": "Knowledgebase Name",
    "description": "description"
  })
};

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "https://app.zbrain.ai:3000/api/knowledge-base"

payload = json.dumps({
    "name": "Knowledgebase Name",
    "description": "description",
})
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3000/api/api/knowledge-base' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API Key>' \
--data '{
    "name": "knowledgebase name",
    "description": "description"
}'
  • Sample Response:

    {
        "responseData": {
            "name": "string",
            "description": "string",
            "tenantId": "string",
            "createdBy": "string",
            "_id": "string",
            "addedOn": number,
            "modifiedOn": number
        },
        "message": "Knowledge base created successfully",
        "success": true,
        "responseCode": 200
    }

Get Knowledge bases

Using the provided ZBrain API, users can easily fetch their knowledge base data. By sending a GET request to the given URL and adjusting the 'limit' and 'skip' parameters, users can tailor the amount of data retrieved and its starting point, simplifying access to their specific knowledge base content.

  • Request URL: https://app.zbrain.ai:3000/api/knowledge-bases?limit=10&skip=0

  • Request Method: GET

  • Query strings:

    1. skip: << numeric value >>

    2. limit: << numeric value >>

  • Request Headers:

    1. Authorization: Bearer <<API key>>

    2. Content-Type: application/json

Parameters

Authorization

skip

Number of knowledge bases to skip

limit

Number of knowledge bases to listout

  • Sample Request Query Payload:

    ?limit=10&skip=0
  • Code snippets:

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://app.zbrain.ai:3000/api/knowledge-bases?limit=10&skip=0',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://app.zbrain.ai:3000/api/knowledge-bases?limit=10&skip=0"

payload = {}
headers = {
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3000/api/knowledge-bases?limit=10&skip=0' \
--header 'Authorization: Bearer <API token>'
  • Sample Response:

    {
        "responseData": {
            "data": [
                {
                    "_id": "string",
                    "name": "string",
                    "description": "string",
                    "tenantId": "string",
                    "createdBy": "string",
                    "addedOn": number,
                    "modifiedOn": number,
                    "importsExists": boolean
                }
            ],
            "total": number
        },
        "message": "Information fetched successfully",
        "success": true,
        "responseCode": 200
    }

Get Knowledge base by Id

  • Request URL: https://app.zbrain.ai:3000/api/knowledge-base/<knowledgeBaseId>

  • Request Method: GET

  • Path parameters:

    1. knowledgebaseId : << knowledgebaseId >>

  • Request Headers:

    1. Authorization: Bearer <<API Key >>

    2. Content-Type: application/json

Parameters

Authorization

knowledgeBaseId

  • Sample Path parameters:

    /knowledge-base/<knowledgeBaseId>
  • Code snippets:

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://app.zbrain.ai:3000/api/knowledge-base/<knowledgebaseId>',
  'headers': {
    'Authorization': 'Bearer <API token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://app.zbrain.ai:3000/api/knowledge-base/<knowledgebaseId>"

payload = {}
headers = {
  'Authorization': 'Bearer <API token>'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3000/api/knowledge-base/<knowledgebaseId>' \
--header 'Authorization: Bearer <API token>'
  • Sample Response:

    {
        "responseData": {
            "_id": "string",
            "name": "string",
            "description": "string",
            "tenantId": "string",
            "createdBy": "string",
            "addedOn": number,
            "knowledgeBaseImports": [
                {
                    "title": "string",
                    "summary": "string",
                    "knowledgeBaseId": "string",
                    "importedType": "string",
                    "status": "string",
                    "file": {
                        "url": "string",
                        "path": "string",
                        "bucket": "string"
                    },
                    "document": {
                        "url": "string",
                        "path": "string",
                        "bucket": "string"
                    },
                    "visitedPages": ["string"],
                    "characters": number,
                    "chunksCount": number,
                    "_id": "string",
                    "addedOn": number,
                    "modifiedOn": number
                }
            ]
        },
        "message": "Information fetched successfully",
        "success": true,
        "responseCode": 200
    }

Knowledge base import creation types

On ZBrain, users have multiple options to create a knowledge base by importing information. They can import data from files such as PDF, TXT, CSV, DOCX, or XLSX, website links, or even through APIs. This approach enables users to gather and integrate relevant information into their knowledge base, feeding their AI applications with accurate and domain-specific data from diverse sources.

Using FILE

ZBrain allows users to create a knowledge base by importing files directly into the system using a specified API. Users can seamlessly import file types such as PDF, TXT, CSV, DOCX, or XLSX into their designated knowledge base by initiating a POST request to the provided URL, ensuring that the AI applications have direct access to the required domain-specific information.

  • Request URL: https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=FILE

  • Request Method: POST

  • Query Strings:

    1. knowledgeBaseId: << knowledgeBaseId >>

    2. importType: FILE

  • Request Headers:

    1. Authorization: Bearer <<API Key >>

    2. Content-Type: application/json

  • form data:

    1. file : << select file (Supported formats : PDF, TXT, CSV, DOCX or XLSX)>>

Parameters

Authorization

knowledgeBaseId

importType

method of importing the content

file

in formdata user needs to select the file to be uploaded and these are the supported file formates PDF, TXT, CSV, DOCX or XLSX

  • Sample Request Query Strings:

    ?knowledgeBaseId=<knowledgeBaseId>&importType=FILE
  • Code snippets:

var request = require('request');
var fs = require('fs');
var options = {
  'method': 'POST',
  'url': 'https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=FILE',
  'headers': {
      'Authorization': 'Bearer <API token>'
    },
  formData: {
    'file': {
      'value': fs.createReadStream('</path/to/file>'),
      'options': {
        'filename': '<file name>',
        'contentType': null
      }
    }
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=FILE"

payload = {}
files=[
  ('file',('fileName',open('/path/to/file','rb'),'application/pdf'))
]
headers = {
  'Authorization': 'Bearer <API token>'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
curl --location 'https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=FILE' \
--header 'Authorization: Bearer <API token>' \
--form 'file=@"<path/to/file>"'
  • Sample Response:

    {
        "responseData": [
            {
                "title": "string",
                "summary": "string",
                "knowledgeBaseId": "string",
                "importedType": "string",
                "status": "string",
                "file": {
                    "url": "string",
                    "path": "string",
                    "bucket": "string"
                },
                "document": {
                    "url": "string",
                    "path": "string",
                    "bucket": "string"
                },
                "visitedPages": ["string"],
                "characters": number,
                "chunksCount": number,
                "_id": "string",
                "input": object,
                "error": object,
                "addedOn": number,
                "modifiedOn": number,
                "charactersLimit": number
            }
        ],
        "message": "Knowledge base import added successfully",
        "success": true,
        "responseCode": 200
    }

Using WEBSITE url

When one seeks to construct a Zbrain knowledge base using a website, they must employ a certain web address or API. This process involves providing necessary details such as the knowledge base's identification, the import type (in this instance, a website), and the desired number of pages for indexing. The interface allows indexing of up to 50 pages at a time, while the API supports large-scale indexing for greater flexibility. Including the website URL from which the knowledge base will be created is crucial. Additionally, they must authenticate their request with their API key.

  • Request URL: https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE

  • Request Method: POST

  • Query Strings:

    1. knowledgeBaseId: << knowledgeBaseId >>

    2. importType: WEBSITE

  • Request Payload:

    1. numberOfPages: << No.of pages to index>>

    2. websiteUrl:<< URL >>

  • Request Headers:

    1. Authorization: Bearer <<API Key>>

    2. Content-Type: application/json

Parameters

Authorization

knowledgeBaseId

importType

method of importing the content

numberOfPages

no.of pages to index

websiteUrl

URL of the website

  • Sample Request Body Payload:

    {
        "numberOfPages": 4,
        "websiteUrl": "https://www.leewayhertz.com"
    }

  • Sample Request Query Payload:

    ?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE
  • Code snippets:

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "numberOfPages": <No.of pages to index>,
    "websiteUrl": "<url>"
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE"

payload = json.dumps({
  "numberOfPages": <No.of pages to index>,
  "websiteUrl": "<url>"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3003/api/knowledge-base-import?knowledgeBaseId=<knowledgeBaseId>&importType=WEBSITE' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API token>' \
--data '{
    "numberOfPages":<No.of pages to index>,
    "websiteUrl":"<url>"
}'
  • Sample Response:

    {
        "responseData": {
            "title": "string",
            "summary": "string",
            "knowledgeBaseId": "string",
            "importedType": "string",
            "status": "string",
            "file": {
                "url": "string",
                "path": "string",
                "bucket": "string"
            },
            "document": {
                "url": "string",
                "path": "string",
                "bucket": "string"
            },
            "visitedPages": ["string"],
            "characters": number,
            "chunksCount": number,
            "_id": "string",
            "input": object,
            "error": object,
            "addedOn": number,
            "modifiedOn": number,
            "charactersLimit": number
        },
        "message": "Knowledge base import added successfully",
        "success": true,
        "responseCode": 200
    }

Using API

When someone aims to construct a Zbrain knowledge base utilizing an API, they send specific data to a Zbrain web address. The information comprises the type of activity (API), a title for their data, and the data content itself, which should span at least 100 characters. They also need to include their API key for security purposes.

  • Request URL: https://app.zbrain.ai:3003/api/knowledge-base-import-by-api?importType=API

  • Request Method: POST

  • Query Strings:

    1. importType: API

  • Request Headers:

    1. Authorization: Bearer <<api key>>

    2. Content-Type: application/json

  • Request Payload:

    1. title: <Enter your file name>

    2. content: <<Enter your content not less than 100 characters>>

    3. knowledgeBaseId : << knowledgeBaseId >>

Parameters

Authorization

importType

method of importing the content

title

title of the file

content

the content that will be uploaded to knowledge base and it should not be less than 100 characters

knowledgeBaseId

  • Sample Request Body Payload:

    {
        "title": "fileName",
        "content": "file content",
        "knowledgeBaseId": "knowledgeBaseId"
    }

Note: If knowledgeBaseId is empty, new knowledge base will be created. Otherwise, specified knowledge base will get updated.

  • Sample Request Query Payload:

    ?importType=API

  • Code snippets:

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://app.zbrain.ai:3003/api/knowledge-base-import-by-api?importType=API',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "title": "<name>",
    "content": "<content>",
    "knowledgeBaseId": "<knowledgeBaseId>"
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "https://app.zbrain.ai:3003/api/knowledge-base-import-by-api?importType=API"

payload = json.dumps({
  "title": "<name>",
  "content": "<content>",
  "knowledgeBaseId": "<knowledgeBaseId>"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3003/api/knowledge-base-import-by-api?importType=API' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API token>' \
--data '{
    "title": "<name>",
    "content": "<content>",
    "knowledgeBaseId" :"<knowledgeBaseId>"
}'
  • Sample Response:

    {
      "responseData": {
        "title": "string",
        "summary": "string",
        "knowledgeBaseId": "string",
        "importedType": "string",
        "status": "string",
        "file": {
          "url": "string",
          "path": "string",
          "bucket": "string"
        },
        "document": {
          "url": "string",
          "path": "string",
          "bucket": "string"
        },
        "visitedPages": ["string"],
        "characters": number,
        "chunksCount": number,
        "_id": "string",
        "input": object,
        "error": object,
        "addedOn": number,
        "modifiedOn": number,
        "charactersLimit": number
      },
      "message": "Knowledge base import added successfully",
      "success": true,
      "responseCode": 200
    }

Update Knowledge base

When a user wishes to update an existing knowledge base in Zbrain, they can utilize the following specific API, which sends a PUT request, along with their API key, to modify the knowledge base's name and description. Providing the correct knowledge base ID is important to ensure the updates are applied to the desired base.

  • Request URL:https://app.zbrain.ai:3000/api/knowledge-base

  • Request Method: PUT

  • Request Payload:

    1. description: << Enter new description (optional)>>

    2. knowledgeBaseId: << knowledgeBaseId >>

    3. name: << Enter new knowledge base name >>

    4. retrieval: Retrieval Object (Optional)

    5. searchMethod: Currently we support only 'SEMANTIC_SEARCH' (Optional)

    6. topK: Maximum number of chunks for similar context in App. (Optional)

    7. scoreThreshold: Adjust this value to filter search results based on relevance. (Optional)

    8. scoreThresholdEnabled: Value will be boolean. (Optional)

  • Request Headers:

    1. Authorization: Bearer <<API Key>>

    2. Content-Type: application/json

Parameters

Authorization

knowledgeBaseId

name

knowledge base name

description

description about knowledge base

  • Sample Request Body Payload:

{
    "knowledgeBaseId": "knowledgeBaseId",
    "name": "sample name",
    "description": "description",
    "retrieval": {
         "searchMethod": "SEMANTIC_SEARCH",
          "topK": 50,
          "scoreThresholdEnabled": false,
          "scoreThreshold": 0.1
    }
}
  • Code snippets:

var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://app.zbrain.ai:3000/api/knowledge-base',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "name": "<name>",
    "description": "<description>",
    "knowledgeBaseId": "<knowledgeBaseId>"
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "https://app.zbrain.ai:3000/api/knowledge-base"

payload = json.dumps({
    "description": "<description>",
    "knowledgeBaseId": "<knowledgeBaseId>",
    "name": "<name>"
  })
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
curl --location --request PUT 'https://app.zbrain.ai:3000/api/knowledge-base' \
--header 'Content-Type: application/json' \
--header 'Authorization': 'Bearer <API token>' \
--data '{
    "description": "<description>",
    "knowledgeBaseId": "<knowledgeBaseId>",
    "name": "<name>"
 }'
  • Sample Response:

    {
        "responseData": {
            "name": "string",
            "description": "string",
            "tenantId": "string",
            "createdBy": "string",
            "_id": "string",
            "addedOn": number,
            "modifiedOn": number
        },
        "message": "Information added successfully",
        "success": true,
        "responseCode": 200
    }

Delete Knowledge base

If a user wishes to delete a specific knowledge base in Zbrain, the following API is used, which sends a DELETE request to the designated URL, including the knowledge base's unique ID in the path. The request must also contain its API key in the header for authorization.

  • Request URL: https://app.zbrain.ai:3000/api/knowledge-base/<knowledgebaseId>

  • Request Method: DELETE

  • Path parameters:

    1. knowledgebaseId : << knowledgebaseId >>

  • Request Headers:

    1. Authorization: Bearer <<API Key>>

    2. Content-Type: application/json

Parameters

Authorization

knowledgebaseId

  • Code snippets:

var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://app.zbrain.ai:3000/api/knowledge-base/<knowledgeBaseId>',
  'headers': {
    'Authorization': 'Bearer <API token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://app.zbrain.ai:3000/api/knowledge-base/<knowledgeBaseId>"

payload = {}
headers = {
  'Authorization': 'Bearer <API token>'
}

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)
curl --location --request DELETE 'https://app.zbrain.ai:3000/api/knowledge-base/<knowledgeBaseId>' \
--header 'Authorization': 'Bearer <API token>'
  • Sample Response:

    {
        "responseData": "Knowledge base deleted successfully",
        "message": "Knowledge base deleted successfully",
        "success": true,
        "responseCode": 200
    }

Delete Import

If a user wishes to delete a specific knowledge base import in Zbrain, the following API is used, which sends a DELETE request to the designated URL, including the knowledge base import's unique ID in the body. The request must also contain its API key in the header for authorization.

  • Request URL: https://app.zbrain.ai:3000/api/knowledge-base-import

  • Request Method: DELETE

  • Request Payload:

    1. ids: << Array of knowledgeBaseImport Id's>>

  • Request Headers:

    1. Authorization: Bearer <<API Key>>

    2. Content-Type: application/json

Parameters

Authorization

ids

  • Sample Request Body Payload:

    {
        "ids": [
            "knowledgeBaseImportId"
        ]
    }
  • Code snippets:

var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://app.zbrain.ai:3000/api/knowledge-base-import',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "ids": [
      "<knowledgeBaseId>",
      "<knowledgeBaseId>"
    ]
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "https://app.zbrain.ai:3000/api/knowledge-base-import"

payload = json.dumps({
    "ids": [
      "<knowledgeBaseId>",
      "<knowledgeBaseId>"
    ]
  })
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <API token>'
}

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)
curl --location --request DELETE 'https://app.zbrain.ai:3000/api/knowledge-base-import' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API token>' \
--data '{
    "ids":["<knowledgeBaseId>","<knowledgeBaseId>"]
}'
  • Sample Response:

    {
        "responseData": "Deleted successfully",
        "message": "Knowledge base import deleted successfully",
        "success": true,
        "responseCode": 200
    }

Get Import Status

To get the status of the imports, send a GET request to the following URL with the specified query parameters. Ensure that the query payload includes the knowledge base import IDs and tenant IDs.

  • Request URL: https://app.zbrain.ai:3003/v2/api/import

  • Request Method: GET

  • Query strings:

    1. kbImportIds: << A comma-separated list of identifiers for the knowledge base import jobs you want to check the status of >>

  • Request Headers:

    1. Authorization: Bearer <<API key>>

    2. Content-Type: application/json

Parameters

Authorization

kbImportIds

Knowledge Base Import Ids

  • Code snippets:

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://app.zbrain.ai:3003/v2/api/import?kbImportIds=<id1,id2>',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://app.zbrain.ai:3003/v2/api/import?kbImportIds=<id1,id2>"

payload = {}
headers = {
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3003/v2/api/import?kbImportIds=<id1,id2>' \
--header 'Authorization: Bearer <API token>'
  • Sample Response:

{
    "responseData": {
        "preview": [
            {
                "content": "",
                "metaData": {
                    "fileName": "",
                    "file": "",
                    "id": 0,
                    "hash": "",
                    "words": 0,
                    "isActive": true
                }
            }
        ],
        "status": "STAGED",
        "data": [
            {
                "title": "",
                "characters": 0,
                "chunksCount": 0,
                "paragraphsCount": 0,
                "avgParagraphsCount": 0,
                "chunkingRules": {
                    "mode": "",
                    "rules": {}
                },
                "status": "STAGED",
                "addedOn": 1714985786550
            },
        ]
    },
    "message": "",
    "success": true,
    "responseCode": 200
}

Create a new chunk in the knowledge base import

To add a chunk to the knowledge base import, send a POST request to the given URL with the chunk's specific information. Ensure that the payload includes a knowledge base import ID, the content you want to add to the chunk while confirming that the necessary headers are correctly incorporated.

  • Request URL: https://app.zbrain.ai:3003/v2/api/knowledge-base-import/chunk

  • Request Method: POST

  • Request Payload:

    • knowledgeBaseImportId: << Enter knowledge base import's _id, in which you want to add the chunk>>

    • content: << Add the text content that you want to add in the chunk >>

  • Request Headers:

    • Authorization: Bearer <<API Key>>

    • Content-Type: application/json

  • Sample Request Body Payload:

{  
    "knowledgeBaseImportId": "",
    "content": ""
}

Code Snippets:

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://app.zbrain.ai:3003/v2/api/knowledge-base-import/chunk',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({  
    "knowledgeBaseImportId": "",
    "content": ""
  })
};

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "https://app.zbrain.ai:3003/v2/api/knowledge-base-import/chunk"

payload = json.dumps({  
    "knowledgeBaseImportId": "",
    "content": ""
})
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3003/v2/api/knowledge-base-import/chunk' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API Key>' \
--data '{  
    "knowledgeBaseImportId": "",
    "content": ""
}'
  • Sample Response:

{
    "responseData": {
        "tenantId": "",
        "addedBy": "",
        "kbImportId": "",
        "content": "",
        "embeddings": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        }
    },
    "message": "Knowledge base import chunk added successfully",
    "success": true,
    "responseCode": 200
}

Update metadata of knowledge base import

To update the metadata of a knowledge base import, send a PATCH request to the following URL with the specified information. Ensure that the payload includes the knowledge base import ID, metadata details, and the isEnabled status.

  • Request URL: https://app.zbrain.ai:3000/v2/api/knowledge-base-import

  • Request Method: PATCH

  • Request Headers:

    • Authorization: Bearer <<API Key>>

    • Content-Type: application/json

  • Request Payload:

    • knowledgeBaseImportId: << Enter the unique identifier of the knowledge base import you want to update >>

    • metadata: << An object containing the metadata fields you want to modify >>

    • title: << The title of the knowledge base import >>

    • author: << The author of the content within the import >>

    • documentType: << The type of document(s) included in the import >>

    • departmentTeam: << The department or team associated with the import content >>

    • isEnabled: << Set it to true or false to indicate whether the import should be included in retrieval operations >>

  • Sample Request Body Payload:

{
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
}
  • Code Snippets:

var request = require('request');
var options = {
  'method': 'PATCH',
  'url': 'https://app.zbrain.ai:3000/v2/api/knowledge-base-import',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  },
  body: JSON.stringify({
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
})
};

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests
import json

url = "https://app.zbrain.ai:3000/v2/api/knowledge-base-import"

payload = json.dumps({
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
})
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <API token>'
  }

response = requests.request("PATCH", url, headers=headers, data=payload)

print(response.text)
curl --location 'https://app.zbrain.ai:3000/v2/api/knowledge-base-import' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API Key>' \
--data '{
    "knowledgeBaseImportId": "",
    "metadata": {
        "title": "",
        "author": "",
        "documentType": "",
        "departmentTeam": ""
    },
    "isEnabled": false
}'\
--request PATCH
  • Sample Response:

{
    "responseData": {
        "chunkingRules": {
            "mode": "AUTOMATIC"
        },
        "metadata": {
            "documentType": "",
            "title": " ",
            "author": "",
            "departmentTeam": "",
            "creationDate": 0,
            "modifiedDate": 0
        },
        "title": "",
        "summary": "",
        "knowledgeBaseId": "",
        "importedType": "",
        "status": "",
        "autoEmbedding": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        },
        "embedding": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        },
        "customEmbedding": {
            "url": "",
            "path": ""
        },
        "file": {
            "url": "",
            "path": "",
            "bucket": "",
            "storageProvider": ""
        },
        "document": {
            "url": "",
            "path": ",
            "bucket": "",
            "storageProvider": ""
        },
        "docHash": "",
        "visitedPages": [],
        "retrievalCount": 0,
        "timeTaken": 0,
        "tokens": 0,
        "characters": 4871,
        "chunksCount": 13,
        "paragraphsCount": 0,
        "avgParagraphsLength": 0,
        "wordsCount": 0,
        "isEnabled": true,
        "historicalDocuments": [],
        "hypotheticalVectorIds": [],
        "smallVectorIds": [],
        "summaryVectorIds": [],
        "faissVectorIds": [],
        "pineconeVectors": 0,
        "pineconeIndexId": "",
        "parentKbImportId": "",
        "currentVersion": 1,
        "isDeleted": false,
        "isActive": true,
        "_id": "",
        "addedOn": 1715145815686,
        "modifiedOn": 1718171976745,
        "__v": 0
    },
    "message": "Information fetched successfully",
    "success": true,
    "responseCode": 200
}
PreviousAPI TutorialsNextAutomated Reasoning

Last updated 1 month ago

Bearer API-Key (get it from settings > profile from )

Bearer API-Key (get it from settings > profile from )

Bearer API-Key (get it from settings > profile from )

unique id (_id) of knowledge base (get it from the API)

Bearer API-Key (get it from settings > profile from )

unique id (_id) of knowledge base to where the file to be imported (get it from the Api)

Bearer API-Key (get it from settings > profile from )

unique id (_id) of knowledge base to where the file to be imported (get it from the Api)

Bearer API-Key (get it from settings > profile from )

unique id (_id) of knowledge base to where the file to be imported (get it from the Api)

Bearer API-Key (get it from settings > profile from )

unique id (_id) of knowledge base to where the file to be imported (get it from the Api)

Bearer API-Key (get it from settings > profile from )

unique id (_id) of knowledge base to where the file to be imported (get it from the Api) (send this on path parameter)

Bearer API-Key (get it from settings > profile from )

Array of knowledgeBaseImport unique Id's to be deleted, get these id's from the response of

Bearer API-Key (get it from settings > profile from )

📖
📚
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
https://app.zbrain.ai/settings/profile
Get knowledge bases
Get knowledge bases
Get knowledge bases
Get knowledge bases
Get knowledge bases
Get knowledge bases
get knowledge base by id