Automation of MailFlow Status Report via REST

Copper Contributor

Hi, I am looking for a way to automate the pulling of the MailFlow Status report but I've not been able to find anything that works. There appears to be an old reporting service on https://reports.office365.com however I've read reports its end of life and there is no useful documentation for it.

 

The main metrics I'm looking to export on a monthly basis are: Total mail in/out, Total spam detected in, Total Malware in etc. I'd need these details filtered for the previous month (01/xx/xx - 31/xx/xx) so can use this in our business wide reporting and would need to be available via a REST API.

Is this information available via the Graph? From what I can see under the https://graph.microsoft.com/beta/reports/ endpoint there doesn't seem to be a useful report. What are other organisations doing in this space to report on these metrics outside of the Microsoft ecosystem? From what I have found the only option is to download the excel data after running the GUI report each month manually. Can anyone point me in the right direction, it seems impossible this isn't available somewhere in way that can be automated, it is 2022 after all. 

5 Replies
It's not going away yet, in fact they added OAuth support for it recently: https://www.michev.info/Blog/Post/4067/modern-authentication-oauth-support-for-the-reporting-web-ser...
The alternative is to get the full span of message trace events and built the reports yourself.

@Vasil Michev Do you know where the updated/latest documentation is so I can figure out whether or not the MailFlowStatus report is going to give me the specific details I need and what odata filters I can use to set a start & end date for the data or whether I need to message trace every message and build the numbers myself. So far after just playing around with the endpoints I cant figure out how to get more than 7 days worth of data. Until I read your OAuth notes I didn't even know the $metadata endpoint existed. Seems very weird that the modern UI reports are not available via any kind of documented API or on the Graph.

The UI reports are not based on this data afaik, they use an internal API we don't have access to. The documentation for the old reporting web service hasn't changed, the only bits they've updated in the past few years are the OAuth support ones. https://learn.microsoft.com/en-us/previous-versions/office/developer/o365-enterprise-developers/jj98...)

Hmm getting a 404 on that link, looks like it may not have copied all of it.

 

In that case do you know what filter options I have to do on the MailFlowStatus to get say 01/10/22 to 31/10/22 stats? Every option I try ends up as a filter error based on random articles I've found online (they are however for different reports so I'm not surprised the options are slightly different). Making random attempts along the following lines hasn't yielded any results
https://reports.office365.com/ecp/ReportingWebService/Reporting.svc/MailFlowStatus?$format=json&$fil... 

The forum formatted the closing ), you should add it as part of the URL.
It doesn't look like this report supports startdate/enddate filter. On the positive side, the same data is exposed via Get-MailFlowStatusReport.