How to?

Establishing a call between soft/hard phone and other phone number

Step 1. Prerequisites

  1. Register at apifonica.com and create your Apifonica account.
  2. Top up the balance and make sure that the balance is not less than 5 EUR before testing the functionality.
  3. In your personal account, find your Apifonica AccountSID and password (AuthToken).
  4. Rent an Apifonica voice phone number to link it with soft/hard phones:

    1. Using personal account: You can search and rent a number here
    2. Using Console: make the GET request to /accounts/{accountSID}/availableNumbers (get list of available countries), then make the GET request to /accounts/{accountSID}/availableNumbers/{countryCode} (available numbers for specified country) and finally make the POST request to /accounts/{accountSID}/numbers (rent phone number)
  5. Change the default mode and the default password of the rented number:

    • Using personal account: In the properties of the rented number set the password for sip-calls and check the mode option to sip_phone.
    • Using Console: make the PUT request to /accounts/{accountSID}/numbers/{numberSID} (Change number properties)

      curl –X PUT ‘https://api.apifonica.com/v2/accounts/{accountSID}/numbers/{numberSID}’
       -H ‘Content-Type: application/json’
       -d ‘{
       "sip_password":"qwerty12345",
       "mode":"sip_phone"
       }’
       -u {accountSID}:{authToken}

      Response example

      {
         "status_code": 200,
         "status_message": "OK",
         "uri": "/accounts/{accountSID}/numbers/{numberSID}"
       }

Step 2. Registration

To register a sip soft/hard phone in the Apifonica platform you need to specify:

  • sip server addres (host): sip-eu.apifonica.com
  • sip login (user name): voice number you have purchased
  • sip password: password that was set up in Step 1

For more details please refer to Configuring Zoiper to make a SIP call using Apifonica How-To.

Now your soft/hard phone is ready to make and receive the calls via Apifonica platform.

Step 3

  1. Create a simple XML file with a number you want to call. Example:

    <?xml version="1.0" encoding="UTF-8"?>
     <response>
       <makeCall>
         <number>35315313424</number>
       </makeCall>
     </response>

    Full Apifonica XML format can be found here. Upload ready XML to your server

  2. Create an application:

    • Using Console: Make the POST request to /accounts/{accountSID}/applications (Create application)
    • Using personal account: You can create it here
  3. Associate your XML with the created Application:

    • Using Console: make the PUT request to /accounts/{accountSID}/applications/{applicationSID} to change “controller” parameter (Update app properties)
    • Using personal account: Insert the link to your XML to the line Controller here

Step 4. Connection setup

  1. Making the calls using Console (Make voice call):

    • make the POST request to /accounts/{accountSID}/calls
    • “from“ parameter is a number rented from Apifonica
    • “to“ parameter is a number, connected to soft/hard phone, which receives the call (Step 2)
    • “Call_app_sid” parameter is Application SID of created application where a link to XML with the second phone number should be indicated (Step 3, Point 3)
  2. Making the callback using personal account:

    • Click the Sandbox
    • Choose accountSID in the list of your accounts/subaccounts
    • Choose “from“ parameter in the list of numbers rented from Apifonica
    • Fill in “to“ parameter - a number connected to soft/hard phone, which receives the call (Step 2)
    • Choose “Controller“ parameter – find in the list of created applications the name of application where a link to XML with the second phone number should be indicated (Step 3)

After that the call is connected between the soft/hard phone and the other local or mobile number.