Skip to main content
The Session API lets you send and validate one-time passwords (OTP) for two-factor authentication (2FA) using SMS and voice channels. API Endpoint

The Session Object

The API creates a Session object once for each recipient within the code expiry time. A session can have multiple attempts to deliver the OTP.

Attributes

string
A 36-character string that uniquely identifies a session.
string
ID of the application used to trigger the session.
string
Alias of the Verify application used to trigger the session.
string
The destination phone number (in E.164 format).
string
ISO 3166-1 alpha-2 country code of the destination number. Example: IN.
string
Carrier network detected for the destination number.
string
IP address from which the session creation request originated.
string
Current status. Values: in-progress, verified, expired.
string
The last channel used for the session.
string
Language translation used for the session.
object
Details of all attempts made during a session.
object
Details of all charges incurred during a session.
string
UTC time when the session was created.
string
UTC time when the session was last updated.

Create a Session

Send an OTP via SMS or voice.

Arguments

string
required
The phone number to send the OTP to.
string
UUID of the Verify application. Defaults to default application.
string
Delivery channel. Values: sms, voice. Default: sms.
string
URL for status callbacks.
string
HTTP method for callbacks. Values: GET, POST. Default: POST.
string
Language code (e.g., en_US, es, fr_FR). Default: en.
string
Brand name to replace ${brand_name} in templates.
string
Android app hash for SMS Retriever API integration.
integer
OTP length (4-8). Overrides application default.

Example

Response

string
Unique identifier for the API request.
string
Status of the request. Returns Session initiated on successful session creation.
string
A 36-character string that uniquely identifies a session.

Validate a Session

Validate the OTP entered by the user.

Arguments

string
required
The OTP to validate.
You can attempt no more than 10 validations per session to prevent brute-force attacks.

Example

Response

string
Unique identifier for the API request.
string
Status of the request. Returns session validated successfully. on a successful validation.

Retrieve a Session

Get details of a specific session.

Example

Response

string
Unique identifier for the API request.
string
A 36-character string that uniquely identifies a session.
string
ID of the application used to trigger the session.
string
The destination phone number (in E.164 format).
string
The last channel used for the session.
string
Current status. Values: in-progress, verified, expired.
array
Details of all attempts made during the session.
object
Details of all charges incurred during the session.
string
UTC time when the session was created.
string
UTC time when the session was last updated.

List All Sessions

Retrieve a list of sessions based on filter criteria over the last 90 days.
The default rate limit is 20 requests per minute. Exceeding this limit returns “too many requests” error.

Query Parameters

string
Filter by application UUID.
string
Filter by status. Values: in-progress, verified, expired.
string
Filter by destination number (E.164 format).
string
Filter by subaccount.
integer
Results per page. Max: 20. Default: 20.
integer
Number of results to skip. Default: 0.
string
Filter by session initiation time. Format: YYYY-MM-DD HH:MM. Supports variants: session_time__gt, session_time__gte, session_time__lt, session_time__lte.
string
Filter by brand name.
string
Filter by app hash.

Example

Response

string
Unique identifier for the API request.
object
Pagination metadata: limit (results per page), offset (items skipped), and next/previous page URLs.
array
Array of session objects — see The Session Object.

Status Callbacks

Set up a server endpoint to receive real-time status updates for your verification sessions. Specify the callback URL when creating a session.

Callback Attributes

string
Unique session identifier.
string
Session status. Values: in-progress, expired.
string
Unique identifier for the SMS/call attempt.
string
Sequence number of the attempt.
string
Channel used. Values: sms, voice.
string
Attempt status. SMS: queued, sent, delivered, failed, undelivered. Voice: in-progress, completed, ringing.
string
Error code from the channel.
string
Destination phone number.
string
UTC time when the attempt was created.

Callback Behavior

Plivo automatically retries webhooks three times if HTTP 200 is not returned:
  • First retry: 60 seconds after original attempt
  • Second retry: 120 seconds after first retry
  • Third retry: 240 seconds after second retry

  • Overview - Quick start guide and concepts