Skip to main content

How to Create a Knowledge Base

If you need to create a Knowledge Base, you can do so by using the Snack Prompt API through the appropriate endpoint for creating elementals. To perform this action, you must be authenticated with your API Key.


Authenticating with Your API Key

To authenticate your API requests, include your API Key in the header:

x-api-key: YOUR_API_KEY
How to Generate an API Key

To generate an API Key, follow these steps:

  1. Log in to your Snack Prompt account.
  2. Navigate to the API Keys page: https://snackprompt.com/api-keys.
  3. Click the Create New API Key button.
  4. Provide a name for your Key to easily identify it later.
  5. Once created, you can:
    • Copy the Key for immediate use.
    • Delete the Key when it's no longer needed.
Note: API Keys do not have an expiration date and will remain valid until deleted.
How to generate an API Key

How to Create a Knowledge Base

To create a Knowledge Base, make a POST request to the /v1/user/elemental endpoint. For this example, I will create a Table type of Knowledge Base.

1. Make the POST API Request to create the Knowledge Base

Here's how to create the Knowledge Base:

Parameters and body content
POST/v1/user/elemental

Properties

NameTypeRequiredDescription
titlestringTitle of the elemental
templatestringTemplate of the elemental
template_overwrite_contentbooleanAn option to overwrite the content
descriptionstringDescription of the elemental
commandstringCommand of the elemental
visibilitynumberVisibility of the elemental
category_idnumberCategory of the elemental
topic_idsnumber[]Topics related to the elemental
lists_to_saveObject[]Lists to save
lists_to_save.list_idnumberID of the list
is_premiumbooleanIndicates if the elemental is premium
is_fixed_pricebooleanIndicates if the elemental has a fixed price
pricenumberPrice of the elemental
price_originalnumberOriginal price of the elemental
avatarObjectAvatar of the elemental
avatar.file_namestringName of the avatar
avatar.file_buffernumber[]Buffer of the avatar
cover_imagesObject[]Cover images of the elemental
cover_images.file_namestringName of the cover image
cover_images.file_buffernumber[]Buffer of the cover image
imagesObject[]Images of the elemental
images.file_namestringName of the image
images.file_buffernumber[]Buffer of the image
filesObject[]Files of the elemental
files.file_namestringName of the file
files.file_buffernumber[]Buffer of the file
video_urlstringVideo URL of the elemental
tagIdsnumber[]Tag IDs of the elemental
tutorial_stepsObject[]Tutorial steps of the elemental
tutorial_steps.titlestringTitle of the tutorial step
tutorial_steps.descriptionstringDescription of the tutorial step
tutorial_steps.video_urlstringVideo URL of the tutorial step

Example

{
"title": "My First Table",
"description": "<p>Snack Prompt is awesome!</p>",
"type_id": 7
}

CURL Example

curl -X POST "https://api-integrations.snackprompt.com/v1/user/elemental" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"title":"My First Table","description":"<p>Snack Prompt is awesome!</p>","type_id":7}'

Code Examples

You can also use the Snack Prompt API in different programming languages:

const response = await fetch(
"https://api-integrations.snackprompt.com/v1/elemental",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": "YOUR_API_KEY",
},
body: JSON.stringify({
title: "My First Table",
description: "<p>Snack Prompt is awesome!</p>",
type_id: 7,
}),
}
);

if (response.ok) {
console.log("Elemental updated successfully");
} else {
console.error("Failed to update elemental");
}

Practical Example

To better understand how the system works in practice, let's walk through a hands-on example where we'll create a Knowledge Base (Simple Database).

Suppose you want to register a new elemental that represents a basic data table. In this case, we'll simulate the creation of a table named "My First Table" with a short description to identify its purpose.

Here are the key details you'll need:

  • Title: "My First Table"

  • Description: "Snack Prompt is awesome!"

  • Type ID: 7 (This value identifies the elemental as a table in the system)

To proceed with the creation, you'll typically send a request (such as via an API or system interface) including the data above. The type_id = 7 is crucial, as it informs the backend logic that this elemental should be treated and structured as a table within the platform.

Once created, this elemental will be available in your workspace, ready to receive new rows, columns, and entries as needed

This approach allows users to structure and store information flexibly while maintaining consistency and clarity in how different types of knowledge bases are handled.

{
"title": "My First Table",
"description": "<p>Snack Prompt is awesome!</p>",
"type_id": 7
}
  1. CURL example:
curl -X POST "https://api-integrations.snackprompt.com/v1/user/elemental"\
-H "Content-Type: application/json"
-H "x-api-key: YOUR_API_KEY"
-d '{"title":"My First Table","description":"Snack Prompt is awesome!"}'

For a visual example, I will use the Postman tool.

How to create a Knowledge Base

After creating the table, I will go to the Knowledge Base and see the changes. For this, I will acess the Snack Prompt website and go to the Knowledge Base section. https://snackprompt.com/table/id/edit. On the url, replace the id with the id of the table that you created.

How to create a Knowledge Base

Now if i need to update the table, i can use the Snack Prompt API to update the cells, documents, etc. Click here to learn how to update a Knowledge Base.