This API lets you send OTPs via Plivo’s SMS or Voice services.
POST
https://api.plivo.com/v1/Account/{auth_id}/Verify/Session/
app_uuid stringoptional | The UUID of the application you want to use for this session. Defaults to UUID of the default application for your account. |
recipient stringrequired | The phone number to which the message is to be delivered. |
channel stringoptional | The channel you want to use for sending the code. Allowed values:sms,voice |
method stringoptional | The HTTP method to be used when calling the URL defined above. Allowed values:GET,POST |
Url stringoptional | Set this parameter to the fully qualified URL to which status update callbacks for the session should be sent. Read more about the session attributes passed to this callback URL. |
locale stringoptional | Set this parameter to determine the language you want to use. Defaults to ‘en’. The locale value is obtained by combining language code in ISO 639-1 format and region code in ISO 3166-1 format (optional). For example: en_US, en, en_GB, es, fr_FR etc. This feature is available upon request only. Raise a support ticket and provide the translations you want to use. |
brand_namestringoptional | This is the brand name that users will see in their Verify messages. It replaces the string “${brand_name}“ in the Verify template of your choice. It is relevant to the ‘Voice’ and 'SMS' channels. Please note that passing a brand_name overrides the Brand Name configured in the Verify application. |
app_hashstringoptional | Relevance: 'SMS' Channel and Android OS only This is the text string that the SMS Retriever API will look for to match the received SMS OTP to your android application. Please refer to Google's documentation on how to compute your app's hash string. The “app_hash” will be appended at the end of your verification SMS body. |
code_lengthintegeroptional | Valid Values: 4 to 8 (inclusive) |
Returns a JSON response containing the API request ID and session UUID.
{
"api_id": "3335cb16-d297-4e00-a5e6-66d2bb03b323",
"message": "Session initiated",
"session_uuid": "8e712097-8090-4644-81e7-8f4265d8354e"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import sys
sys.path.append("../plivo-python")
import plivo
client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.verify_session.create(
recipient='<destination number>',
app_uuid='<verify application uuid>',
channel='<sms/voice>',
url='<callback url>',
method='<callback method:post/get>'
)
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require "rubygems"
require "/usr/src/app/lib/plivo.rb"
include Plivo
# Environment
api = RestClient.new("<auth_id>", "<auth_token>")
app_uuid='<app_uuid>'
channel='<channel>'
url='https://<yourdomain>.com/session_status/'
method='POST'
recipient='<recipient>'
begin
puts("Create Session")
response = client.verify_session.create(app_uuid,recipient,channel,url,method)
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end
1
2
3
let plivo = require('plivo')
let client = new plivo.Client('<auth_id>','<auth_token>');
client.verify_session.create({ app_uuid:'<app_uuid>', recipient: '<recipient>', url:'https://<yourdomain>.com/sms_status/', method:'POST', channel:'sms' }).then(function(response) { console.log(response) });
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
require '/usr/src/app/vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoResponseException;
// ENVIRONMENT
$client = new RestClient("<auth_id>", "<auth_token>");
$optionalArgs=array("url" => "https://<yourdomain>.com/sms_status/", "method" =>"POST", "channel"=>"sms","app_uuid"=>"<app_uuid>");
// Create Session
try {
$response1 = $client->verifySessions->create(
"<recipient>",$optionalArgs
);
print_r($response1);
}
catch (Exception $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
26
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.verify_session.VerifySession;
import com.plivo.api.models.verify_session.SessionCreateResponse;
import com.plivo.api.models.message.Message;
import com.plivo.api.exceptions.PlivoValidationException;
import com.plivo.api.models.base.ListResponse;
class Session {
public static void main(String[] args) {
Plivo.init("<auth_id>", "<auth_token>");
try {
SessionCreateResponse response = VerifySession.creator(
"<app_uuid>",
"<recipient>", "<channel>", "<callback_url>", "<method>")
.create();
System.out.println(response);
}
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
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;
namespace dotnet_sdk
{
class Session
{
static void Main(string[] args)
{
// ENVIRONMENT
var api = new PlivoApi("<auth_id>", "<auth_token>");
// Create Session
try {
Console.WriteLine("Create Session");
var response = api.VerifySession.Create(recipient:"<recipient>",app_uuid:"<app_uuid>",url:"<callback_url>",method:"POST",channel:"<channel>");
Console.WriteLine(response);
}
catch (PlivoRestException e){
Console.WriteLine("Exception: " + e.Message);
}
}
}
}
1
2
3
4
5
6
7
8
9
10
curl -i --user auth_id:auth_token \
-H "Content-Type: application/json" \
-d '{
"app_uuid":"<app_uuid>",
"recipient": "<recipient>",
"url":"<callback_url>",
"channel":"sms",
"method":"POST"
}' \
https://api.plivo.com/v1/Account/{auth_id}/Verify/Session/
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
package main
import (
"fmt"
"encoding/json"
"github.com/plivo/plivo-go"
)
func main() {
client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
if err != nil {
fmt.Printf("Error:\n", err)
}
//Create Session
response, err := client.VerifySession.Create(
plivo.SessionCreateParams{
Recipient: "<destinatination number>",
AppUUID: "<verify application uuid>",
Channel: "<sms/voice>",
URL: "<callback url>",
Method: "<callback method:post/get>",
},
)
if err != nil {
fmt.Print("Error", err.Error())
return
}
res, _ := json.Marshal(response)
fmt.Printf("Response: \n\n %#v \n", string(res))
}