Hello @pranjal sharma,
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
3. Delete the message through powershell
Here is the detailed steps - https://docs.microsoft.com/en-us/office365/securitycompliance/search-for-and-delete-messages-in-your...
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!
Adam