Programmable Fax Quickstart

Twilio's Programmable Fax lets you send and receive faxed documents in your web applications. Many workflows today still depend upon fax - now you can make those interactions more dynamic with your custom code. Let's get started!

Getting Started

Before you can commence world domination via facsimile, you'll need a Twilio phone number capable of sending and receiving faxes. In the Twilio Console (sign up for a Twilio account if you haven't already), you can search for phone numbers capable of sending and receiving faxes.

Search for fax numbers

Buy a number from the list by clicking the "Buy" button.

Buy Fax-enabled number

Now that you have a fax-capable number, let's look at how we can send faxes using the REST API.

Send a fax

Sending a fax requires a Twilio account SID and auth token. You can find these authentication credentials on your Console dashboard. Your API request will use these credentials for HTTP basic authentication. There are three parameters that you must also pass along with your request.

  1. From - the Twilio number the fax will be sent from. Use the one you bought in the console before.
  2. To - the number you'd like to send the fax to.
  3. MediaUrl - a fully qualified URL to a PDF document you'd like to send as the content for a fax.

Note: You should pass your phone numbers to the API in the E.164 format. For our curl example we manually encoded the "+" sign at the beginning of each phone number to its encoded value, "%2B".

Another Note: While Programmable Fax is still in Beta, you'll need to use the "alpha" branch of your favorite language's Twilio helper library in order to use the Fax APIs.

Loading Code Samples...
Language
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Install the Java helper library from twilio.com/docs/libraries/java
import com.twilio.Twilio;
import com.twilio.rest.fax.v1.Fax;
import com.twilio.rest.fax.v1.FaxCreator;
import java.net.URI;
import java.net.URISyntaxException;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) throws URISyntaxException {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

        String from = "+15017250604";
        String to = "+15558675309";
        URI mediaUrl = new URI("https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf");
        FaxCreator faxCreator = Fax.creator(to, mediaUrl);
        faxCreator.setFrom(from);
        Fax fax = faxCreator.create();

        System.out.println(fax.getSid());
    }
}
from twilio.rest import Client

# put your own credentials here
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

fax = client.fax.v1.faxes.create(
    from_="+15017250604",
    to="+15558675309",
    media_url="https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf")

print(fax.sid)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Fax.V1;
using Twilio.Types;
using System.Collections.Generic;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var to = "+15558675309";
        var mediaUrl = new Uri(
            "https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf");

        var fax = FaxResource.Create(to, mediaUrl, from: "+15017250604");

        Console.WriteLine(fax.Sid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$options = array(
  "from" => "+15017250604"
);
$fax = $client->fax->v1->faxes->create(
    "+15558675309",
    "https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf",
    $options
);

echo $fax->sid;
require 'net/http'
require 'json'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

uri = URI('https://fax.twilio.com/v1/Faxes')

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

  request = Net::HTTP::Post.new uri.request_uri
  request.basic_auth account_sid, auth_token
  request.body = URI.encode_www_form({
    :To => '+15558675309',
    :From => '+15017250604',
    :MediaUrl => 'https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf'
  })

  response = http.request request

  puts JSON.parse(response.body)['sid']
end
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.fax.v1.faxes
  .create({
      to: '+15558675309',
      from: '+15017250604',
      mediaUrl: 'https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf'
  }).then(function(response) {
    console.log(response.sid);
  }).catch((err) => {
    console.log(err)
  });
curl 'https://fax.twilio.com/v1/Faxes' \
    -X POST \
    -d 'To=%2B15558675309'  \
    -d 'From=%2B15017250604'  \
    -d 'MediaUrl=https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
	"status": "queued",
	"direction": "outbound",
	"from": "+15017250604",
	"date_updated": "2017-04-06T06:39:15Z",
	"price": null,
	"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"to": "+15558675309",
	"date_created": "2017-04-06T06:39:15Z",
	"url": "https://fax.twilio.com/v1/Faxes/FX4ac3612393b5a66f11c73a148f956a5c",
	"sid": "FX4ac3612393b5a66f11c73a148f956a5c",
	"duration": null,
	"num_pages": null,
	"quality": "fine",
	"price_unit": null,
	"api_version": "v1",
	"media_url": null
}
Send an outbound fax

