APP
Creating an App
Creating an application with ZBrain is a straightforward process facilitated by the platform's intuitive API. In this tutorial, you will learn how to create an app using ZBrain API by sending a POST request to the provided URL with the necessary headers and payload.
Step 1: Prepare the Request
To create an app, you need to send a POST request to the specified URL.
Request URL:
https://app.zbrain.ai:3000/api/manage-app
Request Method:
POST
Step 2: Set the Request Headers
Include the required headers in the POST request to authenticate your request and specify the content type.
Request Headers:
Authorization: Bearer <<API Key>>
Content-Type: application/json
Replace <<API Key>>
in the Authorization
header with your actual API key.
Step 3: Set the Request Payload
In the request payload, provide the necessary details for your app, including the configuration, description, email, knowledge bases, and name.
Request Payload:
Replace
"PRIVATE/PUBLIC"
in theconfiguration
field with the desired configuration type for your app.Replace
"App Description"
with a description for your app (optional).Replace
"example@example.com"
with the email associated with your app.Replace
"knowledgeBaseId"
with the ID of the knowledge base you want to associate with the app.Replace
"App Name"
with the desired name for your app.
Step 4: Send the Request
Using your preferred programming language or API testing tool, send the POST request to the provided URL with the necessary headers and payload.
Step 5: Process the Response
Upon successful execution of the request, you will receive a response from the API indicating that the app has been created.
Sample Response:
The response contains detailed information about the created app, including its styles, configuration, logo, description, and other properties.
The
message
field confirms the successful creation of the app.The
success
field indicates whether the request was successful (true
in this case).The
responseCode
field indicates the HTTP response code (200 for success).
That's it! You have successfully created an app using ZBrain API. The app is now available for use, and you can further customize its settings and features as needed.
Get All Apps
To retrieve all active apps created with ZBrain, you can use the ZBrain get app API. In this tutorial, you will learn how to fetch all apps by sending a GET request to the provided URL with the necessary payload.
Step 1: Prepare the Request
To retrieve all apps, you need to send a GET request to the specified URL.
Request URL:
https://app.zbrain.ai:3000/api/apps
Request Method:
GET
Step 2: Set the Query Strings
Include the query strings in the URL to specify the pagination parameters for the app retrieval.
Query Strings:
skip
: Numeric value indicating the number of records to skip (optional, default is 0).limit
: Numeric value indicating the maximum number of records to retrieve per page (optional, default is 10).
For example, to retrieve the first 10 apps, you can use the sample query string: ?skip=0&limit=10
Step 3: Set the Request Headers
Include the required headers in the GET request to authenticate your request and specify the content type.
Request Headers:
Authorization: Bearer <<API Key>>
Content-Type: application/json
Replace <<API Key>>
in the Authorization
header with your actual API key.
Step 4: Send the Request
Using your preferred programming language or API testing tool, send the GET request to the provided URL with the necessary headers and query strings.
Step 5: Process the Response
Upon successful execution of the request, you will receive a response from the API containing the information of all the apps.
Sample Response:
The response contains the
responseData
field, which includes an array of app objects under thedata
field. Each app object contains various properties such as_id
,styles
,configuration
,name
,description
, and more. Thetotal
field indicates the total number of apps available.The
message
field confirms that the app information has been fetched successfully.The
success
field indicates whether the request was successful (true
in this case).The
responseCode
field indicates the HTTP response code (200 for success).
That's it! You have successfully fetched all active apps using the ZBrain get app API. You can now process the app information as needed in your application.
Get an App by ID
To retrieve a specific app by its ID using the ZBrain API, you can make use of the Get App by ID endpoint. This tutorial will guide you through the steps required to fetch an app by sending a GET request to the provided URL.
Step 1: Prepare the Request
To get an app by ID, you need to send a GET request to the specified URL, including the app's ID in the path.
Request URL:
https://app.zbrain.ai:3000/api/manage-app/<appId>
Request Method:
GET
Replace <appId>
in the URL with the actual ID of the app you want to retrieve.
Step 2: Set the Request Headers
Include the required headers in the GET request to authenticate your request and specify the content type.
Request Headers:
Authorization: Bearer <<API Key>>
Content-Type: application/json
Replace <<API Key>>
in the Authorization
header with your actual API key.
Step 3: Send the Request
Using your preferred programming language or API testing tool, send the GET request to the provided URL with the necessary headers and app ID.
Step 4: Process the Response
Upon successful execution of the request, you will receive a response from the API containing the information of the app with the specified ID.
Sample Response:
The response contains the
responseData
field, which includes various properties of the app based on its ID. These properties includestyles
,configuration
,logo
,name
,description
,pageTitle
,pageDescription
,botName
,botInstruction
,botIcon
,botType
,model
,tenantId
,email
,createdBy
,knowledgeBases
,embedding
,sampleQueries
,suggestedQueries
,tokenLimit
,isDeleted
,isActive
,_id
,addedOn
,modifiedOn
, and__v
.The
message
field confirms that the app information has been fetched successfully.The
success
field indicates whether the request was successful (true
in this case).The
responseCode
field indicates the HTTP response code (200 for success).
That's it! You have successfully fetched the information of an app by its ID using the ZBrain get app by ID API. You can now process the app information as needed in your application.
Updating an App
To update an existing application using the ZBrain API, you can utilize the Update App endpoint. This tutorial will guide you through the steps required to modify various aspects of your app by sending a PUT request to the provided URL.
Step 1: Prepare the Request
To update an app, you need to send a PUT request to the specified URL.
Request URL:
https://app.zbrain.ai:3000/api/manage-app
Request Method:
PUT
Step 2: Set the Request Headers
Include the required headers in the PUT request to authenticate your request and specify the content type.
Request Headers:
Authorization: Bearer <<API Key>>
Content-Type: application/json
Replace <<API Key>>
in the Authorization
header with your actual API key.
Step 3: Set the Request Payload
The request payload contains the updated information for your app. You can modify the app's name, sample queries, page title, page description, knowledge bases, bot instruction, and bot name as needed.
Sample Request Body Payload:
Make sure to replace the placeholders (name of app
, sample query 1
, etc.) with the actual values you want to update.
Step 4: Send the Request
Using your preferred programming language or API testing tool, send the PUT request to the provided URL with the necessary headers and request payload.
Step 5: Process the Response
Upon successful execution of the request, you will receive a response from the API containing the updated information of the app.
Sample Response:
The response contains the
responseData
field, which includes the updated properties ofthe app, along with other relevant details.The
message
field confirms the success of the update operation.The
success
field indicates whether the request was successful (true
in this case).The
responseCode
field indicates the HTTP response code (200 for success).
That's it! You have successfully updated your app using the ZBrain API. The modified app information can now be utilized in your application as required.
Deleting an App
To delete an app using the ZBrain API, you can utilize the Delete App endpoint. This tutorial will guide you through the steps required to delete an app by sending a DELETE request to the provided URL.
Step 1: Prepare the Request
To delete an app, you need to send a DELETE request to the specified URL, replacing
<appId>
with the actual ID of the app you want to delete.Request URL:
https://app.zbrain.ai:3000/api/delete-app/<appId>
Request Method:
DELETE
Step 2: Set the Request Headers
Include the required headers in the DELETE request to authenticate your request and specify the content type.
Request Headers:
Authorization: Bearer <<API Key>>
Content-Type: application/json
Replace <<API Key>>
in the Authorization
header with your actual API key.
Step 3: Send the Request
Using your preferred programming language or API testing tool, send the DELETE request to the provided URL with the necessary headers.
Step 4: Process the Response
Upon successful execution of the request, you will receive a response from the API confirming the deletion of the app.
Sample Response:
The response contains the
responseData
field, which confirms the successful deletion of the app.The
message
field provides additional information about the deletion operation.The
success
field indicates whether the request was successful (true
in this case).The
responseCode
field indicates the HTTP response code (200 for success).
That's it! You have successfully deleted the app using the ZBrain API. The app will no longer be available in your ZBrain account or accessible through the API. Make sure to handle this deletion appropriately in your application logic.
Querying an App
The ZBrain API provides a Query App endpoint that allows you to interact with your created application by sending a POST request. This tutorial will guide you through the steps required to query your app and receive responses using the ZBrain API.
Step 1: Prepare the Request
To query your app, you need to send a POST request to the specified URL.
Request URL:
https://app.zbrain.ai:3002/api/query
Request Method:
POST
Step 2: Set the Request Headers
Include the required headers in the POST request to authenticate your request and specify the content type.
Request Headers:
Authorization: Bearer <<API Key>>
Content-Type: application/json
Replace <<API Key>>
in the Authorization
header with your actual API key.
Step 3: Set the Request Payload
In the request payload, provide the necessary information for the app query. Include the
appId
(your app's ID) and themessages
array containing the user's query.
Request Payload:
Replace <<appId>>
with the actual ID of your app, and <<Enter Query>>
with the query you want to send to the app.
Step 4: Send the Request
Using your preferred programming language or API testing tool, send the POST request to the provided URL with the necessary headers and payload.
Step 5: Process the Response
Upon successful execution of the request, you will receive a response from the API containing the app's response to your query.
Sample Response:
The response contains the
responseData
field, which contains the app's response to your query.The
message
field provides additional information about the request.The
success
field indicates whether the request was successful (true
in this case).The
responseCode
field indicates the HTTP response code (200 for success).
That's it! You have successfully queried your app using the ZBrain API. The responseData
field in the response will provide the app's response to your query. Make sure to handle and utilize this response in your application logic as needed.
Last updated