A2B: Quick start guide to wholesale with A2Billing

This guide is aimed at the SysAdminMan A2B100 template. More details about this template can be found here – http://sysadminman.net/a2billing-hosting.html

In this guide I am going to create an A2Billing wholesale account that could be used to sell SIP termination. I’ll be using VOIP.MS as my call provider.


First we need to create an outbound call trunk. This will be used to ultimately terminate the call. See here for setting up a trunk in A2Billing – http://sysadminman.net/blog/2011/a2b100-setting-up-a-trunk-in-a2billing-3089


Before starting we want to make sure that the base currency in A2Billing¬†is set to the currency that we are going to have our ratecards in. VOIP.MS are in USD so I’m going to go to SYSTEM SETTINGS, Global List, Global and change “base_currency” to USD.

Next we need to create a call plan and rate card. In A2Billing a rate card holds the rate cost for dialling a particular number. That rate card is assigned to a call plan. The call plan is then assigned to a customer. Each call plan can include many rate cards. Sounds complicated but is easier once you start playing with it.

The best way to create a rate card is to import a rate file from your provider. I wrote a script to do this automatically (see here), but here we’re going to manually download and import the file.

On the VOIP.MS website we go to “Rates” and “Download CSV”. You should see the screen below –


Click GO and right click on the download link and save the file somewhere.

A2Billing requires that the first 3 columns in the CSV file are in a particular order before we can import it. These need to be “dial prefix”, “destination”, “selling rate”. Unfortunately our voip.ms CSV is not in this order.

To change the order of the columns I’m going to use CSVed, a free program you can find here – http://download.cnet.com/CSVed/3000-2351_4-52868.html. I would recommend not¬†using Excel doesn’t save CSV files very well.

In our CSV the “dial prefix” is in column 3 so we need to move that to column 1, easy with CSVed. Load the file then at the bottom of the screen select the “Column Edit” tab. Then move column 3 to column 1. We also need to move the “selling rate” which is in column 4 to column 3.

We also want to copy the rate (column 3) to column 4 as we will use this value twice (once for the buy rate and once for the sell rate). So you should end up with a file looking something like this –

What you need to move will depend on your providers CSV file. You can also import other fields such as the billing duration, connection charge, etc.

Save the edited file but save it with the extension .txt. Loading files called .csv in to A2Billing can fail in firefox.

Now we need to create a blank rate card in A2Billing to import these rates in to. Select RATES, RateCards, Add RateCard.

Give the RateCard a name, I always include the date I created it in the name. The RateCard will default to use the trunk we created earlier –


Now we are going to import the ratecard so choose RATES, Import.

Choose the ratecard and the trunk you created earlier. The first 3 fields to import are fixed for us. I’m just going to add “buyrate” as an addition field to import. Select the CSV file to import (that has the .txt extension) and select Import Ratecard –

You should now see a sample rate that will be imported. If you don’t, or if it looks incorrect, there is something wrong with your CSV file –

So that gives us a rate card, but with the buy and sell rate the same. Not very good for making a profit! I’m going to use Batch Update to add 20% to my sell rate. Select the menu RATES, Rates and then click on Batch Update. Ensure you have only the rates you want to modify select when you do this. Tick “sellrate” and select add 20% as shown below –

Now we just need to create a Call Plan and assign the new ratecard to it. Select RATES, Call Plan and Add Callplan. I’m going to select Yes to remove Inter Prefix as my rates do not have the international prefix on the (00, 001, etc) so when matching the rate card I want the number passed without any international prefix the customer may have dialled –

Next, and this is a step many people miss, you need to go in to the Call Plan and assign the rate card to it –


Now that we have our rates in place we just need to create a SIP customer.

From the CUSTOMERS, Add:Search screen choose Add Customer.

At the very least enter a Balance, Last Name, First Name, Time Zone, and ensure Create SIP Config is set to Yes. The customer will be assigned to the only call plan, that we created earlier –

Now if we go back in to that customers account we can click on “GO TO CUSTOMER ACCOUNT”. That will log us in to the A2Billing customer portal as that customer. Then click on SIP/IAX INFO and we will see the connection details the customer should use when setting up their trunk to us –

The VPSIPADDRESS is a field being picked up from the A2Billing config. This can be found under “SETTINGS, Global List, sip-iax info, Host” and should you should change this to match the IP address of your VPS.


Now that we have the trunk details we can use that in Asterisk or FreePBX. Here is the trunk being used on a remote FreePBX server –

And here we can see the CDR report in A2Billing –


It seems like a lot of set up looking at the long post I’ve written!, but there are only really a few steps. Set up your outbound trunk, configure you rate cards and create the customer.

I should point out that the A2B100 template is configured to use Asterisk RealTime so there is no need to generate SIP/IAX configuration files, all of the settings are stored, and pulled from, the MySQL database.


7 thoughts on “A2B: Quick start guide to wholesale with A2Billing

  1. habib

    Hello everybody, I have a problem with my a2billing installation which I am trying to use as SIP trunking plateform.. My customers use predictive/power dialing for their outbound camapaign and the problem is “balance unstability”. I mean that customer’s balance take some random values each time the home page is refreshed!! It takes “stable” and reasonnable value only when there is no trafic over the trunk.I don’t know whether it has some thing to do with installation process or database access.. Any indication plz?

  2. goldy

    sir i setup from you guide it worked perfect.please tell me how can set ip authentication on this sip extension. means my customer should be authenticated on his ip base not on username and password..second question i have given detail to of customer he has setit on his kolmisoft (MOR) switch and when he pass call he listen message number not in server how can i solve this ?? thanks you in advance

  3. JonnE

    I have that setup exactly, however two issues 1) when I run “sip show registry” or “sip show peers” on the a2b server, I do not see the client, but I know they are connected as outbound works without issues and they are being billed, however DDI numbers I can not route to them, what do I have to put in incoming section?

  4. Matt Post author

    Yes, unfortunately with realtime you won’t see the registered SIP devices.

    Check out realtime caching (some info at the bottom here – http://www.voip-info.org/wiki/view/Asterisk+RealTime+Sip)

    For inbound it depends how you’ve got things set up, but you need to pass the SIP INVITE to the correct a2billing context for DDI calls.

    You can see here for some info – https://sysadminman.net/blog/2009/integrating-freepbx-with-a2billing-621 – it’s a little old but the general idea is the same.

  5. Gianfranco

    thank you for your great tutorial.
    Have you tried it with Asterisk 13 and FreePBX 12?
    Don’t work for me.
    Thank you

Comments are closed.