Within moments, your fax should be happily on its way to a lucky recipient. To get updated on the status of the fax (including when sending failed), you can specify a StatusCallback parameter in your request to provide a URL which will be requested when the status of an outbound fax changes.

Receive faxes in your web application

When your Twilio number receives an incoming fax, Twilio will send an HTTP request to a server you control. This callback mechanism is known as a webhook.  When Twilio sends your application a request, it expects a response in the TwiML XML format telling it how to respond to the message. Here's an example of a simple server application set up to receive a fax.

Loading Code Samples...
Language
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 4.x
import spark.Route;

import static spark.Spark.post;

public class IndexFax {

    private static Route faxSent = (request, response) -> {
        // Let's manually build some TwiML. We can choose to receive the
        // fax with <Receive>, or reject with <Reject>.
        String twiml = "<Response>" +
                            "<Receive action=\"/fax/received\"/>" +
                        "</Response>";

        // Send Fax twiml response
        response.type("text/xml");
        return twiml;
    };

    // Define a handler for when the fax is finished sending to us - if successful,
    // We will have a URL to the contents of the fax at this point
    private static Route faxReceived  = (request, response) -> {
        // log the URL of the PDF received in the fax
        System.out.println(request.params(":mediaUrl"));

        // Respond with empty 200/OK to Twilio
        response.status(200);
        return null;
    };

    public static void main(String[] args) {
        post("/fax/sent", faxSent);

        post("/fax/received", faxReceived);
    }
}
#!/usr/bin/env python

"""Fax snippet."""

from flask.ext.script import Manager
from sms2fa_flask import prepare_app
from flask import Flask, Response, request

app = Flask(__name__)

@app.route('/fax/sent', methods=['POST'])
def fax_sent():
    """Define a handler for when the fax is initially sent."""
    # Let's manually build some TwiML. We can choose to receive the
    # fax with <Receive>, or reject with <Reject>.
    twiml = """
        <Response>
            <Receive action="/fax/received"/>
        </Response>
    """

    return Response(twiml, mimetype='text/xml')


@app.route('/fax/received', methods=['POST'])
def fax_received():
    """Define a handler for when the fax finished sending to us."""
    # We will have a URL to the contents of the fax at this point
    # log the URL of the PDF received in the fax
    print(request.form.get('MediaUrl'))

    # Respond with empty 200/OK to Twilio
    return '', 200

if __name__ == "__main__":
    Manager(app).run()
using System.Web.Mvc;

namespace TwilioFax.Web.Controllers
{
    public class FaxController : Controller
    {
        // Define a handler for when the fax is initially sent
        [HttpPost]
        public ActionResult Sent()
        {
            // Let's manually build some TwiML. We can choose to receive the
            // fax with <Receive>, or reject with <Reject>.
            const string xmlString = "<Response>" +
                                        "<Receive action =\"/fax/received\"/>" +
                                      "</Response>";

            return this.Content(xmlString, "text/xml");
        }

