In this section will cover the User Base URL and the associated endpoints in the Ask Sage API, including the parameters and responses for each endpoint.
The Base URL for the User API is: [ Base URL: api.asksage.ai/user/ ]
Make sure to use the correct Base URL associated with your tenant.
Users can use the Static API key Generated in the Ask Sage Platform as the required token for authentication. However, there is no expiration on the API key, while if you generate a token it is valid for 24 hours. "x-access-tokens": "your_access_token_here" "x-access-tokens": "api-key"
Get Access Token
POST https://api.asksage.ai/user/get-token-with-api-key
A user with an API key and email can obtain an access token.
Request body
emailstringRequired
The user's email address.
api_keystringRequired
The user's API key.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- access_tokenstring
The access token for the user, which is only valid for 24 hours.
The 24-hour Token or API Key used for authentication.
Click to see the Return output
Returns
On success (HTTP 200):
responsearray Contains objects with:
- date_timestring
The date and time of the prompt.
- promptstring
The user's prompt.
- completionstring
The completion of the prompt.
- IPstring
The IP address from which the prompt was made.
On error (HTTP 400):
- responsestring
An error message describing the issue.
- statusinteger
The status code of the response.
curl -X POST https://api.asksage.ai/user/get-user-logs \
-H "x-access-tokens: your_access_token_here" \
-H 'Content-Type: application/json'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/get-user-logs"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = "Your_Access_Token"
get_user_log(access_token) # Call the function
import fetch from 'node-fetch';
const url = 'https://api.asksage.ai/user/get-user-logs';
const accessToken = 'your_access_token_here'; // Replace with your actual access token
const body = JSON.stringify({}); // Create an empty body
fetch(url, {
method: 'POST',
headers: {
'x-access-tokens': accessToken,
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: body
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => console.log("Success:", data))
.catch(error => console.error('Error:', error));
Get User Logins
POST https://api.asksage.ai/user/get-user-logins
Get the latest logins of the user.
Request body
limitintegerOptional
The maximum number of user logins to retrieve. Must be between 0 and 101.
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
Click to see the Return output
Returns
On success (HTTP 200):
responsearray Contains objects with:
- date_timestring
The date and time of the login.
- IPstring
The IP address from which the login was made.
On error (HTTP 400):
- responsestring
An error message describing the issue.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/get-user-logins" \
-H "x-access-tokens: your_access_token_here" \
-H "Content-Type: application/json" \
-d '{"limit": 5}'
import requests
def get_user_logins(access_token, limit=5):
# Ensure limit is within the allowed range
if not (1 <= limit <= 100):
raise ValueError("Limit must be between 1 and 100.")
url = "https://api.asksage.ai/user/get-user-logins"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body with the limit parameter
body = {
"limit": limit
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data)
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = "Your_Access_Token"
get_user_logins(access_token, limit=5) # Call the function with the desired limit
import fetch from 'node-fetch';
const url = 'https://api.asksage.ai/user/get-user-logins';
const accessToken = 'your_access_token_here'; // Replace with your actual access token
const limit = 5; // Set your desired limit
// Ensure limit is within the allowed range
if (limit < 1 || limit > 100) {
throw new Error("Limit must be between 1 and 100.");
}
const body = JSON.stringify({ limit });
fetch(url, {
method: 'POST',
headers: {
'x-access-tokens': accessToken,
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: body
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => console.log("Success:", data))
.catch(error => console.error('Error:', error));
Add Dataset
POST https://api.asksage.ai/user/add-dataset
Add a new dataset to the user’s account.
If your content is CUI, you must name your dataset with the prefix “CUI-“.
For dataset names, only alphanumeric characters allowed. NO spaces!
Request body
datasetstringRequired
The name of the dataset.
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message indicating that the dataset was added successfully.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 406):
- responsestring
An error message indicating that the dataset name is too long.
- statusinteger
The status code of the response.
On error (HTTP 407):
- responsestring
An error message indicating that a CAC is required for adding the dataset.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/add-dataset" \
-H "x-access-tokens: your_access_token_here" \
-H "Content-Type: application/json" \
-d '{"dataset": "dataset-name"}'
import requests
url = "https://api.asksage.ai/user/add-dataset"
headers = {
"x-access-tokens": "your_access_token_here", # Replace with your access token
"Content-Type": "application/json"
}
data = {
"dataset": "dataset-name" # Replace with your actual dataset name
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Success:", response.json())
else:
print("Error:", response.json())
fetch('https://api.asksage.ai/user/add-dataset', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token_here', // Replace with your actual Access Token
'Content-Type': 'application/json'
},
body: JSON.stringify({
dataset: 'dataset-name' // Replace with your actual dataset name
})
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => console.log("Success:", data))
.catch(error => console.error('Error:', error));
Delete Dataset
POST https://api.asksage.ai/user/delete-dataset
Deletes dataset from the user’s account.
To get the full name of your dataset use the ‘get-models’ endpoint in the[ Base URL: api.asksage.ai/server/ ]
Request body
datasetstringRequired
Apply the full name of the dataset which is defined as user_custom_USERID_DATASETNAME_content.
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message indicating that the dataset was deleted successfully.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/delete-dataset" \
-H "x-access-tokens: your_access_token_here" \ # Make sure to replace 'your_access_token_here' with your actual access token.
-H "Content-Type: application/json" \
-d '{"dataset": "user_custom_USERID_DATASETNAME_content"}' # Update 'USERID' and 'DATASETNAME' in the dataset parameter with the appropriate values.
import requests
import json
url = "https://api.asksage.ai/user/delete-dataset"
headers = {
"x-access-tokens": "your_access_token_here", # Replace with your access token
"Content-Type": "application/json"
}
data = {
"dataset": "user_custom_USERID_DATASETNAME_content" # Replace USERID and DATASETNAME
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
fetch('https://api.asksage.ai/user/delete-dataset', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token_here', // Replace with your actual access token
'Content-Type': 'application/json'
},
body: JSON.stringify({
dataset: 'user_custom_USERID_DATASETNAME_content' // Replace USERID and DATASETNAME
})
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => console.log("Success:", data))
.catch(error => console.error('Error:', error));
Get Chats
POST https://api.asksage.ai/user/get-chats
Get all chat sessions for user.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message containing all chat sessions
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/get-chats" \
-H "x-access-tokens: your_access_token" \
-H "Content-Type: application/json" \
-d '{"response": "string"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/get-chats"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"response": "string"
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_access_token'
get_user_log(access_token) # Call the function
fetch('https://api.asksage.ai/user/get-chats', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
response: 'string'
})
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => console.log("Success:", data))
.catch(error => console.error('Error:', error));
Get Chat Session
POST https://api.asksage.ai/user/get-chat-session
Get specific chat session.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
session_idstringRequired
The specific chat session id.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- session_idstring
Message containing the specific chat session
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/get-chat-session" \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"session_id": "your_session_id"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/get-chat-session"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"session_id": 'your_session_id'
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
fetch("https://api.asksage.ai/user/get-chat-session", {
method: "POST",
headers: {
"x-access-tokens": "your_api_key", // Replace with your actual API key
"Content-Type": "application/json"
},
body: JSON.stringify({ session_id: "your_session_id" }) // Replace with your actual session ID
})
.then(response => response.json())
.then(data => console.log("Response:", data))
.catch(error => console.error("Error:", error));
Delete Chat Session
POST https://api.asksage.ai/user/delete-chat-session
Delete chat session.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
session_idstringRequired
The specific chat session id.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming the chat session is deleted.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/delete-chat-session" \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"session_id": "your_session_id"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/delete-chat-session"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"session_id": 'your_session_id'
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
fetch("https://api.asksage.ai/user/delete-chat-session", {
method: "POST",
headers: {
"x-access-tokens": "your_api_key", // Replace with your actual API key
"Content-Type": "application/json"
},
body: JSON.stringify({ session_id: "your_session_id" }) // Replace with your actual session ID
})
.then(response => response.json())
.then(data => console.log("Response:", data))
.catch(error => console.error("Error:", error));
Deassign Dataset
POST https://api.asksage.ai/user/deassign-dataset
Remove dataset from user.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
datasetstringRequired
The specific dataset to deassign.
emailstringRequired
The email of the user to deassign from.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming dataset is deassigned.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/deassign-dataset" \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"dataset": "string", "email": "user@example.com"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/deassign-dataset"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"dataset": "string",
"email": "user@example.com"
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
fetch("https://api.asksage.ai/user/deassign-dataset", {
method: "POST",
headers: {
"x-access-tokens": "your_api_key", // Replace with your actual API key
"Content-Type": "application/json"
},
body: JSON.stringify({
dataset: "string", // Replace with the actual dataset name
email: "user@example.com" // Replace with the actual email address
})
})
.then(response => response.json())
.then(data => console.log("Response:", data))
.catch(error => console.error("Error:", error));
Delete Chat Session
POST https://api.asksage.ai/user/delete-chat-session
Delete chat session.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
session_idstringRequired
The specific chat session id.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming the chat session is deleted.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/delete-chat-session" \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"session_id": "your_session_id"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/delete-chat-session"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"session_id": 'your_session_id'
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
fetch("https://api.asksage.ai/user/delete-chat-session", {
method: "POST",
headers: {
"x-access-tokens": "your_api_key", // Replace with your actual API key
"Content-Type": "application/json"
},
body: JSON.stringify({ session_id: "your_session_id" }) // Replace with your actual session ID
})
.then(response => response.json())
.then(data => console.log("Response:", data))
.catch(error => console.error("Error:", error));
Deassign Dataset
POST https://api.asksage.ai/user/deassign-dataset
Remove dataset from user.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
datasetstringRequired
The specific dataset to deassign.
emailstringRequired
The email of the user to deassign from.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming dataset is deassigned.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST "https://api.asksage.ai/user/deassign-dataset" \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"dataset": "string", "email": "user@example.com"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/deassign-dataset"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"dataset": "string",
"email": "user@example.com"
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
fetch("https://api.asksage.ai/user/deassign-dataset", {
method: "POST",
headers: {
"x-access-tokens": "your_api_key", // Replace with your actual API key
"Content-Type": "application/json"
},
body: JSON.stringify({
dataset: "string", // Replace with the actual dataset name
email: "user@example.com" // Replace with the actual email address
})
})
.then(response => response.json())
.then(data => console.log("Response:", data))
.catch(error => console.error("Error:", error));
Update Permission Dataset
POST https://api.asksage.ai/user/update-permission-dataset
Update dataset permissions.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
datasetstringRequired
The specific dataset to set new permissions.
emailstringRequired
The email of the user to set new permissions.
permissionstringRequired
The new permission level to be set.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming dataset permission is updated.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST https://api.asksage.ai/user/update-permission-dataset \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"dataset": "string","email": "user@example.com","permission": "read"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/update-permission-dataset"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"dataset": "string",
"email": "user@example.com",
"permission": "read"
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
const accessToken = 'your_api_key';
fetch('https://api.asksage.ai/user/update-permission-dataset', {
method: 'POST',
headers: {
'x-access-tokens': accessToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({
dataset: 'string',
email: 'user@example.com',
permission: 'read'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Get Datasets With Permissions
POST https://api.asksage.ai/user/get-datasets-with-permissions
Get user datasets with permissions.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
check_permissionsbooleanRequired
A boolean indicating whether to check for permissions.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming datasets with permissions received.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST https://api.asksage.ai/user/get-datasets-with-permissions \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"check_permissions": "true"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/get-datasets-with-permissions"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"check_permissions": "true"
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
const accessToken = 'your_api_key';
fetch('https://api.asksage.ai/user/get-datasets-with-permissions', {
method: 'POST',
headers: {
'x-access-tokens': accessToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({
check_permissions: 'true'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Get User API Keys
POST https://api.asksage.ai/user/get-user-api-keys
Get user API keys.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming API keys retrieved.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST https://api.asksage.ai/user/get-user-api-keys \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/get-user-api-keys"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
const accessToken = 'your_api_key';
fetch('https://api.asksage.ai/user/get-user-api-keys', {
method: 'POST',
headers: {
'x-access-tokens': accessToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
User API Key
POST https://api.asksage.ai/user/user-api-key
Create new API key.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
namestringRequired
The name of the new API key to be created.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming API key created.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X POST https://api.asksage.ai/user/user-api-key \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"name": "string"}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/user-api-key"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"name": "string"
}
response = requests.post(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
const accessToken = 'your_api_key';
fetch('https://api.asksage.ai/user/user-api-key', {
method: 'POST',
headers: {
'x-access-tokens': accessToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'string'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
User API Key
DELETE https://api.asksage.ai/user/user-api-key
Delete an API key.
Request body
x-access-tokensstringRequired
The 24-hour Token or API Key used for authentication.
idintegerRequired
The id of the API key to be deleted.
Click to see the Return output
Returns
On success (HTTP 200):
responseobject Contains:
- responsestring
Message confirming API key created.
- statusinteger
The status code of the response.
On error (HTTP 400):
- responsestring
An error message indicating missing required fields or invalid input.
- statusinteger
The status code of the response.
On error (HTTP 408):
- responsestring
An error message indicating that required information is missing.
- statusinteger
The status code of the response.
curl -X DELETE https://api.asksage.ai/user/user-api-key \
-H "x-access-tokens: your_api_key" \
-H "Content-Type: application/json" \
-d '{"id": 0}'
import requests
def get_user_log(access_token):
url = "https://api.asksage.ai/user/user-api-key"
headers = {
"x-access-tokens": access_token,
"Content-Type": "application/json"
}
# Create the body
body = {
"id": 0
}
response = requests.delete(url, headers=headers, json=body) # Use json= to send JSON body
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("Success:", data) # Response is a JSON object
elif response.status_code == 400:
error_data = response.json()
print("Error:", error_data.get("response", "Missing required fields or invalid input."))
else:
print("Error:", response.text)
# Example usage
access_token = 'your_api_key'
get_user_log(access_token) # Call the function
const accessToken = 'your_api_key';
fetch('https://api.asksage.ai/user/user-api-key', {
method: 'DELETE',
headers: {
'x-access-tokens': accessToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({
id: 0
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));