Latest Legacy

Add a toll-free number

This API lets you add existing SMS- and MMS-enabled toll-free numbers to a number pool.

API Endpoint

POST https://api.plivo.com/v1/Account/{auth_id}/NumberPool/{number_pool_uuid}/Tollfree/{toll_free_number}/

Arguments

No arguments need to be passed.

Returns

Returns a JSON response containing the added toll-free number resource detail.

Response

HTTP Status Code: 200

{
    "account_phone_number_resource": "/v1/Account/<auth_id>/Number/<your_toll_free_number>/",
    "added_on": "2021-04-15T04:49:51.228392Z",
    "api_id": "8a6bba9c-7ed4-11ea-b82e-0242ac110006",
    "country_iso2": "US",
    "number": "<your_toll_free_number>",
    "number_pool_uuid": "<number_pool_uuid>",
    "service": "mms",
    "type": "tollfree"
}

Example Request

1
2
3
4
5
6
7
8
9
10
import plivo

client = plivo.RestClient(auth_id="<auth_id>", auth_token="<auth_token>")
# Add Tollfree to a Powerpack
powerpack = client.powerpacks.get(uuid='<powerpack_uuid>')
# Version 1
response = powerpack.add_tollfree('<tollfree_number>')
# Version 2
response = powerpack.numberpool.tollfree.add('<tollfree_number>')
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>", "<auth_token>")

begin
# Add a Tollfree Number
powerpack = api.powerpacks.get('<powerpack_uuid>')
# Version 1
response = powerpack.add_tollfree('<tollfree_number>')
# Version 2
response = powerpack.numberpool.tollfree.add('<tollfree_number>')

puts(response)
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
11
12
13
let plivo = require('plivo');

let client = new plivo.Client('<auth_id>', '<auth_token>');

// Add Tollfree to a Powerpack
client.powerpacks.get("<powerpack_uuid>").then(
  function (powerpack) {
    return powerpack.add_tollfree("<tollfree>")
    //return powerpack.number_pool.tollfree.add("<tollfree>");  V2
  })
.then(function (result) {
  console.log(result)
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
require 'vendor/autoload.php';
use Plivo\RestClient;

$client = new RestClient("<auth_id>", "<auth_token>");
$client->client->setTimeout(40);

 // Add a TollFree to Powerpack
    try {
    $powerpack = $client->powerpacks->get($powerpack_uuid);
    // Version 1
    $response = $powerpack->add_tollfree($tollfree_number);
    // Version 2 
    $response = $powerpack->number_pool->tollfree->add($tollfree_number);
    print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.plivo.api;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.powerpack.Powerpack;
import com.plivo.api.models.powerpack.Tollfree;

public class Test {
    public static void main(String[] args) {
            
        Plivo.init("<auth_id>", "<auth_token>");

        // Add Tollfree to Powerpack
        try {
            Powerpack powerpack = Powerpack.getter("<powerpack_uuid>").get();
            // Version 1
            Tollfree response = powerpack.add_tollfree().tollfree("<tollfree>").get();
            //Version 2
            Tollfree response = powerpack.numberpool.tollfree.add().tollfree("<tollfree>").get();
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    class Program
    {
        static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");

            // Add Tollfree to Powerpack
            try
            {   
                var powerpack = api.Powerpacks.Get("<powerpack_uuid>");
                // Version 1
                // var response = powerpack.Add_Tollfree("<tollfree_number>");
                // Version 2
                var response = powerpack.numberpool.tollfree.Add("<tollfree_number>");
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main

import (
	"fmt"

	plivo "github.com/plivo/plivo-go/v7"
)

func main() {

	client, err := plivo.NewClient("<auth_id>", "<auth_token>",
		&plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}

	// Add Tollfree to Powerpack
	powerpack, err := client.Powerpack.Get("<powerpack_uuid>")
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := powerpack.Add_tollfree("<tollfree_number>")
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}