Latest Legacy

Update phone number

Change the application and subaccount associated with a specified phone number from your account.

API Endpoint

POST https://api.plivo.com/v1/Account/{auth_id}/Number/{number}/

Arguments

app_id stringrequired — conditional

The application to be assigned to the phone number. If not specified, the application selected as the default_number_app of the account is assigned. For more information, refer to the default_number_app argument in application and the app_id attribute in application object. You may use either app_id or object_id but not both.

subaccount string

The auth_id of the subaccount to which this number should be added. This can be performed only by the main account.

alias string

An alias assigned to the phone number.

object_typestring

Users can pass object_type as trunk.

Mandatory parameter when object_id is present.

Object_type will support trunk, phlo, and xml as values in the next release.

object_idstring

Users can pass trunk_id.

Mandatory parameter when object_type is present.

Object_id will support trunk_id, phlo_id, and xml_id as values in the next release.

message_methodstringrequired — conditional

Allowed values: GET, POST

Allowed for voice- and SMS-enabled numbers.

Required if message_url is passed.

message_urlstringrequired — conditional

Message URL of length not greater than 255 characters.

Allowed only for voice- and SMS-enabled numbers.

Required if message_method is passed.

app_id cannot be updated when object_type is set as trunk and object id is provided.

Response

HTTP Status Code: 202

{
  "message": "changed",
  "api_id": "5a9fcb68-582d-11e1-86da-6ff39efcb949"
}

Example Request

1
1
1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
/**
 * Example for Number update
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->numbers->update(
        '12025551111',
        [
        'object_id' => '33123401372191272',
        'object_type' => 'trunk',
        'message_method' => 'POST',
        'message_url' => 'https://www.plivo.com']
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}
1
1
1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN 
    -H "Content-Type: application/json" 
    -d '{"alias": "testing"}'  
    https://api.plivo.com/v1/Account/{auth_id}/Number/12025551111/
1