API to get roles, access profile and entitlement to users and remove it all from from identity

If you can use Workflow, look at Workflow to remove ALL leavers' standing access which fulfil your requirement.