        // Define a handler for when the fax is finished sending to us - if successful,
        // We will have a URL to the contents of the fax at this point
        [HttpPost]
        public ActionResult Received()
        {
            // log the URL of the PDF received in the fax
            System.Diagnostics.Debug.WriteLine(Request["MediaUrl"]);

            // Respond with empty 200/OK to Twilio
            return new EmptyResult();
        }
    }
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class FaxController extends Controller {

    public function __construct()
    {
        parent::__construct();

        // set content-type for all requests returned by this controller
        $this->set_output->set_content_type('text/xml')
    }

    // Define a handler for when the fax is initially sent
    public function sent()
    {
        $twimlResponse = new SimpleXMLElement("<Response></Response>");
        $recieveEl = $twimlResponse->addChild('Receive');
        $receiveEl->addAttribute('action', '/fax/received');

        $this->output->set_output($twimlResponse->asXML());
    }

    // Define a handler for when the fax is finished sending to us - if successful,
    // We will have a URL to the contents of the fax at this point
    public function received()
    {
        // log the URL of the PDF received in the fax
        log_message('info', $this->input->post("MediaUrl"));

        // Respond with empty 200/OK to Twilio
        $this->set_status_header(200)
        $this->output->set_output('')
    }
}
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');

const app = express();

// Parse any incoming POST parameters
app.use(bodyParser({ extended: false }));

// Define a handler for when the fax is initially sent
app.post('/fax/sent', (req, res) => {
  // Let's manually build some TwiML. We can choose to receive the
  // fax with <Receive>, or reject with <Reject>.
  const twiml = `
  <Response>
    <Receive action="/fax/received"/>
  </Response>
  `;

  // Send Fax twiml response
  res.type('text/xml');
  res.send(twiml);
});

// Define a handler for when the fax is finished sending to us - if successful,
// We will have a URL to the contents of the fax at this point
app.post('/fax/received', (req, res) => {
  // log the URL of the PDF received in the fax
  console.log(res.body.MediaUrl);

  // Respond with empty 200/OK to Twilio
  res.status(200);
  res.send();
});

// Start the web server
http.createServer(app).listen(3000, () => {
  console.log('Express server listening on port 3000');
});
testable: false
require 'rubygems'
require 'sinatra'

# Define a handler for when the fax is initially sent
post '/fax/sent' do
    # Let's manually build some TwiML. We can choose to receive the
    # fax with <Receive>, or reject with <Reject>.
    content_type 'text/xml'

    <<-twiml
    <Response>
        <Receive action="/fax/received"/>
    </Response>'
    twiml
end


# Define a handler for when the fax is finished sending to us - if successful,
# We will have a URL to the contents of the fax at this point
post '/fax/received' do
  # log the URL of the PDF received in the fax
  logger.info(params['MediaUrl'])

  # Respond with empty 200/OK to Twilio
  status 200
  body ''
end
There are two routes you'll probably need - one to return TwiML when the fax is initially sent to your number, and a second when the fax has completed sending.
Receive an incoming fax

There are two routes you'll probably need - one to return TwiML when the fax is initially sent to your number, and a second when the fax has completed sending.

Chances are that during development, you'll be running this code on localhost. Unfortunately, Twilio can't directly call a server running on your computer - you'll either need to deploy this code to a public server, or run a tunnel such as ngrok that provides an externally accessible URL. We'll show you how to set that up next.

Allow Twilio to talk to your web application

If you haven't already, install ngrok and ensure the ngrok command is on your system path. The following command would use ngrok to expose port 3000 to the public Internet. Replace 3000 with whatever port number you're using to run your web application.

ngrok http 3000

ngrok terminal output

Now we have a new external URL.  Configure this as a webhook for one of your phone numbers in the console. Select your phone number, change "A FAX COMES IN" to the external URL to your service, such as https://sadfs3423.ngrok.io/fax/sent.

Fax webhook configuration

Send a fax to your Twilio phone number -  you should see a pair of HTTP requests in your ngrok console. If everything worked according to plan, you should have logged the URL to a PDF containing your inbound fax out to the console.

Next steps

Now that you understand the basics of sending and receiving faxes, you can check out the REST API reference, or dive deeper into TwiML and webhooks to understand the lifecycle of receiving faxes via HTTP requests. Happy faxing!

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

1 / 1
Loading Code Samples...
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 5.x
Format:
  • JSON
// Install the Java helper library from twilio.com/docs/libraries/java
import com.twilio.Twilio;
import com.twilio.rest.fax.v1.Fax;
import com.twilio.rest.fax.v1.FaxCreator;
import java.net.URI;
import java.net.URISyntaxException;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) throws URISyntaxException {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

        String from = "+15017250604";
        String to = "+15558675309";
        URI mediaUrl = new URI("https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf");
        FaxCreator faxCreator = Fax.creator(to, mediaUrl);
        faxCreator.setFrom(from);
        Fax fax = faxCreator.create();

        System.out.println(fax.getSid());
    }
}
from twilio.rest import Client

