Rate this page:

TwiML™ for Programmable Fax

We have made the difficult decision to disable Programmable Fax for all accounts on December 17, 2021. For new and inactive accounts, access to Programmable Fax is disabled effective immediately. We recognize the challenges this decision might cause and have provided detailed migration plans to prevent disruptions.

For additional information, and migration plans, please see Fax Support on Twilio. Learn more.

All Fax functionality with Twilio takes advantage of TwiML, the Twilio markup language. When Twilio reaches out to your application for instructions, you respond and instruct Twilio on how to proceed. You either do this directly by responding with TwiML, or you can use a Helper Library to manage your responses.

What is TwiML?

TwiML is a set of instructions you can use to tell Twilio what to do when you receive an incoming fax – or for that matter an SMS or phone call. For a full overview, feel free to read through the TwiML definition.

Twilio Programmable Fax and TwiML

When Twilio receives a call to an Incoming Phone Number that has been configured as a Fax number, you will receive an HTTP request to the FaxUrl configured for that number. Your server should respond with TwiML that then instructs Twilio how to proceed.

Twilio's request to your application

Twilio makes HTTP requests to your application just like a web browser form submission, in the format application/x-www-form-urlencoded. By including parameters and values in its requests, Twilio sends data to your application that you can parse and act upon before responding.

You can configure the URLs and HTTP Methods Twilio uses to make its requests via your account portal or using the REST API. By setting the 'Webhook' callback, you direct Twilio where to look when we receive an incoming fax. Merely set the 'A Fax Comes In' field on your desired phone number.

Fax webhook configuration

Twilio cannot cache POST requests we make to your application.

If you want Twilio to cache static TwiML pages from your app, have Twilio make requests to your application using GET.

The TwiML request for Programmable Fax will contain the following request parameters:

FaxSid The 34-character unique identifier for the fax
AccountSid The account from which the fax was sent
From The caller ID or SIP From display name
To The phone number or SIP URI of the destination
ApiVersion The API version used to send the fax, which for this API will be "v1"

Responding to Twilio after an incoming fax

When a message comes into one of your Twilio numbers, Twilio makes an HTTP request to the Webhook URL configured for that number, as shown above.

In your response to that request, you can tell Twilio what to do in response to the message. You can configure your number URLs here.

You will want to receive or reject the fax after receiving a request.

Twilio is a well-behaved HTTP client

Twilio behaves just like a web browser, so there's nothing new to learn.

  • Cookies: Twilio accepts HTTP cookies and will include them in each request, just like a normal web browser.
  • Redirects: Twilio follows HTTP Redirects (HTTP status codes 301, 307, etc.), just like a normal web browser.
  • Caching: Twilio will cache files when HTTP headers allow it (via ETag and Last-Modified headers) and when the HTTP method is GET, just like a normal web browser.


Twilio will keep cookie state across multiple requests involving the same two phone numbers. This allows you to treat the separate messages as a conversation, and store data about the conversation, such as a session identifier, in the cookies for future reference. Twilio will expire the cookies for that conversation after four hours of inactivity.

TwiML fax verbs

Most XML elements in a TwiML document are TwiML verbs. Verb names are case sensitive, as are their attribute names. There are only two TwiML fax verbs at this time:

  • <Receive>: receives an incoming fax, creating a new Fax instance resource
  • <Reject>: rejects the fax and list its status as canceled.
Rate this page:

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 by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.


        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more