Latest Legacy

Create a session

This API lets you send OTPs via Plivo’s SMS or Voice services.

API Endpoint

POST https://api.plivo.com/v1/Account/{auth_id}/Verify/Session

Arguments

app_uuid string

The UUID of the application you want to use for this session. Defaults to UUID of the default application for your account.

recipient string

The phone number to which the message is to be delivered.

channel string

The channel you want to use for sending the code.

Allowed values:sms,voice
Defaults tosms

url string

The fully qualified URL to which status update callbacks for the session should be sent.

method string

The HTTP method to be used when calling the URL defined above.

Allowed values:GET,POST
Defaults toPOST

Returns

Returns a JSON response containing the API request ID and session UUID.

Response

{
    "api_id": "3335cb16-d297-4e00-a5e6-66d2bb03b323",
    "message": "Session initiated",
    "session_uuid": "8e712097-8090-4644-81e7-8f4265d8354e"
}

Example Request

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
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
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))
}