# put your own credentials here
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

fax = client.fax.v1.faxes.create(
    from_="+15017250604",
    to="+15558675309",
    media_url="https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf")

print(fax.sid)
// Download the twilio-csharp library from twilio.com/docs/libraries/csharp
using System;
using Twilio;
using Twilio.Rest.Fax.V1;
using Twilio.Types;
using System.Collections.Generic;

class Example
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var to = "+15558675309";
        var mediaUrl = new Uri(
            "https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf");

        var fax = FaxResource.Create(to, mediaUrl, from: "+15017250604");

        Console.WriteLine(fax.Sid);
    }
}
<?php
// Get the PHP helper library from twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/console
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);

$options = array(
  "from" => "+15017250604"
);
$fax = $client->fax->v1->faxes->create(
    "+15558675309",
    "https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf",
    $options
);

echo $fax->sid;
require 'net/http'
require 'json'

# Get your Account SID and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

uri = URI('https://fax.twilio.com/v1/Faxes')

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

  request = Net::HTTP::Post.new uri.request_uri
  request.basic_auth account_sid, auth_token
  request.body = URI.encode_www_form({
    :To => '+15558675309',
    :From => '+15017250604',
    :MediaUrl => 'https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf'
  })

  response = http.request request

  puts JSON.parse(response.body)['sid']
end
// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.fax.v1.faxes
  .create({
      to: '+15558675309',
      from: '+15017250604',
      mediaUrl: 'https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf'
  }).then(function(response) {
    console.log(response.sid);
  }).catch((err) => {
    console.log(err)
  });
curl 'https://fax.twilio.com/v1/Faxes' \
    -X POST \
    -d 'To=%2B15558675309'  \
    -d 'From=%2B15017250604'  \
    -d 'MediaUrl=https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf' \
    -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
	"status": "queued",
	"direction": "outbound",
	"from": "+15017250604",
	"date_updated": "2017-04-06T06:39:15Z",
	"price": null,
	"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
	"to": "+15558675309",
	"date_created": "2017-04-06T06:39:15Z",
	"url": "https://fax.twilio.com/v1/Faxes/FX4ac3612393b5a66f11c73a148f956a5c",
	"sid": "FX4ac3612393b5a66f11c73a148f956a5c",
	"duration": null,
	"num_pages": null,
	"quality": "fine",
	"price_unit": null,
	"api_version": "v1",
	"media_url": null
}
SDK Version:
  • 5.x
SDK Version:
  • 7.x
SDK Version:
  • 5.x
SDK Version:
  • 6.x
SDK Version:
  • 4.x
import spark.Route;

import static spark.Spark.post;

public class IndexFax {

    private static Route faxSent = (request, response) -> {
        // Let's manually build some TwiML. We can choose to receive the
        // fax with <Receive>, or reject with <Reject>.
        String twiml = "<Response>" +
                            "<Receive action=\"/fax/received\"/>" +
                        "</Response>";

        // Send Fax twiml response
        response.type("text/xml");
        return twiml;
    };

    // Define a handler for when the fax is finished sending to us - if successful,
    // We will have a URL to the contents of the fax at this point
    private static Route faxReceived  = (request, response) -> {
        // log the URL of the PDF received in the fax
        System.out.println(request.params(":mediaUrl"));

        // Respond with empty 200/OK to Twilio
        response.status(200);
        return null;
    };

    public static void main(String[] args) {
        post("/fax/sent", faxSent);

        post("/fax/received", faxReceived);
    }
}
#!/usr/bin/env python

"""Fax snippet."""

from flask.ext.script import Manager
from sms2fa_flask import prepare_app
from flask import Flask, Response, request

app = Flask(__name__)

