Example of sending an MMS message using AWS End User Messaging SMS - AWS End User Messaging SMS

Example of sending an MMS message using AWS End User Messaging SMS

If you are using a shared resource then you must use the full Amazon Resource Name (ARN) of the resource. You can use the AWS CLI or AWS End User Messaging SMS and voice v2 API to send MMS messages to your customers.

Use the send-media-message AWS CLI command to send an MMS message. For more information on configuring the AWS CLI, see Configure the AWS CLI in the AWS Command Line Interface User Guide.

Important

MMS capabilities are only available in some countries. For more information on supported countries for SMS and MMS, see Supported countries and regions for SMS messaging with AWS End User Messaging SMS and Supported countries and regions for MMS messaging in AWS End User Messaging SMS.

To check if you origination identity is MMS capable, see View a phone number status and capabilities in AWS End User Messaging SMS.

Before sending an MMS message you need to upload your media files to an Amazon S3 bucket that is in the same AWS Region as your MMS capable origination identity, see Setting up an Amazon S3 bucket for MMS files.

The identity used to call send-media-message must have read access to the Amazon S3 bucket that contains your media files. For more information on setting read access, see Identity-based policy examples for Amazon S3 in the Amazon S3 User Guide.

To use a shared resource you must use the full Amazon Resource Name (ARN).

To send an MMS message
  • At the command line, enter the following command:

    aws pinpoint-sms-voice-v2 --region 'us-east-1' send-media-message --destination-phone-number +12065550150 --origination-identity +14255550120 --message-body 'text body' --media-urls 's3://s3-bucket/media_file.jpg'

    In the preceding command, make the following changes:

If AWS End User Messaging SMS accepts the command you will receive the MessageID. This only means the command was successfully received and not that the destination device has received the message yet. For a list of error codes, see SendMediaMessage Errors.

{ "MessageId": "string" }

Setting up an Amazon S3 bucket for MMS files

Your MMS files must be stored in an Amazon S3 bucket. The Amazon S3 bucket must be in the same AWS account and AWS Region as your MMS capable origination identity. These directions show how to create an Amazon S3 bucket, upload a file, and build the URI to the file. For more information on Amazon S3 commands, see Use high-level (s3) commands with the AWS CLI. For more information on configuring the AWS CLI, see Configure the AWS CLI in the AWS Command Line Interface User Guide.

To create an Amazon S3 bucket use the create-bucket AWS CLI command. At the command line, enter the following command:

aws s3api create-bucket --region 'us-east-1' --bucket BucketName

In the preceding command:

  • Replace us-east-1 with the AWS Region your MMS capable origination identity is in.

  • Replace BucketName with the name of the new bucket.

To copy a file to the Amazon S3 bucket use the cp AWS CLI command. At the command line, enter the following command:

aws s3 cp SourceFilePathAndName s3://BucketName/FileName

In the preceding command:

  • Replace SourceFilePathAndName with the file path and name of the file to copy.

  • Replace BucketName with the name of the bucket.

  • Replace FileName with the name to use for the file.

The URI to use when sending is:

s3://BucketName/FileName