sharepoint online – Removing a siteuser from a site collection using REST API

I am posting this information in case anyone else is trying to build a process like this.

I was trying to manage the users of my site collections and make sure that only active accounts have access. I have a Flow in Power Automate that is able to pull a list of users from the site collection _api/web/siteusers?$filter=PrincipalType%20eq%201%20and%20UserPrincipalName%20ne%20null&$Select=id,Title,Email,UserPrincipalName and then searches for them using the O365 Action by UPN. When this action fails, I know that the user is no longer an active user and they should be removed from the site collection. I then log the information of that user into an array for reporting. After that I send an HTTP action to SharePoint to remove that user from the site collection. The URI for this action or endpoint is _api/web/siteusers/removebyid('###'). An approval process could be added to this to make sure that users are not accidently deleted.

Hopefully this helps anyone else like it helped me!