Plivo Number Masking

    Number masking or call masking allows businesses to facilitate communication while safeguarding their customer’s privacy. An intermediate virtual phone number is used to set up the call. The real phone number of the caller and recipient are kept hidden from each other.

    Prerequisite

    1. A standard Plivo account
    2. At least one Plivo phone number

    Real number to virtual number mapping

    A masking session is created by sending the real phone number of two parties who need to be connected. Plivo will return a virtual number from your account in response to the API request.

    • If one party make a call to the virtual number, the call is connected to the other party
    • The caller ID of the outbound call to the second party is the Plivo virtual number

    Create a masking session

    POSThttps://api.plivo.com/v1/Account/{Auth ID}/Session

    Arguments

    first_party(mandatory)char

    The real phone number of the first person in E.164 format.

    second_party(mandatory)char

    The real phone number of the second person in E.164 format.

    session_expiry(optional)int

    The time in seconds after which the mapping should be deleted automatically.

    Defaults to 1800 seconds Max: 86400 seconds Min: 60 seconds

    call_time_limit(optional)int

    The time in seconds after which the call should be disconnected. Defaults to 14,400 seconds (4 hours)

    Max: 86400 seconds

    Min: 60 seconds

    In case of the input being

    1. Invalid - defaults to 14400

    2. Below Min value - gets set to Min value

    3. Above Max value - gets set to Max value

    record bool(optional)

    Possible values: true, false Defaults to "false"

    Behavior:

    1. Recording starts only when both participants on the bridge have answered their calls.

    2. There may be multiple calls that happen for a single session. This generates multiple recording files.

    record_file_format(optional)char

    Specifies the audio format for the recording. Allowed values: mp3, wav Defaults to mp3

    recording_callback_url(optional) char

    The URL where the recording should be posted There may be multiple calls that happen for a single session. This generates multiple recording files and each of them is posted to this URL. The max URL length can be 1000. For longer URLs, an error is thrown.

    recording_callback_method(phase 2)char

    The HTTP verb that should be used to invoke the URL configured as recording_callback_url. Allowed values: GET, POST

    Defaults to POST

    API Response

    api_id

    The unique identifier for the API request.

    session_uuid

    The unique identifier for the bridge. The bridge maps both the real phone numbers.

    virtual_number

    The Plivo phone number in E.164 format needs to be dialed to bridge Number 1 and Number 2.

    message

    The API response message

    Example Request

    1
    
    1
    
    1
    
    1
    
    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
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    
    package main
    
    import (
    	"fmt"
    	"net/http"
    	"time"
    
    	"github.com/plivo/plivo-go/v7"
    )
    
    func main() {
    	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{HttpClient: &http.Client{Timeout: time.Second * 10}})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	response, err := client.Calls.CreateMaskingSession(
    		plivo.CreateMaskingSessionParams{
    			FirstParty:  "+912025550000",
    			SecondParty: "+912025551111"},
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Printf("Response: %#v\n", response)
    }
    
    // Setting timeout of 10 millisec
    // {HttpClient: &http.Client{Timeout: time.Millisecond * 10}}
    // Setting timeout of 10sec
    // {HttpClient: &http.Client{Timeout: time.Second * 10}}
    // Setting timeout of 10min
    // {HttpClient: &http.Client{Timeout: time.Minute * 10}}