Skip to main content
Number masking sessions establish anonymous connections between two phone numbers. When a session is created, Plivo assigns a virtual number that either party can call to connect to the other without revealing their actual phone numbers. API Endpoint

The Session Object

Attributes

string
Unique identifier for the session.
string
The actual phone number of the first participant.
string
The actual phone number of the second participant.
string
Plivo phone number to be dialed for connecting with the other participant.
string
Current session status. Values: active, in-progress, or expired.
integer
Time in seconds after which the session mapping will expire. Calls made after this will not be forwarded.
integer
Time in seconds after which the call should be disconnected. Applies to all call legs.
integer
Time in seconds after which the ring should be disconnected. Defaults to 120.
boolean
If true, Plivo calls the first party immediately and bridges if answered. Defaults to false.
boolean
Determines the recording status for a phone call. Defaults to false. If true, call recording starts only when both participants have answered.
string
Audio format for the recording. Values: mp3, wav. Defaults to mp3.
string
URL to which the call recording is sent.
string
HTTP verb for invoking recording_callback_url. Values: GET, POST. Defaults to POST.
string
URL on which to receive important session events and status updates.
string
HTTP verb for invoking callback_url. Values: GET, POST. Defaults to POST.
string
URL returning MP3/WAV file to play to first party before connecting.
string
URL returning MP3/WAV file to play to second party before connecting.
boolean
Specifies whether PIN authentication is necessary when the call originates from an unidentified caller.
boolean
Indicates if Plivo generates the PIN for the session.
integer
Length of the PIN to be generated. Default: 4, Min: 4, Max: 15.
string
The PIN for the first party when using a secondary number.
string
The PIN for the second party when using a secondary number.
timestamp
UTC time when the session was created (yyyy-mm-dd, hh-mm-ss).
timestamp
UTC time when the session was last modified (yyyy-mm-dd, hh-mm-ss).
timestamp
UTC time when the session will expire (yyyy-mm-dd, hh-mm-ss).
timestamp
UTC time when the latest interaction ended (yyyy-mm-dd, hh-mm-ss).
integer
Duration of the session in seconds.
string
Total charge incurred for creating the session.
integer
Total number of individual calls (call_uuids) in the session.
string
Total billed amount for all calls within the session.
integer
Total rounded bill duration (seconds) for all calls.
string
Total charges for hosting the session, including call and session creation fees.
object
Interaction object containing session interactions.

Example Object


The Interaction Object

The Interaction object is nested within a session. A masking session can contain multiple interactions. Each interaction within a session has a maximum of two communication legs, regardless of the direction of the call.

Attributes

string
URL of the call-leg resource created for the first party. This field is null if a call is exchanged between the Plivo virtual number and the second party but has not yet been initiated for the first party.
string
URL of the call-leg resource created for the second party. This field is null if a call is exchanged between the Plivo virtual number and the first party but has not yet been initiated for the second party.
string
URL of the recording resource for the interaction. This field will be null when one of the participants didn’t pick up the call.

Create a Session

Create a number masking session using the real phone numbers of two parties. Plivo returns a virtual number from your account that either party can call to connect anonymously.

Arguments

string
required
The actual phone number of the first party.
string
required
The actual phone number of the second party.
boolean
Specifies if the country of the virtual number must match the first_party number. Default: true.
string
Specifies the sub-account auth ID for which the session is created.
integer
Time in seconds after which session mapping ends. Default: 3600.
integer
Time in seconds after which the call disconnects. Default: 3600.
integer
Time in seconds after which ringing stops. Default: 120.
boolean
If true, Plivo calls first party immediately and bridges to second party. Default: false.
string
URL to receive session events and status updates.
string
HTTP method to invoke callback_url. Values: GET, POST. Default: POST.
boolean
Call recording status. Default: false. If true, recording starts after both parties answer.
string
URL where call recordings are sent.
string
Audio format for recording. Values: mp3, wav. Default: mp3.
string
HTTP method to invoke recording_callback_url. Values: GET, POST. Default: POST.
string
URL to .mp3 or .wav file played to first party before connecting.
string
URL to .mp3 or .wav file played to second party before connecting.
boolean
Specifies whether PIN authentication is necessary for unidentified callers. Default: false.
boolean
Indicates if Plivo generates the PIN. Only when is_pin_authentication_required is true. Default: false.
integer
Length of the PIN to be generated. Applicable when generate_pin is true. Default: 4, Min: 4, Max: 15.
string
The PIN for the first party. Must differ from second_party_pin. Length: 4-15 digits.
string
The PIN for the second party. Must differ from first_party_pin. Length: 4-15 digits.
string
URL for playback prompting PIN entry. Required when PIN is activated. Must be .mp3 or .wav.
integer
Number of PIN retries allowed. Values: 0-5. Default: 1.
integer
Wait time in seconds before retrying PIN. Default: 5, Min: 5, Max: 10.
string
URL for playback when incorrect PIN entered. Must be .mp3 or .wav.
string
URL for playback when unknown caller calls the virtual number. Must be .mp3 or .wav.
boolean
Requires PIN even for registered numbers. Only applies if PIN authentication is required. Default: false.
boolean
Allows session creation with only one party. Default: false.
integer
Cool-off period in seconds before the virtual number can be reused. Default: 0, Max: 3600.
The following parameters cannot be updated during an active session:
  • first_party, second_party
  • initiate_call_to_first_party
  • is_pin_authentication_required
  • pin_prompt_play, pin_retry, pin_retry_wait
  • incorrect_pin_play, unknown_caller_play
  • geomatch, subaccount

