iPhones don't let apps read your texts, so there's no SMS API to call. What iOS does have is Shortcuts: a Message automation can run an action every time a text arrives, even with the phone locked. Point that action at an HTTPS endpoint and every new text becomes a POST request you can do anything with.
I make Fwrd , an iPhone app whose Shortcuts action does exactly this: it posts each text to a webhook you own (or to Slack, Discord, Telegram, Teams, email and a few others). There's no Fwrd account and no Fwrd server in between; the iPhone sends the request straight to your URL.…