Introduction to blocking rules

Phaxio allows you to utilize the our API’s and the Phaxio console to set up rules to block unwanted fax calls. The most obvious use case for blocking is to stop spam, but the Phaxio blocking goes way beyond just this use case.

Phaxio blocking allows you to set up rules that can affect both calls to your Phaxio phone numbers as well as making outbound calls. You might want to block outbound calls if you’re running an application that is prone to fraud or if you want to stop certain users from making expensive calls.

As an example, you might create an inbound rule to block a nuisance number that is calling you repeatedly. That rule, create via API would look like this:

curl https://api.phaxio.com/v2.1/blocking_rules/receive \
  -u 'API_KEY:API_SECRET' \
  -F 'to=aNumberYouOwn' \
  -F 'from=aNumberYouDontWantToCallYou'

Or, if you do not want a user to call France, you might make a rule that blocks a particular number from calling France. That rule might look like this:

 
curl https://api.phaxio.com/v2.1/blocking_rules/send \
  -u 'API_KEY:API_SECRET' \
  -F 'from=aNumberYouOwn' \
  -F 'to=FR'

Notice that the country input here uses the alpha2 code. This is true for any country blocking rule that you set up. The values that you use will need to be either a phone number in e.164 format (+1234567890), a country in alpha2 format, or if you want to block everything you can use an asterisk (*).

For example, if you wanted to block your entire account from calling France:

curl https://api.phaxio.com/v2.1/blocking_rules/send \
  -u 'API_KEY:API_SECRET' \
  -F 'to=FR'
  -F 'from=*'

When you create a rule Phaxio will respond with a rule ID. Make sure to hold onto this ID as you’ll use it later to remove a rule if it’s not longer needed. Blocking a rule is pretty simple and looks like this:

 
curl -X DELETE https://api.phaxio.com/v2.1/blocking_rules/ruleID \
  -u 'API_KEY:API_SECRET'

Of course, you can also remove a rule via the console by deleting it with a button click.

To pull down specific rules, you can send a request to the blocking_rules endpoint referencing the rule’s ID you received when creating the rule. What if you don’t have the ID and want to pull down all rules you created in Phaxio? Simply call the same endpoint but without a rule ID:

curl -G https://api.phaxio.com/v2.1/blocking_rules \
  -u 'API_KEY:API_SECRET'

Of course, if you have hundreds of rules Phaxio will paginate them, so make sure that you’re familiar with pagination.