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
  1. User API Endpoints:
    1. Get Access Token
    2. Get User Logs
    3. Get User Logins
    4. Add Dataset
    5. Delete Dataset
    6. Get Chats
    7. Get Chat Session
    8. Delete Chat Session
    9. Deassign Dataset

User API Endpoints:

The User API is used for managing users, authentication, and datasets.

Reference the following Swagger Documentation for detailed information on the API endpoints and how to use them:

  • Ask Sage User API: Copy and paste the following URL to access the Swagger documentation:
https://app.swaggerhub.com/apis-docs/asksageinc/ask-sage_user_api/1.21
  • 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


email string Required

The user's email address.


api_key string Required

The user's API key.


Click to see the Return output

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.


Click to see the Return output

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.


Click to see the Return output

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.


Click to see the Return output

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.


Click to see the Return output

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.
        
        
        
      

Get Chats

POST https://api.asksage.ai/user/get-chats

Get all chat sessions for user.

Request body


x-access-tokens string Required

The 24-hour Token or API Key used for authentication.


Click to see the Return output

Returns

On success (HTTP 200):

response object Contains:

- response string

Message containing all chat sessions

- 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/get-chats" \
     -H "x-access-tokens: your_access_token" \
     -H "Content-Type: application/json" \
     -d '{"response": "string"}'
        
        
          
      

Get Chat Session

POST https://api.asksage.ai/user/get-chat-session

Get specific chat session.

Request body


x-access-tokens string Required

The 24-hour Token or API Key used for authentication.


session_id string Required

The specific chat session id.


Click to see the Return output

Returns

On success (HTTP 200):

response object Contains:

- session_id string

Message containing the specific chat session

- 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/get-chat-session" \
     -H "x-access-tokens: your_api_key" \
     -H "Content-Type: application/json" \
     -d '{"session_id": "your_session_id"}'
     
     

      

Delete Chat Session

POST https://api.asksage.ai/user/delete-chat-session

Delete chat session.

Request body


x-access-tokens string Required

The 24-hour Token or API Key used for authentication.


session_id string Required

The specific chat session id.


Click to see the Return output

Returns

On success (HTTP 200):

response object Contains:

- response string

Message confirming the chat session is deleted.

- 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-chat-session" \
     -H "x-access-tokens: your_api_key" \
     -H "Content-Type: application/json" \
     -d '{"session_id": "your_session_id"}'
     
     

      

Deassign Dataset

POST https://api.asksage.ai/user/deassign-dataset

Remove dataset from user.

Request body


x-access-tokens string Required

The 24-hour Token or API Key used for authentication.


dataset string Required

The specific dataset to deassign.


email string Required

The email of the user to deassign from.


Click to see the Return output

Returns

On success (HTTP 200):

response object Contains:

- response string

Message confirming dataset is deassigned.

- 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/deassign-dataset" \
     -H "x-access-tokens: your_api_key" \
     -H "Content-Type: application/json" \
     -d '{"dataset": "string", "email": "user@example.com"}'
    
     

      

Back to top

Copyright © 2025 Ask Sage Inc. All Rights Reserved.