I know you are asking about API/code way to do this, but i did not have much luck finding that. In an effort to give you more information that may help your search, I wanted to give you the steps to do this in O365, and hopefully that can help you figure out if there are API ways to do this.
To delete a message in O365, its actually a multi-step process through the security and compliance center. (you also need a specific permission granted to do this, ediscovery admin)
1. Create a content search in O365 for the data in question. (based on your search and tenant size this can take anywhere from a min or two, to significantly longer).
2. Login to the Security and Compliance center on O365 via powershell
I tried to find the graph API commands to correlate to this, and did not have much luck. Maybe having the steps of what you need to do as an admin can help you in your research to find the API commands. Goodluck!
Actually I am using cmdlet Search-mailbox currently but this makes my code OS and powershell dependent, so I am looking for other option. Graph APIs I tried but not able to succeed in achieving the same.