Thanks for asking the Apple Support Communities for help restoring your deleted messages.
iMessages and SMS messages are sent from your provider, then removed off their servers. This is different than emails, as most email accounts these days are set up as IMAP accounts, which means the email is stored in the Email Service Provider server, and also downloaded to your devices.
You do have the option to restore your text messages by fully restoring your iPhone from a iCloud or iTunes backup though. Please be aware that any data added to the phone since the date of the backup you are restoring from will be replaced by the data saved in the backup.
You may wish to make a current backup prior restoring. If you are planning on restoring your device from your iCloud backup, to ensure the current data on your device is saved, make a separate iTunes backup, or vice versa. This help article has both backup options: How to back up your iPhone, iPad, and iPod touch