Skip to main content

How to Edit a Knowledge Base Information

If you need to edit a Knowledge Base information, you can do so by using the Snack Prompt API through the appropriate endpoint for editing 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 Edit a Knowledge Base Information

To edit a cell, document, prompt or any other elemental of a Knowledge Base, make a PUT request to the /v1/user/elemental/{id} endpoint.

1. Get Your Knowledge Base ID

If you don't know your Knowledge Base ID, you can get it by:

  • Open your Knowledge Base in Snack Prompt

  • Click the three-dot menu at the top of the Knowledge Base

  • Select "Copy the ID"

Example of a valid Knowledge Base ID: hoewEL19T. The ID is always a string of characters (nanoId).

How to get your Knowledge Base ID

If you want to edit a prompt, document or any other elemental, of Knowledge Base list, you can get the ID of the elemental by:

  • Open your Knowledge Base in Snack Prompt

  • Click to edit the knowledge base list

  • Select the elemental you want to edit. Will open a new page with the elemental information

  • Click the three-dot menu at the top of the elemental

  • Copy the ID of the elemental

How to get your Knowledge Base ID

2. Make the PUT API Request to edit the Knowledge Base information

Here's how to edit the Knowledge Base information:

Parameters and body content:

Parameters and body content
PUT/v1/user/elemental/{id}

Properties

NameTypeRequiredDescription
idstringID of the elemental

Example

/v1/user/elemental/your-elemental-id

CURL Example

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

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/{id}",
{
method: "PUT",
headers: {
"Content-Type": "application/json",
"x-api-key": "YOUR_API_KEY",
},
body: JSON.stringify({
title: "My First Prompt",
description: "<p>Snack Prompt is awesome!</p>",
}),
}
);

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

Practical Example

For a hands-on example, let's say you want to edit a cell of the Knowledge Base (Simple Database) with the ID kCT7xzdPy.

How to get your Knowledge Base ID

I will change the title and template of the cell. I will use the Snack Prompt API to edit the cell.

  1. After get the ID of the cell, I will make a PUT request to the /v1/user/elemental/{id} endpoint.

  2. I will pass the title "My First Prompt" and the template "Prompt". I need to pass the type_id of my elemental. In this case, the type_id is 8 because I want to edit a cell.

{
"title": "My First Prompt",
"template": "Prompt",
"type_id": 8
}
  1. CURL example:
curl -X PUT "https://api-integrations.snackprompt.com/v1/user/elemental/{id}"\
-H "Content-Type: application/json"
-H "x-api-key: YOUR_API_KEY"
-d '{"title":"My First Prompt","template":"Prompt"}'

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

How to edit a Knowledge Base

After editing the cell, I will go to the Knowledge Base and see the changes.

How to edit a Knowledge Base

For more information, refer to the API Reference here.