Send an MMS

In this code snippet you will see how to send an MMS using the Messages API.

IMPORTANT: Only US short codes, 10DLC numbers and SMS Enabled Toll Free Numbers are currently supported for sending MMS. For US short codes, MMS messages can be sent to AT&T, T-Mobile (previously Sprint), and Verizon networks in the US. Find out more about setting up 10DLC numbers (note: this page references the SMS API, but the contents of the 10 DLC guidelines section also apply to the Messages API).

Message throughput, deliverability, and SMS message volumes may vary depending on the type of number used. For more information on this, and on MMS in general, see the Vonage MMS overview page, the Vonage 10DLC overview page, and the Vonage Phone Numbers overview page.

Example

Find the description for all variables used in each code snippet below:

KeyDescription
VONAGE_APPLICATION_ID

The Vonage Application ID.

VONAGE_APPLICATION_PRIVATE_KEY_PATH

Private key path.

VONAGE_PRIVATE_KEY_PATH

Private key path.

FROM_NUMBER

The phone number you are sending the MMS from. (US Short Code, 10DLC number, or SMS Enabled Toll Free Number)

VONAGE_NUMBER

Refer to FROM_NUMBER above

VONAGE_FROM_NUMBER

Refer to FROM_NUMBER above

TO_NUMBER

The number you are sending the to in E.164 format. For example 447700900000.

IMAGE_URL

The URL of the media you want to send. Accepted file formats are .jpg, .jpeg, .png, and .gif.

NOTE: Don't use a leading + or 00 when entering a phone number, start with the country code, for example 14155550105.

Prerequisites

If you do not have an application you can create one. Make sure you also configure your webhooks.

Write the code

Add the following to send-mms.sh:

curl -X POST https://api.nexmo.com/v1/messages \
  -H 'Authorization: Bearer '$JWT\
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d $'{
            "message_type": "image",
            "image": {
                "url": "https://example.com/image.jpg"
            },
            "to": "'$TO_NUMBER'",
            "from": "'$FROM_NUMBER'",
            "channel": "mms"
}'

View full source

Run your code

Save this file to your machine and run it:

bash send-mms.sh

Try it out

When you run the code an MMS message is sent to the destination number.