User Parameters and Responses
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.
Table of contents
User API Endpoints:
The User API is used for managing users, authentication, and datasets. We have the following Swagger documentation for the User API:
- 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"
The following table shows the available endpoints in the User API:
Endpoint | Description |
---|---|
/get-token-with-api-key | Get an access token with API Key and email |
/get-user-logins | Get your last logins (limited to 5 by default) |
/get-user-logs | Get your last prompts |
/add-dataset | Add a new dataset |
/delete-dataset | Deletes a dataset |
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
email string Required
The user's email address.
api_key string Required
The user's API key.
Returns
On success (HTTP 200):
response object Contains:
- access_token string
The access token for the user, which is only valid for 24 hours.
- status integer
The status code of the response.
On error (HTTP 400):
- response string
An error message describing the issue.
- status integer
The status code of the response.
curl -X 'POST' \
'https://api.asksage.ai/user/get-token-with-api-key' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"email": "your_email@email.com",
"api_key": "your_api_key"
}'
Get User Logs
POST https://api.asksage.ai/user/get-user-logs
Get the latest prompts of the user.
Request body
x-access-tokens string Required
The 24-hour Token or API Key used for authentication.
Returns
On success (HTTP 200):
response array Contains objects with:
- date_time string
The date and time of the prompt.
- prompt string
The user's prompt.
- completion string
The completion of the prompt.
- IP string
The IP address from which the prompt was made.
On error (HTTP 400):
- response string
An error message describing the issue.
- status integer
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'
Get User Logins
POST https://api.asksage.ai/user/get-user-logins
Get the latest logins of the user.
Request body
limit integer Optional
The maximum number of user logins to retrieve. Must be between 0 and 101.
x-access-tokens string Required
The 24-hour Token or API Key used for authentication.
Returns
On success (HTTP 200):
response array Contains objects with:
- date_time string
The date and time of the login.
- IP string
The IP address from which the login was made.
On error (HTTP 400):
- response string
An error message describing the issue.
- status integer
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}'
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
dataset string Required
The name of the dataset.
x-access-tokens string Required
The 24-hour Token or API Key used for authentication.
Returns
On success (HTTP 200):
response object Contains:
- response string
Message indicating that the dataset was added successfully.
- status integer
The status code of the response.
On error (HTTP 400):
- response string
An error message indicating missing required fields or invalid input.
- status integer
The status code of the response.
On error (HTTP 406):
- response string
An error message indicating that the dataset name is too long.
- status integer
The status code of the response.
On error (HTTP 407):
- response string
An error message indicating that a CAC is required for adding the dataset.
- status integer
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"}'
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
dataset string Required
Apply the full name of the dataset which is
defined as user_custom_USERID_DATASETNAME_content.
x-access-tokens string Required
The 24-hour Token or API Key used for authentication.
Returns
On success (HTTP 200):
response object Contains:
- response string
Message indicating that the dataset was deleted successfully.
- status integer
The status code of the response.
On error (HTTP 400):
- response string
An error message indicating missing required fields or invalid input.
- status integer
The status code of the response.
On error (HTTP 408):
- response string
An error message indicating that required information is missing.
- status integer
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.
Train Model
POST https://api.asksage.ai/user/train
Train the model based on the user’s input.
Request body
content object Required
The user's input content.
context string Optional
Short context (metadata) about the content.
summarize boolean Optional
Summarize the content.
summarize_model string Optional
Model to use for summarization.
force_dataset string Optional
Force a specific dataset.
x-access-tokens string Required
The 24-hour Token or API Key used for authentication.
Returns
On success (HTTP 200):
response object Contains:
- result string
The result of the training process.
- status integer
The status code of the response.
On error (HTTP 400):
- response string
An error message indicating missing required fields or invalid input.
- status integer
The status code of the response.
curl -X POST "https://api.asksage.ai/user/train" \
-H "x-access-tokens: your_access_token_here" \
-H "Content-Type: application/json" \
-d '{
"content": {
"context": "Your context here",
"content": "Your input content here"
},
"summarize": true,
"summarize_model": "model_name",
"force_dataset": "dataset_name"
}'