How do I add a line break in my SMS message?

New line encoding differs a bit depending on the terminating carrier, but the following are the methods that we find work most consistently for the types of SMS messages you can send:

  • For sending outbound SMS messages via the REST API, it is best to encode a new line as %0a. For example, you could send a message like the following:
    $ curl -X POST{AccountSid}/SMS/Messages.json \ -d "To=%2b14154445555" \ -d "From=%2b14156667777" \ -d "Body=Here+is+my+first+line%0aHere+is+my+second+line" \ -u '{AccountSid}:{AuthToken}'
  • In a TwiML reply the best way to insert a line break is to just use a new line. For example:
    <?xml version="1.0" encoding="UTF-8"?>
        <Sms>Here is my first line 
         Here is my second line.</Sms>

These examples should deliver a message with “Here is my first line” on one line and “Here is my second line.”

Note: If you are using one of the official Twilio helper libraries to send SMS messages, they will take care of encoding new lines present in strings as "\n".

Have more questions? Submit a request
Powered by Zendesk