Sending an SMS with Unicode

The Vonage SMS API supports Unicode characters too, which you will need to use when communicating with customers in Chinese, Japanese and Korean.

To send an SMS that contains Unicode characters, replace the following variables in the example below:

KeyDescription
VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

VONAGE_BRAND_NAME

The alphanumeric string that represents the name or number of the organization sending the message.

TO_NUMBER

The phone number you are sending the message to.

Write the code

Add the following to send-an-sms-with-unicode.sh:

curl -X POST https://rest.nexmo.com/sms/json \
  -d "from=${SMS_SENDER_ID}" \
  -d "to=${SMS_TO_NUMBER}" \
  -d 'text=こんにちは世界' \
  -d 'type=unicode' \
  -d "api_key=${VONAGE_API_KEY}" \
  -d "api_secret=${VONAGE_API_SECRET}"

View full source

Run your code

Save this file to your machine and run it:

sh send-an-sms-with-unicode.sh

Try it out

When you run the example above, the text message will be sent to the mobile number specified with the Unicode characters intact.

Note that Unicode messages can only contain 70 characters, rather than the usual 160. There's more information about this on the help page

Further reading