Example

Response

string
Unique identifier for the API request.
string
Unique identifier for the session.
string
Plivo phone number to be dialed for connecting with the other participant.
string
Status of the request. Returns Session created on successful session creation.
object
The created session object — see The Session Object.

Retrieve a Session

Fetch details of an existing masking session.

Example

Response

string
Unique identifier for the API request.
object
The session object — see The Session Object.

List All Sessions

Fetch details of all existing masking sessions.

Arguments

string
Filter by first party phone number.
string
Filter by second party phone number.
string
Filter by virtual number assigned for the session.
string
Filter by status. Values: active, expired, all. Default: all.
string
Filter sessions by creation time. Format: YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Supports variants: created_time__gt, created_time__gte, created_time__lt, created_time__lte. Default window: 7 days. Max: 30 days.
string
Filter sessions by expiry time. Format: YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Supports variants: expiry_time__gt, expiry_time__gte, expiry_time__lt, expiry_time__lte. Default window: 7 days. Max: 30 days.
string
Filter sessions by duration in seconds. Supports variants: duration__gt, duration__gte, duration__lt, duration__lte.
integer
Number of results per page. Min: 1, Max: 20. Default: 20.
integer
Number of results to skip. Used for pagination.

Example

Response

string
Unique identifier for the API request.
object
Object containing pagination metadata (meta: limit, offset, total_count, and next/previous page URLs) and an objects array of session objects — see The Session Object.

Update a Session

Update an existing masking session.

Arguments

integer
Time in seconds after which the session mapping will end. Default: 3600.
integer
Time in seconds after which the call will be disconnected. Default: 3600.
integer
Time in seconds after which the ring will be disconnected. Default: 120.
string
URL to receive session events and status updates.
string
HTTP verb to invoke callback_url. Values: GET, POST. Default: POST.
boolean
Recording status for phone calls. Default: false.
string
URL to which the call recording is sent.
string
Audio format for the recording. Values: mp3, wav. Default: mp3.
string
HTTP verb to invoke recording_callback_url. Values: GET, POST. Default: POST.
string
URL that returns an .mp3 or .wav file to be played to the first party.
string
URL that returns an .mp3 or .wav file to be played to the second party.
string
The phone number of the first participant. Only applicable when session was created with create_session_with_single_party set to true.
string
The phone number of the second participant. Only applicable when session was created with create_session_with_single_party set to true.

Example

Response

string
Unique identifier for the API request.
string
Status of the request. Returns Session updated on a successful update.
object
The updated session object — see The Session Object.

Expire a Session

Terminate an ongoing session and mark it as expired.

Example


Session Callbacks

Session Status Callback

Configure the callback_url to receive important session events and status updates.

Events

event
Triggered when the first party answers the call.
event
Triggered when the second party’s phone starts ringing.
event
Triggered when the second party answers the call.
event
Triggered when the second party disconnects the call.
event
Triggered when the first party disconnects the call.
event
Triggered when the PIN authentication status is success, failed, or if the call is from an authorized caller.
event
Triggered when the session expires.
event
Triggered when the session call is done.

Callback Attributes

string
Event that triggered this callback.
string
Timestamp in UTC at which the event occurred.
string
Unique ID of the masking session.
string
Actual from number used to interact with the virtual number.
string
Actual to number dialing out from the virtual number.
string
The virtual number used in the session.
string
Status of the PIN authentication. Values: success, failed, AuthorizedCaller.
integer
Indicates the PIN retry counter due to incorrect PIN input.
string
Total amount incurred for the call.
string
Duration in seconds for which the call was billed.
string
Actual duration of the call in seconds.
string
Reason for the call termination.
integer
A unique integer code for the termination cause.
string
Indicates the sequence of the callback. Helpful for sorting events.

Session Recording Callback

Configure the recording_callback_url to receive recording-related callback events.

Events

event
Triggered when the first party and the second party are connected via the virtual phone number and the recording begins.
event
Triggered when one of the parties disconnects the call.
event
Triggered when the record attribute is set to true but the recording could not be started.

Recording Callback Attributes

string
Event that triggered this callback.
string
Timestamp at which the event occurred.
string
Unique ID of the masking session.
string
Actual from number used to interact with the virtual number.
string
Actual to number dialing out from the virtual number.
string
The virtual number used in the session.
string
Unique identifier of the recording file.
string
Actual media URL path of the recording.
string
Complete URL path to the recording resource URL.
string
Duration of recording in seconds.
string
UTC Timestamp at which the recording started.
string
UTC Timestamp at which the recording ended.
string
Format of the recording. Values: .mp3, .wav.
string
Indicates the sequence of the callback.