Skip to main content

First steps with fax

Learn how to send and receive your first fax using SignalWire. You'll configure a phone number, create SWML or cXML scripts to handle faxes, and use SWML or our APIs to send faxes programmatically.

Prerequisites

Before you begin, you'll need:

  • A SignalWire account
  • At least one phone number capable of receiving faxes
  • Your API credentials (Space URL, Project ID, and API token)

Receiving your first fax

To receive faxes, you'll configure a phone number to handle incoming faxes using either a SWML or cXML script that defines what happens when a fax arrives.

Below are examples of how to set up your fax handler with SWML or cXML.

Obtain a phone number

First, you need a SignalWire phone number capable of receiving faxes.

Log in to your SignalWire Space. If you don't have a number yet, navigate to the Phone Numbers section and buy a new phone number.

Create a SWML script

From your SignalWire Dashboard, create a new Resource by navigating to the resources tab, then select the "New Script" option and choose "New SWML application".

Paste the following code into your script:

version: 1.0.0
sections:
main:
- receive_fax: {}

Save the script; it should now be located in your Resources tab on the left sidebar under Scripts.

Configure phone number for SWML

Navigate to the "Phone Numbers" tab on the left sidebar.

From this tab, click on your newly purchased phone number, then on the "edit settings" option. In the settings page that appears, select "Assign Resource" for "Inbound Call Settings".

Select the newly created SWML script, then click "Save" to apply the configuration.

Test your setup

Send a test fax to your configured phone number and then open the respective call log found in the "logs" section on your left sidebar.

Copy the link found in the "document" parameter and paste it into your browser to view your fax.

Obtain a phone number

First, you need a SignalWire phone number capable of receiving faxes.

Log in to your SignalWire Space. If you don't have a number yet, navigate to the Phone Numbers section and buy a new phone number.

Create a cXML script

From your SignalWire Dashboard, create a new Resource by selecting the Script option, then choose "cXML script".

In the pane that appears, select the "Script Will Be Used For" dropdown, then select Faxing.

Paste the following XML into your script:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Receive></Receive>
</Response>

Save the script; it should now be located in your Resources tab on the left sidebar under Scripts.

Configure phone number for cXML

Navigate to the "Phone Numbers" tab on the left sidebar. From this tab, click on your newly purchased phone number, then on the "edit settings" option. In the settings page that appears, select "Assign Resource" for "Inbound Call Settings".

Select the newly created cXML script, then click "Save" to apply the configuration.

Test your setup

Send a test fax to your configured phone number and then open the respective call log found in the "logs" section on your left sidebar.

Copy the link found in the "document" parameter and paste it into your browser to view your fax.

[Alternative: Using webhooks or SDKs]

If you prefer to host the fax handling logic yourself, you have two options:

You'll need to make your code accessible to SignalWire through a webhook. We have a guide on testing webhooks with ngrok to help you get started.

Sending your first fax

A fax can be sent by utilizing SWML, the Compatibility REST API, or the Compatibility SDK.

Using SWML

SWML can be used to send a fax through the send_fax method. The below example script sends a fax, then posts the result to a predetermined webhook.

version: 1.0.0
sections:
main:
- send_fax:
document: https://example.com/fax_to_send.pdf
- execute:
dest: 'https://example.com/handle_outgoing_fax_result'

Using the SignalWire REST API

You can also utilize SWML to send faxes via the SignalWire REST API's Create a Call endpoint

POST https://{Your_Space_Name}.signalwire.com/api/calling/calls

example body including required parameters:

{
"command": "dial",
"params": {
"from": "sip:from-sip@example-112233445566.sip.signalwire.com",
"to": "sip:from-sip@example-112233445567.sip.signalwire.com",
"url": "https://example.com/swml-for-faxing"
}
}

Using the Compatibility REST API

Send a fax by making a POST request to the Compatibility API's Send Fax endpoint:

POST https://<YOUR_SPACE_URL>.signalwire.com/api/laml/2010-04-01/Accounts/<YOUR_PROJECT_ID>/Faxes

Required parameters:

  • From - Your SignalWire phone number
  • To - The destination fax number
  • MediaUrl - URL to the document you want to send

Using the Compatibility SDK

You can also send faxes using our Compatibility SDK's Send a Fax function:

const { RestClient } = require("@signalwire/compatibility-api");
const client = RestClient("YourProjectID", "YourAuthToken", {
signalwireSpaceUrl: "example.signalwire.com",
});

client.fax.faxes
.create({
from: "+13103383454",
to: "+13104456789",
mediaUrl: "https://example.com/fax.pdf",
})
.then((fax) => console.log(fax.sid))
.done();

In the Legacy Dashboard

No Resources tab? Your SignalWire Space is on the Legacy Dashboard.

Expand the section below to view this guide's Legacy instructions.

Follow the above guide with these changes:

Create a cXML Script

Navigate to the "LaML/cXML" section of your Dashboard and create a new cXML bin.

Assign a phone number

Open the settings for your phone number. Under "Voice and Fax Settings":

  • Set "Accept Incoming Calls As" to "Fax"
  • Set "Handle Faxes Using" to "LaML Webhooks"
  • Select your cXML script from the dropdown for "When a Fax Comes In"

Identify your Dashboard and select between Legacy and New UIs using the tabs below.

Resources that were previously accessible in the sidebar of the legacy UI are now located in the unified My Resources menu.

Next steps