Delete a Knowledge Base using the API
How to Delete a Knowledge Base
If you need to delete a Knowledge Base, you can do so by using the Snack Prompt API through the appropriate endpoint for deleting 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:
- Log in to your Snack Prompt account.
- Navigate to the API Keys page: https://snackprompt.com/api-keys.
- Click the Create New API Key button.
- Provide a name for your Key to easily identify it later.
- 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 Delete a Knowledge Base Using the API
To delete a Knowledge Base, make a DELETE request to the /v1/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).

2. Make the DELETE API Request
Here's how to delete the Knowledge Base:
curl -X DELETE "https://api-integrations.snackprompt.com/v1/elemental/{id}"\
-H "x-api-key: YOUR_API_KEY"

Example Response
{
"code": 201,
"meta": {
"version": "v1.0.2",
"is_authenticaded": true
}
}
Code Examples
You can also use the Snack Prompt API in different programming languages:
- JavaScript
- Python
- Go
const response = await fetch(
"https://api-integrations.snackprompt.com/v1/elemental/{id}",
{
method: "DELETE",
headers: {
"x-api-key": "YOUR_API_KEY",
},
}
);
if (response.ok) {
console.log("Knowledge Base deleted successfully");
} else {
console.error("Failed to delete Knowledge Base");
}
import requests
url = 'https://api-integrations.snackprompt.com/v1/elemental/{id}'
headers = {
'x-api-key': 'YOUR_API_KEY'
}
response = requests.delete(url, headers=headers)
if response.status_code == 201:
print('Knowledge Base deleted successfully')
else:
print('Failed to delete Knowledge Base:', response.text)
package main
import (
"fmt"
"net/http"
)
func main() {
url := "https://api-integrations.snackprompt.com/v1/elemental/{id}"
req, err := http.NewRequest("DELETE", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("x-api-key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
fmt.Println("Knowledge Base deleted successfully")
} else {
fmt.Printf("Failed to delete Knowledge Base: %s\n", resp.Status)
}
For more information, refer to the API Reference here.