Purchase phone number
Purchase a new phone number for the account. You can specify search criteria or let the system select a random number.
Authorization
authorization In: header
Path Parameters
The account for which the phone number should be created.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
import Surge from '@surgeapi/node';
const client = new Surge({
apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});
const phoneNumber = await client.phoneNumbers.purchase('acct_01j9a43avnfqzbjfch6pygv1td');
console.log(phoneNumber.id);{
"campaign_id": "cpn_01jjnn7s0zfx5tdcsxjfy93et2",
"id": "pn_01jsjwe4d9fx3tpymgtg958d9w",
"name": "(801) 555-1234",
"number": "+18015551234",
"type": "local"
}{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}