Skip to main content

How to Create

How to Create an Image (item)

If you need to create an Image (item), 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.

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

Creating a Image (item)

To create an Image (item), make a POST request to the /v1/user/elemental endpoint. For this example, I will create an Image (item) type of Image (item).

Endpoint

POST /v1/user/elemental

Headers

  • x-api-key: Your API Key.

Make the POST API Request to create the Image (item)

Here's how to create the Image (item).

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 Image (item)",
"description": "<p>Snack Prompt is awesome!</p>",
"type_id": 11,
"files": [
{
"file_name": "file-4nt.pdf",
"file_buffer": {
"type": "Buffer",
"data": [
123,
10,
32,
32,
32,
32,
34,
110
]
}
}
],
"images": [
{
"file_name": "file-4nt.png",
"file_buffer": {
"type": "Buffer",
"data": [
123,
10,
32,
32,
32,
32,
34,
110
]
}
}
]
}

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 Image (item)","description":"<p>Snack Prompt is awesome!</p>","type_id":11,"files":[{"file_name":"file-4nt.pdf","file_buffer":{"type":"Buffer","data":[123,10,32,32,32,32,34,110]}}],"images":[{"file_name":"file-4nt.png","file_buffer":{"type":"Buffer","data":[123,10,32,32,32,32,34,110]}}]}'

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 Image (item)",
description: "<p>Snack Prompt is awesome!</p>",
type_id: 11,
files: [
{
"file_name": "file-4nt.pdf",
"file_buffer": {
"type": "Buffer",
"data": [
123,
10,
32,
32,
32,
32,
34,
110
]
}
}
],
images: [
{
"file_name": "file-4nt.png",
"file_buffer": {
"type": "Buffer",
"data": [
123,
10,
32,
32,
32,
32,
34,
110
]
}
}
]
}),
}
);

if (response.ok) {
console.log("Image (item) created successfully");
} else {
console.error("Failed to create Image (item)");
}

Practical Example

To better understand how the system works in practice, let's walk through a hands-on example where we'll create an Image (item).

Suppose you want to register a new elemental that represents an Image (item). In this case, we'll simulate the creation of an Image (item) named "My First Image (item)" with a short description to identify its purpose.

Here are the key details you'll need:

  • Title: "My First Image (item)"

  • Description: "Snack Prompt is awesome!"

  • Type ID: 11 (This value identifies the elemental as an Image in the system)

  • Files: [{"file_name": "file-4nt.pdf", "file_buffer": {"type": "Buffer", "data": [123, 10, 32, 32, 32, 32, 34, 110]}}]

  • Images: [{"file_name": "file-4nt.png", "file_buffer": {"type": "Buffer", "data": [123, 10, 32, 32, 32, 32, 34, 110]}}]

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 = 11 is crucial, as it informs the backend logic that this elemental should be treated and structured as an Image (item) within the platform.

This approach allows users to structure and store information flexibly while maintaining consistency and clarity in how different types of Image (item)s are handled.

{
"title": "My First Image (item)",
"description": "<p>Snack Prompt is awesome!</p>",
"type_id": 11,
"files": [{"file_name": "file-4nt.pdf", "file_buffer": {"type": "Buffer", "data": [123, 10, 32, 32, 32, 32, 34, 110]}}],
"images": [{"file_name": "file-4nt.png", "file_buffer": {"type": "Buffer", "data": [123, 10, 32, 32, 32, 32, 34, 110]}}]
}
  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 Image (item)","description":"Snack Prompt is awesome!", "type_id": 11, "files": [{"file_name": "file-4nt.pdf", "file_buffer": {"type": "Buffer", "data": [123, 10, 32, 32, 32, 32, 34, 110]}}, {"file_name": "file-4nt.png", "file_buffer": {"type": "Buffer", "data": [123, 10, 32, 32, 32, 32, 34, 110]}}]'

Now if i need to create an Image (item), I can use the Snack Prompt API to create the Image (item). Click here to learn how to create an Image (item) and Body and Params to create an Image (item).