This API lets you buy a phone number and add it to your account. If the number is for a country that requires address and identity verification, you must provide verification documents before Plivo can activate the phone number.
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.
If the number is for a country with verification requirements, Plivo sends an email message to the registered email address for the account that describes the requirements, and returns this response.
## Example for PhoneNumber Create#require'rubygems'require'plivo'includePlivoincludePlivo::Exceptionsapi=RestClient.new("<auth_id>","<auth_token>")beginresponse=api.phone_numbers.buy('441273257545','app id to link with')putsresponserescuePlivoRESTError=>eputs'Exception: '+e.messageend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Example for PhoneNumber createvarplivo=require('plivo');(functionmain(){'use strict';// If auth id and auth token are not specified, Plivo will fetch them from the environment variables.varclient=newplivo.Client("<auth_id>","<auth_token>");client.numbers.buy("441273257545",// number).then(function(response){console.log(response);},function(err){console.error(err);});})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php/**
* Example for PhoneNumber create
*/require'vendor/autoload.php';usePlivo\RestClient;usePlivo\Exceptions\PlivoRestException;$client=newRestClient("<auth_id>","<auth_token>");try{$response=$client->phonenumbers->buy('441273257545');print_r($response);}catch(PlivoRestException$ex){print_r($ex);}
packagecom.plivo.api.samples.phonenumber;importjava.io.IOException;importcom.plivo.api.Plivo;importcom.plivo.api.exceptions.PlivoRestException;importcom.plivo.api.models.number.PhoneNumber;importcom.plivo.api.models.number.PhoneNumberCreateResponse;/**
* Example for PhoneNumber create
*/classPhoneNumberCreate{publicstaticvoidmain(String[]args){Plivo.init("<auth_id>","<auth_token>");try{PhoneNumberCreateResponseresponse=PhoneNumber.creator("441273257545").create();System.out.println(response);}catch(PlivoRestException|IOExceptione){e.printStackTrace();}}}
/**
* Example for PhoneNumber Create
*/usingSystem;usingSystem.Collections.Generic;usingPlivo;usingPlivo.Exception;namespacePlivoExamples{internalclassProgram{publicstaticvoidMain(string[]args){varapi=newPlivoApi("<auth_id>","<auth_token>");try{varresponse=api.PhoneNumber.Buy(number:"441273257545");Console.WriteLine(response);}catch(PlivoRestExceptione){Console.WriteLine("Exception: "+e.Message);}}}}
1
2
3
curl -X POST -i--user AUTH_ID:AUTH_TOKEN
-H"Content-Type: application/json"
https://api.plivo.com/v1/Account/{auth_id}/PhoneNumber/444444444444/
// Example for PhoneNumber createpackagemainimport("fmt""github.com/plivo/plivo-go/v7")funcmain(){client,err:=plivo.NewClient("<auth_id>","<auth_token>",&plivo.ClientOptions{})iferr!=nil{fmt.Print("Error",err.Error())return}response,err:=client.PhoneNumbers.Create("123",plivo.PhoneNumberCreateParams{},)iferr!=nil{fmt.Print("Error",err.Error())return}fmt.Printf("Response: %#v\n",response)}
Example Request
1
2
3
4
5
6
7
8
9
10
11
12
13
importplivoauth_id="Your AUTH_ID"auth_token="Your AUTH_TOKEN"p=plivo.RestAPI(auth_id,auth_token)params={'number':'444444444444'# Phone number to buy
}response=p.buy_phone_number(params)printstr(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require'plivo'includePlivoAUTH_ID="Your AUTH_ID"AUTH_TOKEN="Your AUTH_TOKEN"p=RestAPI.new(AUTH_ID,AUTH_TOKEN)# Get a particular numberparams={'number'=>'444444444444'# Phone number to buy}response=p.buy_phone_number(params)printresponse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
varplivo=require('plivo');varp=plivo.RestAPI({authId:'Your AUTH_ID',authToken:'Your AUTH_TOKEN'});// Buy a phone numbervarparams={'number':'444444444444'// Phone number to buy};p.buy_phone_number(params,function(status,response){console.log('Status: ',status);console.log('API Response:\n',response);});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?phprequire'vendor/autoload.php';usePlivo\RestAPI;$auth_id="Your AUTH_ID";$auth_token="Your AUTH_TOKEN";$p=newRestAPI($auth_id,$auth_token);# Get a particular number$params=array('number'=>'444444444444'# Phone number to buy);$response=$p->buy_phone_number($params);print_r($response);?>
packageplivoexample;importjava.util.LinkedHashMap;importcom.plivo.helper.api.client.*;importcom.plivo.helper.api.response.number.NumberResponse;importcom.plivo.helper.exception.PlivoException;publicclassApp{publicstaticvoidmain(String[]args)throwsIllegalAccessException{Stringauth_id="Your AUTH_ID";Stringauth_token="Your AUTH_TOKEN";RestAPIapi=newRestAPI(auth_id,auth_token,"v1");// Get details of a numberLinkedHashMap<String,String>parameters=newLinkedHashMap<String,String>();parameters.put("number","444444444444");// Phone number to buytry{NumberResponseresp=api.buyPhoneNumber(parameters);System.out.println(resp);}catch(PlivoExceptione){System.out.println(e.getLocalizedMessage());}}}
usingSystem;usingSystem.Collections.Generic;usingRestSharp;usingPlivo.API;namespaceapps{classProgram{staticvoidMain(string[]args){RestAPIplivo=newRestAPI("Your AUTH_ID","Your AUTH_TOKEN");// Get a particular numberIRestResponse<PhoneNumberResponse>res=plivo.buy_phone_number(newDictionary<string,string>(){{"number","444444444444"}// Phone number to buy});Console.WriteLine(res.Content);}}}
1
2
3
curl -X POST -i--user AUTH_ID:AUTH_TOKEN
-H"Content-Type: application/json"
https://api.plivo.com/v1/Account/{auth_id}/PhoneNumber/444444444444/
Rate this page
🥳 Thank you! It means a lot to us!
×
Help Us Improve
Thank you so much for rating the page, we would like to get your input
for further improvements!