The User Activity API provides comprehensive audit logging and activity tracking for all user actions in the system.
Get user activities
Retrieve user activity logs with filtering options.
Query parameters
Filter activities from this date (ISO 8601 format)
Filter activities to this date (ISO 8601 format)
Filter by specific user ID
Filter by action type (e.g., CREATE, UPDATE, DELETE)
Maximum number of records to return
Response
Array of activity records
Total number of activities returned
Activity object structure
User who performed the action
Description of the action performed
Detailed information about the action
Type of entity affected (e.g., Product, Employee, Sale)
ID of the affected entity
Action category (CREATE, UPDATE, DELETE, etc.)
ISO 8601 timestamp of the action
Example request
curl -X GET "https://api.example.com/api/useractivity?startDate=2024-02-01T00:00:00Z&endDate=2024-02-28T23:59:59Z&limit=100" \
-H "Content-Type: application/json"
Example response
{
"activities": [
{
"id": 1234,
"userId": 1,
"userName": "Manager",
"action": "Created product: Premium Coffee Beans",
"details": "Barcode: 1234567890, Price: $24.99, Stock: 100",
"entityType": "Product",
"entityId": 5,
"actionType": "CREATE",
"ipAddress": "192.168.1.100",
"timestamp": "2024-02-28T10:30:00Z"
},
{
"id": 1235,
"userId": 2,
"userName": "Cashier",
"action": "Processed sale: 2x 5 - Total: $54.98",
"details": "Payment: Cash, Items: 1, Discount: $0.00",
"entityType": "Sale",
"entityId": 123,
"actionType": "SALE",
"ipAddress": "192.168.1.101",
"timestamp": "2024-02-28T11:15:00Z"
},
{
"id": 1236,
"userId": 1,
"userName": "Manager",
"action": "⚠️ MAJOR PRICE CHANGE: Premium Coffee Beans",
"details": "Critical price adjustment: $24.99 → $29.99 (+20.0%) - Product: 1234567890 - Requires review",
"entityType": "Product",
"entityId": 5,
"actionType": "PRICE_CHANGE_MAJOR",
"ipAddress": "192.168.1.100",
"timestamp": "2024-02-28T14:45:00Z"
}
],
"totalCount": 3
}
Get activity summary
Retrieve aggregated activity statistics.
GET /api/useractivity/summary
Query parameters
Filter from this date (ISO 8601 format)
Filter to this date (ISO 8601 format)
Response
Total number of activities in period
Number of unique users who performed actions
Breakdown of activities by type
Most active users (top 10)
Activity type summary structure
Number of actions of this type
User activity count structure
Number of activities by this user
Example request
curl -X GET "https://api.example.com/api/useractivity/summary?startDate=2024-02-01T00:00:00Z&endDate=2024-02-28T23:59:59Z" \
-H "Content-Type: application/json"
Example response
{
"totalActivities": 1250,
"uniqueUsers": 8,
"activityTypes": [
{
"actionType": "SALE",
"count": 450
},
{
"actionType": "UPDATE",
"count": 320
},
{
"actionType": "CREATE",
"count": 180
},
{
"actionType": "DELETE",
"count": 25
},
{
"actionType": "PRICE_CHANGE_MAJOR",
"count": 12
}
],
"topUsers": [
{
"userId": 2,
"userName": "Cashier 1",
"activityCount": 420
},
{
"userId": 3,
"userName": "Cashier 2",
"activityCount": 385
},
{
"userId": 1,
"userName": "Manager",
"activityCount": 245
}
]
}
Activity types
The system tracks these action types:
Product activities
CREATE - Product created
UPDATE - Product updated
DELETE - Product deleted
PRICE_CHANGE_MAJOR - Significant price change (>20%)
Employee activities
CREATE - Employee account created
UPDATE - Employee details updated
ACTIVATE - Employee account activated
DEACTIVATE - Employee account deactivated
PIN_RESET - Employee PIN reset
Sales activities
SALE - Sale transaction processed
Returns activities
CREATE - Return processed
Inventory activities
CREATE - Inventory count started
COMPLETE - Inventory count completed
CANCEL - Inventory count cancelled
DISCREPANCY - Significant inventory discrepancy found
Stock adjustment activities
CREATE - Stock adjustment created
APPROVE - Stock adjustment approved
Settings activities
UPDATE - Settings updated
CREATE - Initial settings created
Use cases
Security audit
Track all user actions for security and compliance:
curl -X GET "https://api.example.com/api/useractivity?userId=1&actionType=DELETE" \
-H "Content-Type: application/json"
Price change review
Monitor significant price changes:
curl -X GET "https://api.example.com/api/useractivity?actionType=PRICE_CHANGE_MAJOR" \
-H "Content-Type: application/json"
Employee activity report
Generate activity report for a specific employee:
curl -X GET "https://api.example.com/api/useractivity?userId=2&startDate=2024-02-01T00:00:00Z&endDate=2024-02-28T23:59:59Z" \
-H "Content-Type: application/json"
Inventory discrepancy tracking
Find all inventory discrepancies:
curl -X GET "https://api.example.com/api/useractivity?actionType=DISCREPANCY" \
-H "Content-Type: application/json"