If you're looking to apologize to your boyfriend in a text message, here's an example of how you could do it:
"Hey [boyfriend's name], I just wanted to say I'm sorry for [what you did wrong]. I know my actions hurt you, and that wasn't my intention. I feel terrible about it and I'm willing to do whatever it takes to make things right between us. I hope you can forgive me."
It's important to acknowledge your mistake and take responsibility for your actions. Let your boyfriend know that you understand how your behavior affected him, and express your willingness to make things right.