Text messages have a reputation for being informal and inconsequential, but you can sometimes have some really critical information in there! If you deleted some texts to clear up space on your iPhone and—whoops!—accidentally got rid of one that's important, all hope is not lost.
There are three potential avenues for recovering a deleted text message. You can restore your iPhone to a time before the message was deleted, you might be able to contact your phone provider, and you may be able to use a third-party app. Here's a brief explanation of all three options.
Recover deleted texts using an iCloud backup
This is probably the simplest and fastest way to restore missing texts. If you have an iCloud backup from the time before you deleted the text, you should be able to get it back by restoring your phone to that iCloud backup.
Open Settings, tap on your Apple ID card at the top, select iCloud > Manage Storage > Backups. You'll see a list of backups for your devices and can tap on the one for your iPhone to see when it was last backed up.
Now comes the annoying part. You'll have to reset your iPhone to factory settings and set it up again, choosing to restore from your iCloud backup during the process. Note that you'll lose everything from after the backup, so I hope those texts really are important!
To reset your iPhone go to General > Reset > Erase All Content and Settings. Once your iPhone restarts and begins the setup process, choose to restore from an iCloud backup and pick the backup from before you erased your text message.
Recover deleted texts from an iTunes or Finder backup
If you don't want to rely on automatic iCloud backups, or don't have enough iCloud storage space for them, you can back up your iPhone to your PC or Mac using iTunes (or Finder in macOS Catalina or later). Just as with the previous iCloud method, this requires having a backup from before you deleted the message and the resetting your phone, restoring from that backup. You'll lose everything from after the backup.
Connect your iPhone to the PC or Mac you've backed it up with. If iTunes does not open automatically, open it up manually. (If you're on a Mac running Catalina or later, open Finder instead.)
Click on the iPhone icon in the top left-hand corner. On a Mac running macOS Catalina or later, select your device from the lefthand menu bar in Finder.
Now choose Restore Backup. All the data you previously backed up will now replace the data on your phone. It will take a few minutes. As long as you haven't backed up since deleting those text messages, they should now appear in the normal messaging list on your phone.
Restore deleted texts by contacting your carrier
Your cell provider may keep a record of text message you send, at least for awhile. If you've deleted a text message that is really critical, you might be able to call your carrier to get a copy of it.
Note that this will only work for SMS text messages (green bubble conversations), not iMessages (blue bubble conversations), since those are end-to-end encrypted and your carrier doesn't keep a record of them.
You may need to jump through a bunch of hoops to prove your identity, or even get permission from the other party you were texting. And most carriers only keep records of SMS messages for a limited time—you're not likely to ever be able to recover a message from a year ago.
But as a last resort, getting a copy of your SMS messages from your carrier is a possibility, and it's worth calling the customer support number to ask about it.
Restore deleted texts using a third-party app
There are quite a few third-party software tools that promise to let you restore deleted data on your iPhone, including deleted texts. It's a bit of a risk—they're almost never free and there's no guarantee they'll even work. But if you've exhausted all other options, it may be worth a shot.
Some of the options with a good reputation online are PhoneRescue, Wondershare Dr. Fone, and Tenorshare UltData. Much of the time, a deleted message on your iPhone is actually still there in the flash storage, waiting to be overwritten by new data. If that's the case, one of they programs may be able to restore it.