function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Access to Setup Audit Trail via APEX / Webservice API



I have been looking for a way to access the setup audit trail programatically, using apex or webservice api. But without any luck. 

Is there a way to achieve this.. 


Maybe by using some URL Tricks ?


The basic requirement is to get a list of all the actions performed by a user in a given time (as displayed in the setup audit trail). It would be great if I could simply query that from some Table ?


Any Ideas , Leads, Comments please.




You can't query this table directly, although you could, if you were so inclined, use a PageReference to the link and call the getContent function. This should allow you to retrieve the contents of the audit trail as a CSV. I'm not entirely sure how reliable this method would be, but in lieu of a standard API, your options are fairly limited. And you would have to process each row instead of filtering by user.

four years later - still nothing?
Ashutosh LAshutosh L
Vote for this Idea:
Andy In The CloudAndy In The Cloud
Starting with Winter'16 the SetupAuditTrail object ( has now been exposed via the Salesforce API's and within Apex via SOQL. Its pretty much a mirror of the CSV download, accept for the Delegate User (though since this is documented, this could be a bug or something i'm missing). The following is a sample query from my latest blog ( where i dig into it a little further...

List<SetupAuditTrail> stuffDoneByConsultants = 
    [SELECT Id,
     FROM SetupAuditTrail 
     WHERE CreatedBy.Email LIKE ''];