Send an MMS

Send messages to mobile phones with image and a long text message.

Request

POST https://api.46elks.com/a1/mms

Request parameters

Parameter Example Description
to +46700000000 The phone number of the recipient, in E.164 format.
from +46700000000
noreply
The phone number to send from. Must be an MMS-enabled Virtual Phone Number or the text "noreply". We will replace the sender id with a random phone number if "noreply" is used.
message Hi! This is a message to your phone! A message to be sent with the MMS. Either message or image must be present in the API request.
image http://yourapp.example/image.jpg
data:image/png;base64,iVBOR...
Either a data URL or a publicly accessible URL that points to an image. GIF, PNG and JPEG images are supported. Either image or message must be present in the API request.

Sample code

curl https://api.46elks.com/a1/MMS \
  -u <Username>:<API Password> \
  -d from=+46700000000 \
  -d to=+46700000000 \
  -d image="https://yourserver.example/images/treasuremap.jpg"
import HTTPotion.base
authdata = [basic_auth: {'',

request = %{
            "from"    => "+46700000000",
            "to"      => "+46700000000",
            "image"   => "https://yourserver.example/images/treasuremap.jpg"
           }

request_data = URI.encode_query(request)

HTTPotion.start
HTTPotion.post("https://api.46elks.com/a1/MMS",
  [body: request_data , ibrowse: authdata]
)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

public class UnirestSendMMS {
  public static void main(String[] args) {
    try {
      System.out.println("Sending MMS");

      HttpResponse response = Unirest.post("https://api.46elks.com/a1/MMS")
        .basicAuth("","")
        .field("to", "+46700000000")
        .field("from", "+46700000000")
        .field("image", "https://yourserver.example/images/treasuremap.jpg")
        .asString();

      System.out.println(response.getBody());
      }

    catch (Exception e){
        System.out.println(e);
    }
  }
}
function sendMMS ($mms) {
  $username = "USERNAME";
  $password = "PASSWORD";
  $context = stream_context_create(array(
    'http' => array(
      'method' => 'POST',
      'header'  => 'Authorization: Basic '.
                   base64_encode($username.':'.$password). "\r\n".
                   "Content-type: application/x-www-form-urlencoded\r\n",
      'content' => http_build_query($mms,'','&'),
      'timeout' => 10
  )));
  $response = file_get_contents("https://api.46elks.com/a1/MMS",
    false, $context);

  if (!strstr($http_response_header[0],"200 OK"))
    return $http_response_header[0];
  return $response;
}
$mms = array(
  "from" => "+46700000000",   /* You need an mms enabled phone number */
  "to" => "+46700000000",  /* The mobile number you want to send the image to */
  "image" => "https://yourserver.example/images/treasuremap.jpg",
);
echo sendMMS($mms);
import requests

auth = (
    '',
    ''
    )

fields = {
    'from': '+46700000000',
    'to': '+46700000000',
    'image': 'https://yourserver.example/images/treasuremap.jpg'
    }

response = requests.post(
    "https://api.46elks.com/a1/MMS",
    data=fields,
    auth=auth
    )

print(response.text)
const axios = require("axios");

const sendMMS = async credentials => {
    try {
        const res = await axios.post(
            "https://api.46elks.com/a1/mms",
            new URLSearchParams({
                from: "noreply",
                to: "+46766860002",
                message: "Bring a sweater, it’s cold outside!",
                image: "https://46elks.com/press/46elks-blue-png"
            }), {
                headers: {
                    "Authorization": "Basic " + credentials
                }
            });
        console.log(res.data);
    } catch (err) {
        console.log(err);
    }
}

const username = "USERNAME";
const password = "PASSWORD";
const authKey = Buffer.from(username + ":" + password).toString("base64");

sendMMS(authKey);
require 'net/http'

uri = URI('https://api.46elks.com/a1/MMS')
req = Net::HTTP::Post.new(uri)
req.basic_auth '', ''
req.set_form_data(
  :from => '+46704508449',
  :to => '+46704508449',
  :image => 'https://yourserver.example/images/treasuremap.jpg'
)

res = Net::HTTP.start(
    uri.host,
    uri.port,
    :use_ssl => uri.scheme == 'https') do |http|
  http.request req
end

puts res.body

More examples
C - C# - Go - Google App Script - Haskell - Node.js - Postman

Response

Example JSON response
{
  "direction": "outgoing",
  "from": "+46766861218",
  "created": "2016-11-03T12:44:56.180704",
  "to": "+46700000000",
  "cost": 12500,
  "message": "Hej!",
  "id": "mf3d05c159aa49e1951c5301bc6af1bac"
}
Attribute Type Description
id string The unique id of the message in our systems.
from string The phone number the MMS was sent from.
to string Phone number that the MMS was sent to.
message string The text message if the MMS contains text.
created string The time in UTC when the MMS object was created in our systems.
cost integer The cost of sending the MMS. Specified in 10000s of the currency of the account (SEK or EUR). For example, for an account with currency SEK, a cost of 3500 means that the cost was 0.35SEK.

Image formats

PNG and JPG image formats are supported by the API. There is no hard limit on the size of an image but the total payload size of the MMS (text + images or other media) cannot exceed 320kB.

MMS vs. SMS

MMS uses completely different protocols than SMS and some features of SMS are not part of the MMS standard, for example delivery reports, alphanumeric senders and multipart messages.