Docs

Rent phone number

/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.

Parameter

Required?

Description

Default value

number

yes

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

N/A

controller

no

URL which will be used to make a request for an XML controller file.

N/A

method

no

The request method.

POST

 

Request example

The following example demonstrates renting the +447860041755 number.

curl –X POST ‘https://api.apico.net/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}"
}

Apico request parameters which are sent to controller URL

The parameters described below are sent to controller URL in case the phone number receives a call or a message. The XML controller file is expected in return.

The table below lists parameters for an incoming call.

Parameter

Description

call_sid

Unique call identifier.

account_sid

Unique account identifier.

from

The calling party number (conventional or virtual).

to

The called party number (conventional or virtual).

direction

Call direction.

Either inbound or outbound.

The table below lists parameters for an incoming message.

Parameter

Description

message_sid

Unique message identifier.

account_sid

Unique account identifier.

from

The sender’s phone number.

to

The recipient’s phone number.

text

Message text.

Apico request examples

The following example demonstrates parameters sent for an incoming call.

{
    "call_sid": "{callSID}",
    "account_sid": "{accountSID}",
    "from": "+447860041755",
    "to": "+35315313424",
    "direction": "inbound"
}

The following example demonstrates parameters sent for an incoming message.

{
    "message_sid": "{messageSID}",
    "account_sid": "{accountSID}",
    "from": "+447860041755",
    "to": "+35315313424",
    "text": "Hello, this is my first SMS sent via Apico API!"
}