Sending Images over SMS

Last updated: 2021-06-16 Contributors Paco VuNoneByrne Reese
Edit this page

One can send images and other files via SMS as well. Doing so requires developers to POST to the sms endpoint using multipart form-data, or attachments. In the following example we will transmit an image called test.jpg along with the text message, "hello world."

Creating Attachments

When assembling a multipart message, it is important to remember that the root part, or first part of the request is always the request body or payload. Subsequently you attach images and files to the request. You can see how this is done via the code samples below.

Attachment Limitations

  • There is a combined limit of 1.5M bytes for all attachments.
  • There is a limit of 10 attachments for any request.
const RingCentral = require('@ringcentral/sdk').SDK
const FormData = require('form-data')

const rcsdk = new RingCentral({
  server: "server_url", appKey: "client_id", appSecret: "client_secret"

var platform = rcsdk.platform();

platform.login({username: "username", extension: "extension_number", password: "password"})

platform.on(, async function(){

async function send_mms(){
var FormData = require('form-data');
formData = new FormData();
var body = {
  from: {'phoneNumber': "user_phone_number"},
  to: [{'phoneNumber': "recipient_phone_number"}]

formData.append('json', new Buffer.from(JSON.stringify(body)), {
    filename: 'request.json',
    contentType: 'application/json'

formData.append('attachment', require('fs').createReadStream('test.jpg'));
try {
  var resp = await'/restapi/v1.0/account/~/extension/~/mms', formData)
  var jsonObj = await resp.json()
  console.log("MMS sent. Message status: " + jsonObj.messageStatus)
  console.log('Message Id: ' +
}catch (e){
from ringcentral import SDK
sdk = SDK( "client id", "client_secret", "server_url" );
platform = sdk.platform()
platform.login( "username", "extnsion_number", "password" )
builder = sdk.create_multipart_builder()
    'from': {'phoneNumber': "username"},
    'to': [{'phoneNumber': "recipient_number"}],
    'text': "Hello World"
image = open ('test.jpg', 'rb')
attachment = ('test.jpg', image, 'image/jpeg')
    request = builder.request('/account/~/extension/~/sms')
    response = platform.send_request(request)
except Exception as e:
$rcsdk = new RingCentral\SDK\SDK("client id","client_secret","server_url");
$platform = $rcsdk->platform();
$platform->login( "username", "extension_number", "password" );
$body = array(
   'from' => array( 'phoneNumber' => "username" ),
   'to'   => array( array('phoneNumber' => "receiver" ) ),
   'text' => 'Hello world'
$request = $rcsdk->createMultipartBuilder()
    ->setBody( $body )
    ->add(fopen(__DIR__.'/test.jpg', 'r'))
$r = $platform->sendRequest($request);

Rate this page: