🚀 User API Documentation

Comprehensive guide to User endpoints for authentication, datasets, and user management


📑 Table of contents
  1. 📖 Reference Documentation
  2. 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
    10. Update Dataset Permissions
    11. Get Datasets With Permissions
    12. Get User API Keys
    13. Create API Key
    14. Delete API Key

📚 Base URL: https://api.asksage.ai/user/
⚠️ Important: Make sure to use the correct Base URL associated with your tenant.
🔑 Authentication: Use either a Static API key or a 24-hour access token in the x-access-tokens header.

📖 Reference Documentation

For detailed API specifications, visit the Ask Sage User API Swagger Documentation


API Endpoints

Get Access Token

POST https://api.asksage.ai/user/get-token-with-api-key

Obtain a 24-hour access token using your API key and email address.

Request Parameters

email string Required

The user's email address.

api_key string Required

The user's API key.

📤 Response Details
200 Success

access_token (string) - Valid for 24 hours

status (integer) - HTTP status code

400 Error

response (string) - Error message

status (integer) - HTTP status code

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

Retrieve the latest prompts and completions for the authenticated user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

📤 Response Details
200 Success

response (array) - Array of log objects containing:

  • date_time - Timestamp of the prompt
  • prompt - User's input prompt
  • completion - AI response
  • IP - Request IP address
400 Error

response (string) - Error message

curl -X POST 'https://api.asksage.ai/user/get-user-logs' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json'

Get User Logins

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

Retrieve recent login history for the authenticated user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

limit integer Optional

Maximum number of login records to retrieve (1-100). Default: 5

📤 Response Details
200 Success

response (array) - Array of login objects containing:

  • date_time - Login timestamp
  • IP - Login IP address
400 Error

Invalid limit value or missing required fields

curl -X POST 'https://api.asksage.ai/user/get-user-logins' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"limit": 5}'

Add Dataset

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

Create a new dataset in your account.

💡 CUI Content: If your content is CUI (Controlled Unclassified Information), prefix your dataset name with "CUI-"
⚠️ Naming Rules: Dataset names must be alphanumeric only. No spaces allowed!

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

dataset string Required

Name of the dataset to create (alphanumeric, no spaces).

📤 Response Details
200 Success

Dataset created successfully

400 Error

Missing required fields or invalid input

406 Error

Dataset name too long

407 Error

CAC required for this operation

curl -X POST 'https://api.asksage.ai/user/add-dataset' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"dataset": "MyDataset123"}'

Delete Dataset

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

Permanently delete a dataset from your account.

📝 Note: Use the 'get-models' endpoint at api.asksage.ai/server/ to retrieve the full dataset name.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

dataset string Required

Full dataset name in format: user_custom_USERID_DATASETNAME_content

📤 Response Details
200 Success

Dataset deleted successfully

400 Error

Missing required fields or invalid input

408 Error

Required information missing

curl -X POST 'https://api.asksage.ai/user/delete-dataset' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"dataset": "user_custom_123_MyDataset_content"}'

Get Chats

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

Retrieve all chat sessions for the authenticated user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

📤 Response Details
200 Success

response (array) - Array of all chat sessions

400 Error

Missing required fields or invalid input

curl -X POST 'https://api.asksage.ai/user/get-chats' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json'

Get Chat Session

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

Retrieve a specific chat session by ID.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

session_id string Required

The unique identifier of the chat session to retrieve.

📤 Response Details
200 Success

response (object) - Chat session details

400 Error

Missing required fields or invalid session ID

curl -X POST 'https://api.asksage.ai/user/get-chat-session' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"session_id": "your_session_id"}'

Delete Chat Session

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

Permanently delete a chat session.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

session_id string Required

The unique identifier of the chat session to delete.

📤 Response Details
200 Success

Chat session deleted successfully

400 Error

Missing required fields or invalid session ID

curl -X POST 'https://api.asksage.ai/user/delete-chat-session' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"session_id": "your_session_id"}'

Deassign Dataset

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

Remove a dataset assignment from a specific user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

dataset string Required

The name of the dataset to deassign.

email string Required

The email address of the user to deassign the dataset from.

📤 Response Details
200 Success

Dataset deassigned successfully

400 Error

Missing required fields or invalid input

curl -X POST 'https://api.asksage.ai/user/deassign-dataset' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{
    "dataset": "MyDataset",
    "email": "user@example.com"
  }'

Update Dataset Permissions

POST https://api.asksage.ai/user/update-permission-dataset

Update permission levels for a dataset assigned to a user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

dataset string Required

The name of the dataset to update permissions for.

email string Required

The email address of the user whose permissions to update.

permission string Required

The new permission level (e.g., "read", "write", "admin").

📤 Response Details
200 Success

Dataset permissions updated successfully

400 Error

Missing required fields or invalid permission level

curl -X POST 'https://api.asksage.ai/user/update-permission-dataset' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{
    "dataset": "MyDataset",
    "email": "user@example.com",
    "permission": "read"
  }'

Get Datasets With Permissions

POST https://api.asksage.ai/user/get-datasets-with-permissions

Retrieve all datasets with their associated permissions for the authenticated user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

check_permissions boolean Required

Whether to include detailed permission information in the response.

📤 Response Details
200 Success

response (array) - Array of datasets with permission details

400 Error

Missing required fields or invalid input

curl -X POST 'https://api.asksage.ai/user/get-datasets-with-permissions' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"check_permissions": true}'

Get User API Keys

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

Retrieve all API keys associated with the authenticated user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

📤 Response Details
200 Success

response (array) - Array of API key objects

400 Error

Authentication failed or invalid token

curl -X POST 'https://api.asksage.ai/user/get-user-api-keys' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json'

Create API Key

POST https://api.asksage.ai/user/user-api-key

Generate a new API key for the authenticated user.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

name string Required

A descriptive name for the new API key.

📤 Response Details
200 Success

api_key (string) - The newly generated API key

name (string) - The name of the API key

400 Error

Missing required fields or invalid input

curl -X POST 'https://api.asksage.ai/user/user-api-key' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"name": "My API Key"}'

Delete API Key

DELETE https://api.asksage.ai/user/user-api-key

Permanently delete an API key.

⚠️ Warning: This action cannot be undone. Make sure you're not using this API key in any active integrations.

Request Parameters

x-access-tokens string (header) Required

24-hour access token or API key for authentication.

id integer Required

The unique identifier of the API key to delete.

📤 Response Details
200 Success

API key deleted successfully

400 Error

Missing required fields or invalid API key ID

404 Error

API key not found

curl -X DELETE 'https://api.asksage.ai/user/user-api-key' \
  -H 'x-access-tokens: your_access_token' \
  -H 'Content-Type: application/json' \
  -d '{"id": 123}'

Back to top

Copyright © 2025 Ask Sage Inc. All Rights Reserved.