🚀 User API Documentation
Comprehensive guide to User endpoints for authentication, datasets, and user management
📑 Table of contents
- 📖 Reference Documentation
- API Endpoints
- Get Access Token
- Get User Logs
- Get User Logins
- Add Dataset
- Delete Dataset
- Get Chats
- Get Chat Session
- Delete Chat Session
- Deassign Dataset
- Update Dataset Permissions
- Get Datasets With Permissions
- Get User API Keys
- Create API Key
- 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
Obtain a 24-hour access token using your API key and email address.
Request Parameters
The user's email address.
📤 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"
}'import requests
url = 'https://api.asksage.ai/user/get-token-with-api-key'
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
data = {
'email': 'your_email@email.com',
'api_key': 'your_api_key'
}
response = requests.post(url, headers=headers, json=data)
print(response.json())const response = await fetch('https://api.asksage.ai/user/get-token-with-api-key', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'your_email@email.com',
api_key: 'your_api_key'
})
});
const data = await response.json();
console.log(data);
Get User Logs
Retrieve the latest prompts and completions for the authenticated user.
Request Parameters
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'import requests
url = 'https://api.asksage.ai/user/get-user-logs'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, json={})
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/get-user-logs', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
const data = await response.json();
console.log(data);
Get User Logins
Retrieve recent login history for the authenticated user.
Request Parameters
24-hour access token or API key for authentication.
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}'import requests
url = 'https://api.asksage.ai/user/get-user-logins'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'limit': 5}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/get-user-logins', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ limit: 5 })
});
const data = await response.json();
console.log(data);
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
24-hour access token or API key for authentication.
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"}'import requests
url = 'https://api.asksage.ai/user/add-dataset'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'dataset': 'MyDataset123'}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/add-dataset', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ dataset: 'MyDataset123' })
});
const data = await response.json();
console.log(data);
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
24-hour access token or API key for authentication.
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"}'import requests
url = 'https://api.asksage.ai/user/delete-dataset'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'dataset': 'user_custom_123_MyDataset_content'}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/delete-dataset', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
dataset: 'user_custom_123_MyDataset_content'
})
});
const data = await response.json();
console.log(data);
Get Chats
Retrieve all chat sessions for the authenticated user.
Request Parameters
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'import requests
url = 'https://api.asksage.ai/user/get-chats'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, json={})
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/get-chats', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
const data = await response.json();
console.log(data);
Get Chat Session
Retrieve a specific chat session by ID.
Request Parameters
24-hour access token or API key for authentication.
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"}'import requests
url = 'https://api.asksage.ai/user/get-chat-session'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'session_id': 'your_session_id'}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/get-chat-session', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ session_id: 'your_session_id' })
});
const data = await response.json();
console.log(data);
Delete Chat Session
Permanently delete a chat session.
Request Parameters
24-hour access token or API key for authentication.
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"}'import requests
url = 'https://api.asksage.ai/user/delete-chat-session'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'session_id': 'your_session_id'}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/delete-chat-session', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ session_id: 'your_session_id' })
});
const data = await response.json();
console.log(data);
Deassign Dataset
Remove a dataset assignment from a specific user.
Request Parameters
24-hour access token or API key for authentication.
The name of the dataset to deassign.
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"
}'import requests
url = 'https://api.asksage.ai/user/deassign-dataset'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {
'dataset': 'MyDataset',
'email': 'user@example.com'
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/deassign-dataset', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
dataset: 'MyDataset',
email: 'user@example.com'
})
});
const data = await response.json();
console.log(data);
Update Dataset Permissions
Update permission levels for a dataset assigned to a user.
Request Parameters
24-hour access token or API key for authentication.
The name of the dataset to update permissions for.
The email address of the user whose permissions to update.
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"
}'import requests
url = 'https://api.asksage.ai/user/update-permission-dataset'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {
'dataset': 'MyDataset',
'email': 'user@example.com',
'permission': 'read'
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/update-permission-dataset', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
dataset: 'MyDataset',
email: 'user@example.com',
permission: 'read'
})
});
const data = await response.json();
console.log(data);
Get Datasets With Permissions
Retrieve all datasets with their associated permissions for the authenticated user.
Request Parameters
24-hour access token or API key for authentication.
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}'import requests
url = 'https://api.asksage.ai/user/get-datasets-with-permissions'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'check_permissions': True}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/get-datasets-with-permissions', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ check_permissions: true })
});
const data = await response.json();
console.log(data);
Get User API Keys
Retrieve all API keys associated with the authenticated user.
Request Parameters
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'import requests
url = 'https://api.asksage.ai/user/get-user-api-keys'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, json={})
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/get-user-api-keys', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
const data = await response.json();
console.log(data);
Create API Key
Generate a new API key for the authenticated user.
Request Parameters
24-hour access token or API key for authentication.
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"}'import requests
url = 'https://api.asksage.ai/user/user-api-key'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'name': 'My API Key'}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/user-api-key', {
method: 'POST',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: 'My API Key' })
});
const data = await response.json();
console.log(data);
Delete 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
24-hour access token or API key for authentication.
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}'import requests
url = 'https://api.asksage.ai/user/user-api-key'
headers = {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
}
data = {'id': 123}
response = requests.delete(url, headers=headers, json=data)
if response.status_code == 200:
print('Success:', response.json())
else:
print('Error:', response.json())const response = await fetch('https://api.asksage.ai/user/user-api-key', {
method: 'DELETE',
headers: {
'x-access-tokens': 'your_access_token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ id: 123 })
});
const data = await response.json();
console.log(data);