Skip to main content
This guide shows how to receive MMS messages on a Plivo phone number. You can do this using Plivo’s APIs.
Here’s how to use Plivo APIs to receive MMS multimedia messages.

How it works

When someone sends an MMS to your Plivo number, Plivo forwards the message details, including the media URL, to a web server you control. Your server can then process this information.Receive MMS API workflow

Prerequisites

To get started, you need a Plivo account — sign up if you don’t have one. You must also have a Plivo phone number that supports MMS. You can rent one from the Numbers page in the console or by using the Numbers API.

1. Create a server to receive MMS messages

First, create a web server that can receive POST requests from Plivo. The code below shows how to start a basic server that logs the From and To numbers, the Text body, and the Media0 URL from an incoming MMS.Select your programming language to see the specific code.
If this is your first time using Plivo APIs with Node.js, follow our instructions to set up your development environment.Create a file called receive_mms.js and paste this code into it.
const express = require('express');
const bodyParser = require('body-parser');
const app = express();

app.use(bodyParser.urlencoded({ extended: true }));

app.all('/receive_mms/', (request, response) => {
    const from_number = request.body.From;
    const to_number = request.body.To;
    const text = request.body.Text;
    const media_url = request.body.Media0;
    console.log('Message received - From: %s, To: %s, Text: %s, Media: %s', from_number, to_number, text, media_url);
    response.status(200).send('Message received');
});

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});

2. Expose your local server to the internet

Once your server is running, make it accessible from the public internet so Plivo can send requests to it. We recommend using a tunneling service like ngrok for development.
$ ngrok http 3000 
# The port number should match the port your server is running on
Ngrok will provide a public URL (e.g., https://<unique-id>.ngrok-free.app) that forwards traffic to your local server.

3. Create a Plivo application

A Plivo application tells Plivo how to handle events like incoming messages.
  1. Navigate to Messaging > Applications in the Plivo console and click Add New Application.
  2. Give the application a name, like Receive MMS App.
  3. Enter your server’s public URL into the Message URL field (e.g., https://<unique-id>.ngrok-free.app/receive_mms/) and set the method to POST.
  4. Click Create Application. Create Plivo Application for MMS

4. Assign a Plivo number to your application

To start receiving messages, you must assign a Plivo phone number to the application.
  1. Go to the Numbers page and select the number you want to use.
  2. In the Application Type drop-down, select XML Application.
  3. From the Plivo Application drop-down, select Receive MMS App.
  4. Click Update Number. Assign Phone Number to MMS App

5. Test it out

Send an MMS message from your mobile phone to the Plivo number you assigned to the application. Your local server’s console should print a log with the message details.