@app.route('/fax/sent', methods=['POST'])
def fax_sent():
    """Define a handler for when the fax is initially sent."""
    # Let's manually build some TwiML. We can choose to receive the
    # fax with <Receive>, or reject with <Reject>.
    twiml = """
        <Response>
            <Receive action="/fax/received"/>
        </Response>
    """

    return Response(twiml, mimetype='text/xml')


@app.route('/fax/received', methods=['POST'])
def fax_received():
    """Define a handler for when the fax finished sending to us."""
    # We will have a URL to the contents of the fax at this point
    # log the URL of the PDF received in the fax
    print(request.form.get('MediaUrl'))

    # Respond with empty 200/OK to Twilio
    return '', 200

if __name__ == "__main__":
    Manager(app).run()
using System.Web.Mvc;

namespace TwilioFax.Web.Controllers
{
    public class FaxController : Controller
    {
        // Define a handler for when the fax is initially sent
        [HttpPost]
        public ActionResult Sent()
        {
            // Let's manually build some TwiML. We can choose to receive the
            // fax with <Receive>, or reject with <Reject>.
            const string xmlString = "<Response>" +
                                        "<Receive action =\"/fax/received\"/>" +
                                      "</Response>";

            return this.Content(xmlString, "text/xml");
        }

        // Define a handler for when the fax is finished sending to us - if successful,
        // We will have a URL to the contents of the fax at this point
        [HttpPost]
        public ActionResult Received()
        {
            // log the URL of the PDF received in the fax
            System.Diagnostics.Debug.WriteLine(Request["MediaUrl"]);

            // Respond with empty 200/OK to Twilio
            return new EmptyResult();
        }
    }
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class FaxController extends Controller {

    public function __construct()
    {
        parent::__construct();

        // set content-type for all requests returned by this controller
        $this->set_output->set_content_type('text/xml')
    }

    // Define a handler for when the fax is initially sent
    public function sent()
    {
        $twimlResponse = new SimpleXMLElement("<Response></Response>");
        $recieveEl = $twimlResponse->addChild('Receive');
        $receiveEl->addAttribute('action', '/fax/received');

        $this->output->set_output($twimlResponse->asXML());
    }

    // Define a handler for when the fax is finished sending to us - if successful,
    // We will have a URL to the contents of the fax at this point
    public function received()
    {
        // log the URL of the PDF received in the fax
        log_message('info', $this->input->post("MediaUrl"));

        // Respond with empty 200/OK to Twilio
        $this->set_status_header(200)
        $this->output->set_output('')
    }
}
const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');

const app = express();

// Parse any incoming POST parameters
app.use(bodyParser({ extended: false }));

// Define a handler for when the fax is initially sent
app.post('/fax/sent', (req, res) => {
  // Let's manually build some TwiML. We can choose to receive the
  // fax with <Receive>, or reject with <Reject>.
  const twiml = `
  <Response>
    <Receive action="/fax/received"/>
  </Response>
  `;

  // Send Fax twiml response
  res.type('text/xml');
  res.send(twiml);
});

// Define a handler for when the fax is finished sending to us - if successful,
// We will have a URL to the contents of the fax at this point
app.post('/fax/received', (req, res) => {
  // log the URL of the PDF received in the fax
  console.log(res.body.MediaUrl);

  // Respond with empty 200/OK to Twilio
  res.status(200);
  res.send();
});

// Start the web server
http.createServer(app).listen(3000, () => {
  console.log('Express server listening on port 3000');
});
testable: false
require 'rubygems'
require 'sinatra'

# Define a handler for when the fax is initially sent
post '/fax/sent' do
    # Let's manually build some TwiML. We can choose to receive the
    # fax with <Receive>, or reject with <Reject>.
    content_type 'text/xml'

    <<-twiml
    <Response>
        <Receive action="/fax/received"/>
    </Response>'
    twiml
end


# Define a handler for when the fax is finished sending to us - if successful,
# We will have a URL to the contents of the fax at this point
post '/fax/received' do
  # log the URL of the PDF received in the fax
  logger.info(params['MediaUrl'])

  # Respond with empty 200/OK to Twilio
  status 200
  body ''
end