Login with Mobile and OTP

I currently have a method with a third party service which sends an OTP to a mobile number and then verifies the OTP entered with the session ID returned. I now want to use this to create a custom login flow which only requires the user to enter their mobile number and then login after entering their OTP.

I intend to use this authentication method for a mobile app. Is there a way to create a custom API endpoint for this? To log a user into the platform without needing an email/username and password