I want to do one research in salesforce agent How can we get details of the audit stuff and admin activities .. not the data part but details like-
- how many users we have
- Active/disabled users
- Login location
- And there are other logs as well ?
- Apex log as well
What else we can get in apis ..
HI@Priyanka Joshi, Great questions! Salesforce provides several APIs and tools to help you research and monitor audit and admin activities. Here's an overview of what you can access, how, and what else is available:
1. User Information
- How many users we have: Use the REST API or Tooling API to query the User object.
- Active/Disabled users: Query the User object, filter by IsActive field.
SELECT Id, Name, IsActive FROM User
Login location:
Check the LoginHistory object for login details, including location info (IP address, login time).
SELECT UserId, LoginTime, SourceIp, Application FROM LoginHistory
2. Audit & Admin Activities
A. Setup Audit Trail
- Tracks admin changes (e.g., profile changes, permission sets, settings updates).
- Accessible via the Salesforce UI and SetupAuditTrail object in API.
B. Login History
- Accessible via LoginHistory object (as above).
- Provides details about user logins, including status, IP, and time.
C. Field History Tracking
- If enabled, you can query field history objects for individual records.
D. Event Monitoring
- Provides detailed logs (e.g., API usage, report exports, login events).
- Requires Event Monitoring license.
- Access via REST API or Bulk API.
- Includes:
- Report and Dashboard usage
- Login and Logout events
- API calls
- Apex executions
- Data exports
3. Apex Logs
- Debug Logs: Use the ApexLog object to query logs, or access via Tooling API.
SELECT Id, LogUserId, Operation, DurationMilliseconds, Status FROM ApexLog
4. Other Logs & Audit Objects
- SetupEntityAccess: Tracks admin access to setup objects.
- ApiUsage: Monitors API call counts.
- UserLogin: (Enhanced version of LoginHistory, available in some orgs.)
5. How to Access via APIs
- REST API: Query objects with /services/data/vXX.X/query/?q=SOQL_QUERY
- Tooling API: For developer logs and metadata changes.
- Bulk API: For large datasets.
- Event Monitoring: For advanced audit logs (requires license).
6. What Else Can You Get?
- Permission Set Assignments
- Profile changes
- Data exports
- Object schema changes
- Connected app usage
- Failed login attempts
- Session details
- Report exports
- API usage logs
References
Regards,
@Raju Petluri