Send a fax via API
The Telnyx Programmable Fax API lets you send, receive, and manage faxes through a set of easy-to-use HTTP endpoints.
In this guide, you'll learn how to send a fax using the Programmable Fax API in four simple steps.
First, follow our Quickstart guide to create a Telnyx account, phone number, and Fax Application.
If you already have a Telnyx V2 API Authentication key, skip to Step 3.
- In the Telnyx Mission Control Portal, in the left menu bar navigate to "Auth".
- Ensure, API V2 is selected in the horizontal menu bar.
- Click "Create API key"
- Copy the API key and save it somewhere safe.
The Telnyx Programmable Fax API supports PDF files. To initiate sending a fax, we need to send the request to the Telnyx Programmable Fax API endpoint
We need to send additional parameters containing authentication information with the request, so Telnyx knows which account to send the fax from and information about the destination and file being sent.
|media_url||The URL of the PDF used for the fax's media.|
|connection_id||The app ID or connection ID to send the fax with.|
|to||The fax enabled phone number (in E.164 format), or SIP URI, the fax will be sent to.|
|from||The phone number, in E.164 format, the fax will be sent from.|
|Authorizaton: Bearer||The prefix to your API V2 key created in Step 2.|
Now that we know what we need to include in our request, we can use a number of different methods to structure and send it. In this example, we are going to use
curl straight from the command line. You can also use a client such as Postman to structure your request.
curl -X POST https://api.telnyx.com/v2/faxes \ --data-urlencode "media_url=https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" \ --data-urlencode "connection_id=1232154810234" \ --data-urlencode "to=+13129457420" \ --data-urlencode "from=+19459457421" \ --header "Authorization: Bearer APIAuthKey_fromPortal"
Simply copy the above code into your favorite text editor, paste in your parameters from the table in place of the existing data, and execute the command.
If you have successfully structured your command and the fax has begun sending, the Programmable Fax API will respond with
If you do not receive a
HTTP 202 response, double-check your request and try again. Explanations of other response codes can be found in our API reference.
Once the request to send the fax has been successfullly received by Telnyx, you should begin receiving a series of webhooks to the URL that you specified in your Fax Application.
The webhooks you should receive are:
That's it! Once you've received a
fax.delivered webhook, your fax has been delivered to its destinaion.
Continue to our next tutorial to learn how to receive inbound faxes via API.