Docs

Rent phone number

https://api.apifonica.com/v2/accounts/{accountSID}/numbers

Overview

To rent a number, make the POST request to /accounts/{accountSID}/numbers.

The table below lists parameters specified while making this request.

ParameterRequiredDescriptionDefault Value
number
yes

Phone number in E.164 format that you want to rent.

N/A
call_app_sid
optional

Existing application SID, which will be used for Call operations.

existing
application SID

msg_app_sid
optional

Existing application SID, which will be used for Message operations.

Please note that only one of the parameters call_app_sid and msg_app_sid can be specified (the other must be null)

existing
application SID

Request example

curl –X POST https://api.apifonica.com/v2/accounts/{accountSID}/numbers \
-H 'Content-Type: application/json' \
-d '{
      "number": "447860041755"
    }' \
-u {accountSID}:{authToken}

Response example

{
  "status_code": 201,
  "status_message": "CREATED",
  "uri": "/accounts/{accountSID}/numbers/{numberSID}"
}

For incoming call:

Request parameters which are sent to controller url:

ParameterDescription
call_sid

Call unique identifier.

account_sid

Account unique identifier.

from

The phone number or virtual number of the caller.

to

The phone number or virtual number which is used to receive the call.

direction

Call direction. Can be “inbound” or “outbound”.

For incoming message:

ParameterDescription
message_sid

Message unique identifier.

account_sid

Account unique identifier.

from

The phone number of the sender.

to

The phone number which received the message

text

Text of message.

Request example

For incoming call:

{
  "call_sid": "{callSID}",
  "account_sid": "{accountSID}",
  "from": "+79991234566",
  "to": "+79992323232",
  "direction": "inbound"
}

For incoming message:

{
  "message_sid": "{messageSID}",
  "account_sid": "{accountSID}",
  "from": "+79991234566",
  "to": "+79992323232",
  "text": "Hello World"
}