Latest Legacy

Overview

All Plivo APIs use HTTP verbs and standard HTTP status codes to make it easy for you to integrate communications into your code. To secure requests to our servers, we serve our APIs over HTTPS.

You can find documentation on our client SDKs on these pages: iOS SDK, Android SDK, and Browser SDK.

Note: The current version of the APIs is v1, and the server SDKs are versioned as latest and legacy.

API Endpoint

POST https://api.plivo.com/{version}/

API Request

Plivo exposes a list of REST API calls to perform various actions. You can use these API calls in combination with XML code to create voice and SMS applications.

POST https://api.plivo.com/v1/

Authentication

All requests to Plivo API are authenticated with BasicAuth using your AUTH ID and AUTH TOKEN. You can see your Plivo AUTH ID and AUTH TOKEN at the top of the Overview page of the Plivo console.

Example Request

1
2
3
4
5
6
7
import plivo

proxies = {
    'http': 'https://username:password@proxyurl:proxyport',
    'https': 'https://username:password@proxyurl:proxyport'
    }
client = plivo.RestClient('<auth_id>', '<auth_token>', proxies=proxies,timeout=5)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
require 'rubygems'
require 'plivo'

proxy = {
	proxy_host: "https://proxyurl",
	proxy_port: "proxyport",
	proxy_user: "username",
	proxy_pass: "password"
}
api = RestClient.new("<auth_id>", "<auth_token>", proxy, timeout=5)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
var plivo = require('plivo');
let options = {
	'timeout': 5000, //ms
	'host': 'https://proxyurl',
	'port': 'proxyport',
	auth: {
		username: 'my-user',
		password: 'my-password'
	}
}

var client = new plivo.Client("<auth_id>", "<auth_token>", options);

Was this code helpful

1
2
3
4
5
6
<?php
require 'vendor/autoload.php';
use Plivo\RestClient;

$client = new RestClient("<auth_id>", "<auth_token>", "<https://proxyurl>", "<proxyport>", "<username>", "<password>");
$client->client->setTimeout(5)

Was this code helpful

1
2
3
4
5
6
7
8
9
package com.plivo.api.samples.application;

import com.plivo.api.Plivo;

class AutheExample {
  public static void main(String [] args) {
    Plivo.init();
  }
}

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
using System;
using System.Collections.Generic;
using Plivo;

namespace PlivoExamples {
  internal class Program {
    public static void Main(string[] args) {
      var api = new PlivoApi(
        "<auth_id>", "<auth_token>",
        "<https://proxyurl>", "<proxyport>", "<username>", "<password>");
      api.Client.SetTimeout(10);
    }
  }
}

Was this code helpful

1
2
3
4
5
6
7
8
9
10
package main

import "github.com/plivo/plivo-go/v7"

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		panic(err)
	}
}

Was this code helpful

Content-Type

Plivo only accepts input of the type application/json.

All POST requests arguments must be passed as json with the Content-Type set as application/json.

All GET and DELETE request arguments must be passed in the query string.

Timeouts and Proxies

The server SDKs provide for specifying timeouts and proxy settings that are to be used while making API requests. Select the programming language of your choice in the code example pane and click on Latest to see how to specify these settings.

Pagination

Plivo uses offset-based pagination to list the resources.

For instance, if your search request has a result of 100 objects with limit = 10 and offset = 5, then Plivo will return objects with indices 51 through 60.

Parameters used for pagination

limit integer

A limit on the number of phone numbers to be returned. limit can range between 1 and 20, and the default is 20.

offset integer

A pagination cursor that denotes the number of objects by which the results should be offset.

Asynchronous Request

All Plivo API requests can be made asynchronous by adding the parameters listed below. When an asynchronous call is made, Plivo will return a generic response with the api_id and the API responses will be sent to the callback URL.

Arguments

callback_url

The URL notified by the API response is available and to which the response is sent.

callback_method

The method used to notify the callback_url. Defaults to POST.

Response

{
"message": "async api spawned",
"api_id": "63f0761a-e0ed-11e1-8ea7-12313924e3a6"
}

API Response

All Plivo API endpoints return a response in JSON format. An api_id is set in each response to uniquely identify your request. The API returns one of the following HTTP status codes depending on whether the API call is successful or a failure.

HTTP Status Codes We Send

200

Request has been executed

201

Resource created

202

Resource changed

204

Resource deleted

400

A parameter is missing or is invalid

401

Authentication failed

404

Resource cannot be found

405

HTTP method not allowed

500

Server error

Response Examples

Response Attributes

api_idstring

Identifies the request.

errorstring

Indicates there’s an error and provides information regarding the error.

messagestring

Provides information regarding the request.

Response

Success

{
  "api_id": "97ceeb52-58b6-11e1-86da-77300b68f8bb",
  "message": "call fired",
  "request_uuid": "75b26856-8638-11e0-802c-6d99d509954e"
}

Error

{
  "api_id": "97ceeb52-58b6-11e1-86da-77300b68f8bb",
  "error": "answer_url parameter is missing",
  "request_uuid": "56hf4856-8638-11e0-802c-65j6gd39954e"
}

Account

The Account object lets you perform actions on your Plivo account. You can update and modify Account details using this object.

API Endpoint

BaseURI https://api.plivo.com/v1/Account/

The Account object

Attributes

account_type string

String representing the account’s type. Possible values are standard for paid accounts and developer for accounts in free trial.

address string

Postal address of the account which will be displayed in the invoices.

auth_id string

Auth ID of the account.

auto_recharge boolean

Whether automatic recharge of account is enabled when credits fall below a certain threshold.

billing_mode string

Billing mode of the account. Possible values are prepaid and postpaid.

cash_credits string

Credits of the account in USD.

city string

City of the account holder.

name string

Name of the account holder.

resource_uri string

URI of the account resource.

state string

State or region of the account.

timezone string

The time zone used in the Plivo dashboard for this account. A list of possible time zone values is maintained at the IANA Time Zone Database.

Response

{
  "account_type": "standard",
  "address": "Wayne Enterprises Inc.",
  "api_id": "150892a0-922a-11e7-b6f4-061564b78b75",
  "auth_id": "MA2025RK4E639VJFZAGV",
  "auto_recharge": false,
  "billing_mode": "prepaid",
  "cash_credits": "1.80900",
  "city": "Gotham",
  "name": "Bruce Wayne",
  "resource_uri": "/v1/Account/MA2025RK4E639VJFZAGV/",
  "state": "NY",
  "timezone": "America/New_York"
}

Retrieve account details

Retrieves the details of the account.

API Endpoint

GET https://api.plivo.com/v1/Account/{auth_id}/

Arguments

No arguments need to be passed.

Returns

Returns an Account object.

Example Request

1
2
3
4
5
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.account.get()
print(response)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#
# Example for Account Get
#
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.account.details
  
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Example for Account get

var plivo = require('plivo');

(function main() {
    'use strict';
    
   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    client.accounts.get(
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
/**
 * Example for Account get
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->accounts->get(
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.plivo.api.samples.account;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.account.Account;
import com.plivo.api.models.account.Account;

/**
* Example for Account get
*/
class AccountGet {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>");
        try {
            Account response = Account.getter()
                .get();

            System.out.println(response);
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}

Was this code helpful

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
/**
 * Example for Account Get
 */
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Account.Get(
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Was this code helpful

1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Example for Account get
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Accounts.Get()
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}

Was this code helpful

Response

HTTP Status Code: 200

{
  "account_type": "standard",
  "address": "Wayne Enterprises Inc.",
  "api_id": "150892a0-922a-11e7-b6f4-061564b78b75",
  "auth_id": "MA2025RK4E639VJFZAGV",
  "auto_recharge": false,
  "billing_mode": "prepaid",
  "cash_credits": "1.80900",
  "city": "Gotham",
  "name": "Bruce Wayne",
  "resource_uri": "/v1/Account/MA2025RK4E639VJFZAGV/",
  "state": "NY",
  "timezone": "America/New_York"
}

Update the account details

Updates the Account object by setting the values of the parameters passed. Parameters that are not provided will remain unchanged.

This request accepts only the name, city, state, time zone, and address as parameters.

API Endpoint

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

Arguments

address string

Postal address of the account, which is displayed on the invoices.

name string

Name of the account holder.

city string

City of the account holder.

state string

State or region of the account.

timezone string

The time zone used in the Plivo dashboard for this account. A list of possible time zone values is maintained at the IANA Time Zone Database.

Returns

Returns a confirmation that the object is updated.

Example Request

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.account.update(
    name='Lucius Fox',
    city='New York',
    address='Times Square', )
print(response)

# Or, you could use the Application object
account_details = client.account.get()
response = account_details.update(
    name='Lucius Fox',
    city='New York',
    address='Times Square', )
print(response)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Example for Account Update
#
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.account.update(
    city: 'Bengaluru',
    name: 'Test Account',
    address: 'Test Address'
  )
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Example for Account update

var plivo = require('plivo');

(function main() {
    'use strict';
    
   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    client.accounts.update(
        {
            name: "Test Account",
            city: "Bengaluru",
            address: "Test Address",
        },
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
/**
 * Example for Account update
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->accounts->update(
        'Test Account',
        'Bengaluru',
        'Test Address'
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}

Was this code helpful

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
package com.plivo.api.samples.account;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.account.Account;
import com.plivo.api.models.account.AccountUpdateResponse;

/**
* Example for Account update
*/
class AccountUpdate {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>");
        try {
            AccountUpdateResponse response = Account.updater()
                .name("Test Account")
                .city("Bengaluru")
                .address("Test Address")
                .update();

            System.out.println(response);
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}

Was this code helpful

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
/**
 * Example for Account Update
 */
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Account.Update(
                    city:"Bengaluru",
                    name:"Test Account",
                    address:"Test Address"
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Was this code helpful

1
2
3
4
5
6
7
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{"name": "John Smith",
         "city": "San Francisco",
         "address": "123 Main St",
         "timezone": "America/Los_Angeles"}' \
    https://api.plivo.com/v1/Account/{auth_id}/

Was this code helpful

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
// Example for Account update
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Accounts.Update(
		plivo.AccountUpdateParams{
			Name:    "Test Account",
			City:    "Bengaluru",
			Address: "Test Address",
		},
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}

Was this code helpful

Response

HTTP Status Code: 202

{
  "api_id": "02bbdbaa-9303-11e7-8bc8-065f6a74a84a",
  "message": "changed"
}

Subaccount

You can manage multiple customer accounts using Subaccounts. Subaccounts are owned by a parent Account and can be used to segment, manage, and keep track of the account usage of each user independently.

API Endpoint

BaseURI https://api.plivo.com/v1/Account/{auth_id}/Subaccount/

The Subaccount object

Attributes

account string

URI to the parent account

auth_id string

Auth ID of the subaccount.

auth_token string

Auth Token of the subaccount.

created string

Date on which the subaccount was created.

enabled boolean

Whether the subaccount is enabled.

modified string

Date on which the subaccount was last modified.

name string

Name of the subaccount.

new_auth_token string 
resource_uri string

URI to the subaccount resource.

Response

{
  "account": "/v1/Account/MA2025RK4E639VJFZAGV/",
  "api_id": "968f0a22-9237-11e7-a51d-0245fa790d9e",
  "auth_id": "SA2025RK4E639VJFZAMM",
  "auth_token": "NWM3YjliMjk0ZGYxMGM2YjJiYWE0MjEwZDM5YWU5",
  "created": "2022-09-05",
  "enabled": true,
  "modified": null,
  "name": "Subaccount Test",
  "new_auth_token": "NWM3YjliMjk0ZGYxMGM2YjJiYWE0MjEwZDM5YWU5",
  "resource_uri": "/v1/Account/MA2025RK4E639VJFZAGV/Subaccount/SA2025RK4E639VJFZAMM/"
}

Create a Subaccount

Creates a new Subaccount object.

API Endpoint

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

Arguments

name required string

A human-readable name for the subaccount.

enabled boolean

Specifies whether the subaccount should be enabled. Takes a value of true or false. Defaults to false.

Example Request

1
2
3
4
5
6
7
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.subaccounts.create(
    name='Wayne Enterprises Subaccount',
    enabled=True, )
print(response)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# Example for Subaccount Create
#
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.subaccounts.create(
    'Test Subaccount',
    true,
  )
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example for Subaccount create

var plivo = require('plivo');

(function main() {
    'use strict';

   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    client.subAccounts.create(
        "Test Subaccount", // name
        true                 // enabled
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
 * Example for Subaccount create
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->subaccounts->create(
        'Test Subaccount',
        True
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}

Was this code helpful

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
package com.plivo.api.samples.subaccount;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.account.Subaccount;
import com.plivo.api.models.account.SubaccountCreateResponse;

/**
* Example for Subaccount create
*/
class SubaccountCreate {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>");
        try {
            SubaccountCreateResponse response = Subaccount.creator("Test Subaccount")
                .enabled(true)
                .create();

            System.out.println(response);
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}

Was this code helpful

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
/**
 * Example for Subaccount Create
 */
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Subaccount.Create(
                    enabled:true,
                    name:"Test Subaccount dotNet"
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Was this code helpful

1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{"name": "test_subaccount1","enabled": "True"}' \
    https://api.plivo.com/v1/Account/{auth_id}/Subaccount/

Was this code helpful

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
// Example for Subaccount create
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Subaccounts.Create(
		plivo.SubaccountCreateParams{
			Name:    "Test Subaccount",
			Enabled: true,
		},
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}

Was this code helpful

Response

HTTP Status Code: 201

{
"api_id": "324a7dd8-0db2-11e4-8a4a-123140008edf",
"auth_id": "SA2025RK4E639VJFZAMM",
"auth_token": "MTZjYWM0YzVjNjMwZmVmODFiNWJjNPJmOGJjZjgw",
"message": "created"
}

Retrieve a Subaccount

Retrieves the detail of a specific Subaccount.

API Endpoint

GET https://api.plivo.com/v1/Account/{auth_id}/Subaccount/{subauth_id}/

Arguments

No arguments need to be passed.

Returns

Returns a Subaccount object.

Example Request

1
2
3
4
5
6
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.subaccounts.get(
    auth_id='SA2025RK4E639VJFZAMM', )
print(response)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#
# Example for Subaccount Get
#
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.subaccounts.get(
    'SA2025RK4E639VJFZAMM'
  )
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Example for Subaccount get

var plivo = require('plivo');

(function main() {
    'use strict';
    
   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    client.subaccounts.get(
        "SA2025RK4E639VJFZAMM", // subauth id
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
/**
 * Example for Subaccount get
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->subaccounts->get(
        'SA2025RK4E639VJFZAMM'
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.plivo.api.samples.subaccount;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.account.Subaccount;
import com.plivo.api.models.account.Subaccount;

/**
* Example for Subaccount get
*/
class SubaccountGet {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>");
        try {
            Subaccount response = Subaccount.getter("SA2025RK4E639VJFZAMM")
                .get();

            System.out.println(response);
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}

Was this code helpful

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
/**
 * Example for Subaccount Get
 */
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Subaccount.Get(
                    id:"SA2025RK4E639VJFZAMM"
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Was this code helpful

1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Subaccount/{subauth_id}/

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Example for Subaccount get
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Subaccounts.Get(
		"SA2025RK4E639VJFZAMM",
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}

Was this code helpful

Response

HTTP Status Code: 200

{
  "account": "/v1/Account/MA2025RK4E639VJFZAGV/",
  "api_id": "323972b2-0db3-11e4-a2d1-22000ac5040c",
  "auth_id": "SA2025RK4E639VJFZAMM",
  "auth_token": "MTZjYWM0YzVjNjMwZmVmODFiNWJjNWJmOGJjZjgw",
  "created": "2022-07-17",
  "enabled": false,
  "modified": null,
  "name": "Han Solo",
  "resource_uri": "/v1/Account/MA2025RK4E639VJFZAGV/Subaccount/SA2025RK4E639VJFMM/"
}

Update a Subaccount

Updates the account object by setting the values to the parameters passed. Parameters that are not provided remain unchanged.

API Endpoint

POST https://api.plivo.com/v1/Account/{auth_id}/Subaccount/{subauth_id}/

Path parameters

auth_id required string

auth_id of the main account

subauth_id required string

auth_id of the subaccount

Arguments

name required string

Name of the Subaccount.

enabled boolean

Specifies whether the Subaccount should be enabled. Takes a value of true or false.

Returns

Returns a confirmation that the object is updated.

Example Request

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.subaccounts.update(
    auth_id='SA2025RK4E639VJFZAMM',
    name='Updated Subaccount Name', )
print(response)

# Or, you can use the subaccount object directly
subaccount_details = client.subaccounts.get(
    'SA2025RK4E639VJFZAMM', )
response = subaccount_details.update(
    name='Updated Subaccount Name', )
print(response)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Example for Subaccount Update
#
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.subaccounts.update(
    'SA2025RK4E639VJFZAMM',
    'Updated Subaccount Name',
    false
  )
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example for Subaccount update

var plivo = require('plivo');

(function main() {
    'use strict';
    
   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    client.subaccounts.update(
        "SA2025RK4E639VJFZAMM", // subauth id
        "Updated Subaccount Name", // name
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
 * Example for Subaccount update
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->subaccounts->update(
        'SA2025RK4E639VJFZAMM',
        'Updated Subaccount Name'
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.plivo.api.samples.subaccount;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.account.Subaccount;
import com.plivo.api.models.account.SubaccountUpdateResponse;

/**
* Example for Subaccount update
*/
class SubaccountUpdate {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>");
        try {
            SubaccountUpdateResponse response = Subaccount.updater("SA2025RK4E639VJFZAMM", "Updated Subaccount Name")
                .update();

            System.out.println(response);
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}

Was this code helpful

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
/**
 * Example for Subaccount Update
 */
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Subaccount.Update(
                    id:"SA2025RK4E639VJFZAMM",
                    name:"Updated Subaccount Name"
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Was this code helpful

1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{"name": "ABC_test"}' \
    https://api.plivo.com/v1/Account/{auth_id}/Subaccount/{subauth_id}/

Was this code helpful

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
// Example for Subaccount update
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Subaccounts.Update(
		"SA2025RK4E639VJFZAMM",
		plivo.SubaccountUpdateParams{
			Name: "Updated Subaccount Name",
		},
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}

Was this code helpful

Response

{
  "message": "changed",
  "api_id": "5a9fcb68-523d-11e1-86da-6ff39efcb949"
}

Delete a Subaccount

Permanently deletes a Subaccount. Optionally associates all Numbers, Endpoints, and Applications that were linked to the deleted Subaccount to the main Plivo Account.

API Endpoint

DELETE https://api.plivo.com/v1/Account/{auth_id}/Subaccount/{subauth_id}/

Arguments

cascade boolean

If cascade is set to true, the Applications, Endpoints, and Numbers associated with the Subaccount are also deleted. When set to false, the Applications, Endpoints, and Numbers are mapped with the main Account.

Defaults to false.

Example Request

1
2
3
4
5
6
7
8
9
10
11
12
13
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.subaccounts.delete(
    auth_id='SA2025RK4E639VJFZAMM',
    cascade=True )
print(response)

# Or, you could delete the subaccount directly using the subaccount object
subaccount = client.subaccounts.get(
    auth_id='SA2025RK4E639VJFZAMM', )
response = subaccount.delete(cascade=True)
print(response)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# Example for Subaccount Delete
#
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.subaccounts.delete(
    'SA2025RK4E639VJFZAMM’,
     true
  )
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
End

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Example for Subaccount delete

var plivo = require('plivo');

(function main() {
    'use strict';

   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    client.subaccounts.delete(
        "SA2025RK4E639VJFZAMM", // subauth id
         true  //cascade=true/false
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
 * Example for Subaccount delete
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->subaccounts->delete(
        'SA2025RK4E639VJFZAMM',
         true
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.plivo.api.samples.subaccount;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.account.Subaccount;

/**
* Example for Subaccount delete
*/
class SubaccountDelete {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>");
        try {
            Subaccount.deleter("SA2025RK4E639VJFZAMM").cascade(true)
                .delete();

            System.out.println("Deleted successfully.");
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}

Was this code helpful

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
/**
 * Example for Subaccount Delete
 */
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Subaccount.Delete(
                    id:"SA2025RK4E639VJFZAMM",
                    cascade: true
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Was this code helpful

1
2
curl -X DELETE --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Subaccount/{subauth_id}/

Was this code helpful

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
// Example for Subaccount delete
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	err = client.Subaccounts.Delete(
		"SA2025RK4E639VJFZAMM",
		plivo.SubaccountDeleteParams{Cascade: true},
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Println("Deleted successfully.")
}

Was this code helpful

Response

HTTP Status Code: 204

List all Subaccounts

Returns a list of subaccounts sorted by creation date, with the most recently created subaccount appearing first.

API Endpoint

GET https://api.plivo.com/v1/Account/{auth_id}/Subaccount/

Arguments

limit integer

Denotes the number of results displayed per page. The maximum number of results that can be fetched is 20.

offset integer

Denotes the number of value items by which the results should be offset.

Returns

An array of Subaccount objects.

Example Request

1
2
3
4
5
6
7
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')
response = client.subaccounts.list(
    offset=0,
    limit=5, )
print(response)

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# Example for Subaccount List
#
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

api = RestClient.new("<auth_id>","<auth_token>")

begin
  response = api.subaccounts.list(
    limit: 5,
    offset: 0,
  )
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
end

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Example for Subaccount list

var plivo = require('plivo');

(function main() {
    'use strict';
    
   // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
    var client = new plivo.Client("<auth_id>","<auth_token>");
    client.subaccounts.list(
        {
            offset: 0,
            limit: 5,
        },
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();

Was this code helpful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
 * Example for Subaccount list
 */
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("<auth_id>","<auth_token>");

try {
    $response = $client->subaccounts->list(
        3,
        2
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r($ex);
}

Was this code helpful

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
package com.plivo.api.samples.subaccount;

import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.account.Subaccount;
import com.plivo.api.models.base.ListResponse;

/**
* Example for Subaccount list
*/
class SubaccountList {
    public static void main(String [] args) {
        Plivo.init("<auth_id>","<auth_token>");
        try {
            ListResponse<Subaccount> response = Subaccount.lister()
                .offset(0)
                .limit(5)
                .list();

            System.out.println(response);
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}

Was this code helpful

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
/**
 * Example for Subaccount List
 */
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("<auth_id>","<auth_token>");
            try
            {
                var response = api.Subaccount.List(
                    limit:5,
                    offset:0
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}

Was this code helpful

1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Subaccount/

Was this code helpful

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
// Example for Subaccount list
package main

import (
	"fmt"

	"github.com/plivo/plivo-go/v7"
)

func main() {
	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	response, err := client.Subaccounts.List(
		plivo.SubaccountListParams{
			Offset: 0,
			Limit:  5,
		},
	)
	if err != nil {
		fmt.Print("Error", err.Error())
		return
	}
	fmt.Printf("Response: %#v\n", response)
}

Was this code helpful

Response

HTTP Status Code: 200

{
  "api_id": "b38bf42e-0db4-11e4-8a4a-123140008edf",
  "meta": {
    "limit": 20,
    "next": null,
    "offset": 0,
    "previous": null,
    "total_count": 2
  },
  "objects": [{
      "account": "/v1/Account/MA2025RK4E639VJFZAGV/",
      "auth_id": "SA2025RK4E639VJFZAMM",
      "auth_token": "MTZjYWM0YzVjNjMwZmVmODFiNWJjNWJmOGJjZjgw",
      "created": "2022-07-17",
      "enabled": false,
      "modified": null,
      "name": "Chewbacca",
      "resource_uri": "/v1/Account/MA2025RK4E639VJFZAGV/Subaccount/SA2025RK4E639VJFZAMM/"
    },
    {
      "account": "/v1/Account/MA2025RK4E639VJFZAGV/",
      "auth_id": "SA1914RK4E639VJFZAMM",
      "auth_token": "OTdhMjYwMWYxOGMyNpFjNzUwYWM3YWI3NjY4Y2Ey",
      "created": "2022-09-23",
      "enabled": true,
      "modified": "2022-09-23",
      "name": "new",
      "resource_uri": "/v1/Account/MA2025RK4E639VJFZAGV/Subaccount/SA1914RK4E639VJFZAMM/"
    }
  ]
}

Application

An Application is a set of Answer, Hangup, and Message URLs that help you control your incoming calls and messages.

API Endpoint

BaseURI https://api.plivo.com/v1/Account/{auth_id}/Application/

Answer URL

Plivo requests this URL for a valid Plivo XML element on an incoming call. The XML returned by this URL determines the flow of the call. For example, if you want to play a message on an incoming call to a Plivo number, the URL must return the XML as shown in the example response.

Plivo requests the Answer URL with the following parameters:

Parameters Plivo sends to the Answer URL

CallUUID string

A unique identifier for this call.

From string

The phone number of the party that initiated the call along with the country code. If the call is inbound, then it is the caller’s caller ID. If the call is outbound i.e. initiated via a request to the API, then this is the phone number you specify as the caller ID.

To string

The phone number of the called party with the country code. If the call is inbound, then it’s your incoming phone number. If the call is outbound, then it’s the phone number you provided to call.

ForwardedFrom string

This parameter is set only when the call received by Plivo is a forwarded call. Its value depends on the caller’s carrier. Not all carriers pass this information.

CallStatus string

Indicates the status of the call. The value is set to either ringing, in- progress,or completed. In case the call is hung up, the CallStatus is set to completed for inbound calls and to completed, busy, failed, timeout or no- answer for outbound calls.

Direction string

Indicates the direction of the call. In most cases this will be inbound, wherein the call would be in a ringing state. If you are using the Call API, the direction will be outbound, wherein the call will be in an answered state.

ALegUUID string

This contains a unique identifier which identifies the first leg of the call in case it is outbound. If the call direction is inbound, this parameter will not be present.

ALegRequestUUID string

Contains a unique request identifier which is returned by Plivo in case of a API request during an outbound call. In case the call direction is inbound, this parameter will not be present.

Hangup URL

Plivo will make an HTTP request to this URL when the call is hung up. The following parameters will be sent to the Hangup URL:

Parameters Plivo sends to the Hangup URL

CallUUID string

A unique identifier for this call.

From string

The phone number of the party that initiated the call along with the country code. If the call is inbound, then it is the caller’s caller ID. If the call is outbound i.e. initiated via a request to the API, then this is the phone number you specify as the caller ID.

To string

The phone number of the called party with the country code. If the call is inbound, then it’s your incoming phone number. If the call is outbound, then it’s the phone number you provided to call.

ForwardedFrom string

This parameter is set only when the call received by Plivo is a forwarded call. Its value depends on the caller’s carrier. Not all carriers pass this information.

CallStatus string

Indicates the status of the call. The value is set to either ringing, in-progress,or completed. In case the call is hung up, the CallStatus is set to completed for inbound calls and to completed, busy, failed, timeout or no-answer for outbound calls.

Direction string

Indicates the direction of the call. In most cases this will be inbound, wherein the call would be in a ringing state. If you are using the Call API, the direction will be outbound, wherein the call will be in an answered state.

ALegUUID string

This contains a unique identifier which identifies the first leg of the call in case it is outbound. If the call direction is inbound, this parameter will not present.

ALegRequestUUID string

Contains a unique request identifier which is returned by Plivo in case of a API request during an outbound call. In case the call direction is inbound, this parameter will not be present.

Duration string

Contains the duration of the call in seconds.

BillDuration string

Contains the billed duration of the call in seconds.

HangupCauseName string

The reason for the call hangup. Refer to this guide for a comprehensive list of hangup causes and sources.

HangupCauseCode integer

A unique integer code for the hangup cause. Refer to this guide for a comprehensive list of hangup causes and sources.

HangupSource string

The entity that triggered the call hangup. Possible hangup sources are Caller, Callee, Plivo, API Request, Answer XML, Error, and Unknown.

Refer to this guide for a comprehensive list of hangup causes and sources.

Message URL

Plivo will send all incoming messages to this URL. We expect to receive a HTTP status code of 200 from this URL. If a non 200 code is returned, we would keep retrying this URL once every 5 minutes for the first hour and then once every hour for 24 hours. Plivo will drop the message after 24 hours of receiving non 200 codes.

The following parameters will be sent to the Message URL.

Parameters Plivo sends to the Message URL

From string

The source number of the incoming message. This will be the number of the person sending a message to a Plivo number.

To string

The number to which the message was sent. This will the your Plivo number on which the message has been received.

Type string

Type of the message. This will always be sms.

Text string

The content of the message.

MessageUUID string

A unique ID for the message. Your message can be uniquely identified on Plivo by this ID.

Response

<Response>
    <Speak>Hello, thanks for call</Speak>
</Response>

The Application object

Attributes

answer_url string

On receiving an incoming call on a number of an endpoint attached to an Application, Plivo sends a request to the answer_url with the attributes of the call. We expect a valid Plivo XML response to be returned to the request Plivo makes.

answer_method string

The HTTP method to be used to request the answer_url when an incoming call is answered on the number or the endpoint attached to the application.

app_name string

A friendly name for your Plivo application.

default_app boolean

Specifies whether this is the default app.

enabled boolean

Set to true if the application is enabled.

fallback_answer_url string

Plivo requests this URL with the same parameters sent to the answer_url when the answer_url returns a non 200 HTTP status code.

fallback_answer_method string

The HTTP method to be used to request the fallback_answer_url when the answer_url returns a non 200 HTTP status code.

hangup_url string

If the incoming call is hung up on a number or an endpoint attached to the application, Plivo will send a request to the hangup_url with the attributes of the call.

hangup_method string

The HTTP method to be used to request the hangup_url when an incoming call is hung up on the number or the endpoint attached to the application.

message_url string

If an incoming message (SMS) is received to a number attached to the application, Plivo will make a request to the message_url with the parameters documented here.

message_method string

The HTTP method to be used to request the message_url when an incoming message (SMS) is received on the number attached to the application.

public_uri boolean

Set to true if the application can be called from an external SIP service. By default the application is not public, and external SIP services cannot call your application SIP URI.

sip_uri string

The SIP URI of the application. All Plivo applications can be called directly without attaching them to a number or an endpoint. When an incoming call is received on this URI, Plivo follows the same flow as it does with a number or an endpoint.

subaccount string

The subaccount associated with the application. If the application belongs to the main account, this field will be null.

log_incoming_messages boolean

This flag controls whether incoming messages to phone numbers associated with the Application are logged in Plivo systems. When set to false, message content is not logged in any Plivo system, including the debug logs visible on the console. Additionally, the last three digits of the from number are redacted in all system logs and in the Message Detail Record (MDR). The default value of this parameter is true.

Create an Application

Creates an Application. Creating an application is usually a first step, after which you attach the application to either a number or an endpoint.

API Endpoint

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

Arguments

answer_url required string

The URL fetched when a call executes this application.

app_name required string

The name of your application.
Allowed Values:

  • Alphabets (upper case and lower case)
  • Numbers (0-9).
  • Only 2 special characters, i.e. "-" (hyphen) and "_" (underscore)
  • answer_method string

    The method used to call the answer_url. Defaults to POST.

    hangup_url string

    The URL notified when the call hangs up. Defaults to answer_url.

    hangup_method string

    The method used to call the hangup_url. Defaults to POST.

    fallback_answer_url string

    Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain an XML response.

    fallback_method string

    The method used to call the fallback_answer_url. Defaults to POST.

    message_url string

    The URL notified when an inbound message is received. Defaults not set.

    message_method string

    The method used to call the message_url. Defaults to POST.

    default_number_app boolean

    If set to true, this parameter ensures that newly created numbers that don't have an app_id point to this application.

    default_endpoint_app boolean

    If set to true, this parameter ensures that newly created endpoints that don't have an app_id point to this application.

    subaccount string

    ID of the subaccount that this application is associated with.

    log_incoming_messages boolean

    If set to false, the content of incoming messages to Plivo phone numbers associated with this application are not logged in Plivo systems, including the debug logs available on the Plivo console. Additionally, the last three digits of the "from" number are redacted in all system logs and in the Message Detail Record (MDR) of the incoming message.

    Defaults to true when not specified.

    Note that non-redacted content and "from" number are always passed to the the message_url irrespective of the value set for this flag.

    Example Request

    1
    2
    3
    4
    5
    6
    7
    
    import plivo
    
    client = plivo.RestClient('<auth_id>','<auth_token>')
    response = client.applications.create(
        app_name='Test Application',
        answer_url='https://answer.url', )
    print(response)
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    #
    # Example for Application Create
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("<auth_id>","<auth_token>")
    
    begin
      response = api.applications.create(
        'Test Application',
        answer_url: 'https://answer.url',
        answer_method: 'GET'
      )
      puts response
    rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    // Example for Application create
    
    var plivo = require('plivo');
    
    (function main() {
        'use strict';
        
       // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
        var client = new plivo.Client("<auth_id>","<auth_token>");
        client.applications.create(
            "Test Application", // app name
        	{
    		answerUrl: "https://answer.url", // answer url
    	}
        ).then(function (response) {
            console.log(response);
        }, function (err) {
            console.error(err);
        });
    })();
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    <?php
    /**
     * Example for Application create
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("<auth_id>","<auth_token>");
    
    try {
        $response = $client->applications->create(
            'Test Application',
            [
    	'answer_url' => 'https://answer.url',
            'answer_method' => 'POST'
    	]
        );
        print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    package com.plivo.api.samples.application;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.application.Application;
    import com.plivo.api.models.application.ApplicationCreateResponse;
    
    /**
    * Example for Application create
    */
    class ApplicationCreate {
        public static void main(String [] args) {
            Plivo.init("<auth_id>","<auth_token>");
            try {
                ApplicationCreateResponse response = Application.creator("Test Application", "https://answer.url")
                    .create();
    
                System.out.println(response);
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    

    Was this code helpful

    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
    
    /**
     * Example for Application Create
     */
    using System;
    using System.Collections.Generic;
    using Plivo;
    using Plivo.Exception;
    
    namespace PlivoExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new PlivoApi("<auth_id>","<auth_token>");
                try
                {
                    var response = api.Application.Create(
                        appName:"Test Application",
                        answerUrl:"https://answer.url"
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    

    Was this code helpful

    1
    2
    3
    4
    
    curl -i --user AUTH_ID:AUTH_TOKEN \
        -H "Content-Type: application/json" \
        -d '{"answer_url": "https://<yourdomain>.com", "app_name": "Testing_App"}' \
        https://api.plivo.com/v1/Account/{auth_id}}/Application/
    

    Was this code helpful

    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
    
    // Example for Application create
    package main
    
    import (
    	"fmt"
    
    	"github.com/plivo/plivo-go/v7"
    )
    
    func main() {
    	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	response, err := client.Applications.Create(
    		plivo.ApplicationCreateParams{
    			AppName:   "Test Application",
    			AnswerURL: "https://answer.url",
    		},
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Printf("Response: %#v\n", response)
    }
    

    Was this code helpful

    Response

    HTTP Status Code: 201

    {
      "message": "created",
      "app_id": "15784735442685051",
      "api_id": "5a9fcb68-582d-11e1-86da-6ff39efcb949"
    }
    

    Get Details of a Single Application

    Get details of an particular application by passing the app_id. This API returns all the information linked with the application.

    API Endpoint

    GET https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/

    Arguments

    No arguments need to be passed.

    Returns

    Returns an Application object.

    Example Request

    1
    2
    3
    4
    5
    6
    
    import plivo
    
    client = plivo.RestClient('<auth_id>','<auth_token>')
    response = client.applications.get(
        app_id='24075895272788587', )
    print(response)
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    #
    # Example for Application Get
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("<auth_id>","<auth_token>")
    
    begin
      response = api.applications.get(
        '15784735442685051'
      )
      puts response
    rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    // Example for Application get
    
    var plivo = require('plivo');
    
    (function main() {
        'use strict';
        
       // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
        var client = new plivo.Client("<auth_id>","<auth_token>");
        client.applications.get(
            "15784735442685051", // app id
        ).then(function (response) {
            console.log(response);
        }, function (err) {
            console.error(err);
        });
    })();
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    <?php
    /**
     * Example for Application get
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("<auth_id>","<auth_token>");
    
    try {
        $response = $client->applications->get(
            '1101234567899201'
        );
        print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    package com.plivo.api.samples.application;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.application.Application;
    import com.plivo.api.models.application.Application;
    
    /**
    * Example for Application get
    */
    class ApplicationGet {
        public static void main(String [] args) {
            Plivo.init("<auth_id>","<auth_token>");
            try {
                Application response = Application.getter("15784735442685051")
                    .get();
    
                System.out.println(response);
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    

    Was this code helpful

    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
    
    /**
     * Example for Application Get
     */
    using System;
    using System.Collections.Generic;
    using Plivo;
    using Plivo.Exception;
    
    namespace PlivoExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new PlivoApi("<auth_id>","<auth_token>");
                try
                {
                    var response = api.Application.Get(
                        appId:"15784735442685051"
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    

    Was this code helpful

    1
    2
    
    curl -i --user AUTH_ID:AUTH_TOKEN \
        https://api.plivo.com/v1/Account/{auth_id}/Application/16631550192125875/
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    // Example for Application get
    package main
    
    import (
    	"fmt"
    
    	"github.com/plivo/plivo-go/v7"
    )
    
    func main() {
    	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	response, err := client.Applications.Get(
    		"15784735442685051",
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Printf("Response: %#v\n", response)
    }
    

    Was this code helpful

    Response

    HTTP Status Code:200

    {
      "answer_method": "GET",
      "answer_url": "https://<yourdomain>.com/dial.xml",
      "app_id": "20372631212782780",
      "app_name": "Dial Office",
      "default_app": false,
      "enabled": true,
      "fallback_answer_url": "",
      "fallback_method": "POST",
      "hangup_method": "POST",
      "hangup_url": "http://webapp.com/dial.xml",
      "message_method": "POST",
      "message_url": "",
      "public_uri": false,
      "resource_uri": "/v1/Account/MA2025RK4E639VJFZAGV/Application/20372631212782780/",
      "sip_uri": "sip:20372631212782780@app.plivo.com",
      "sub_account": null,
      "log_incoming_messages": true
    }
    

    Modify an Application

    Modify an application using this API.

    API Endpoint

    POST https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/

    Arguments

    answer_url

    The URL invoked when a call executes this application.

    answer_method

    The method used to call the answer_url. Defaults to POST.

    hangup_url

    The URL notified when the call hangs up.

    hangup_method

    The method used to call the hangup_url. Defaults to POST.

    fallback_answer_url

    Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.

    fallback_method

    The method used to call the fallback_answer_url. Defaults to POST.

    message_url

    The URL that is notified by Plivo when an inbound message is received.

    message_method

    The method used to call the message_url. Defaults to POST.

    default_number_app

    If set to true , associates all newly created Plivo numbers that have not specified an app_id to this application.Takes a value of True or False.

    default_endpoint_app

    If set to true , associates all newly created Plivo endpoints that have not specified an app_id to this application.Takes a values of True or False.

    subaccount

    ID of the subaccount with which this application is associated.

    log_incoming_messages

    This flag controls whether incoming messages to phone numbers associated with the Application are logged in Plivo systems or not. When set to false , message content is not logged in any Plivo system, including the debug logs visible on the console. Additionally, the last three digits of the from number are redacted in all system logs and in the Message Detail Record (MDR). The default value of this parameter is true .

    Example Request

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    import plivo
    
    client = plivo.RestClient('<auth_id>','<auth_token>')
    response = client.applications.update(
        app_id='21686794894743506',
        answer_url='https://updated.answer.url', )
    print(response)
    
    # You can updated an application directly using the application object
    application = client.applications.get('21686794894743506')
    application.update(
        answer_url='https://updated.answer.url', )
    print(response)
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    #
    # Example for Application Update
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("<auth_id>","<auth_token>")
    
    begin
      response = api.applications.update(
        '15784735442685051',
        answer_url: 'https://updated.answer.url'
      )
      puts response
    rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    // Example for Application update
    
    var plivo = require('plivo');
    
    (function main() {
        'use strict';
        
       // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
        var client = new plivo.Client("<auth_id>","<auth_token>");
        client.applications.update(
            "15784735442685051", // app id
            {
                answerUrl: "https://updated.answer.url",
            },
        ).then(function (response) {
            console.log(response);
        }, function (err) {
            console.error(err);
        });
    })();
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    <?php
    /**
     * Example for Application update
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("<auth_id>","<auth_token>");
    
    try {
        $response = $client->applications->update(
            '1101234567899201',
            [
            	'answer_url' => 'https://updated.answer.url'
            ]
        );
        print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
    

    Was this code helpful

    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
    
    package com.plivo.api.samples.application;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.application.Application;
    import com.plivo.api.models.application.ApplicationUpdateResponse;
    
    /**
    * Example for Application update
    */
    class ApplicationUpdate {
        public static void main(String [] args) {
            Plivo.init("<auth_id>","<auth_token>");
            try {
                ApplicationUpdateResponse response = Application.updater("15784735442685051")
                    .answerUrl("https://updated.answer.url")
                    .update();
    
                System.out.println(response);
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    

    Was this code helpful

    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
    
    /**
     * Example for Application Update
     */
    using System;
    using System.Collections.Generic;
    using Plivo;
    using Plivo.Exception;
    
    namespace PlivoExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new PlivoApi("<auth_id>","<auth_token>");
                try
                {
                    var response = api.Application.Update(
                        appId:"15784735442685051",
                        answerUrl:"https://updated.answer.url"
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    

    Was this code helpful

    1
    2
    3
    4
    
    curl -i --user AUTH_ID:AUTH_TOKEN  \
        -H "Content-Type: application/json" \
        -d '{"answer_url": "https://<yourdomain>.com"}' \
        https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/
    

    Was this code helpful

    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
    
    // Example for Application update
    package main
    
    import (
    	"fmt"
    
    	"github.com/plivo/plivo-go/v7"
    )
    
    func main() {
    	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	response, err := client.Applications.Update(
    		"15784735442685051",
    		plivo.ApplicationUpdateParams{
    			AnswerURL: "https://updated.answer.url",
    		},
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Printf("Response: %#v\n", response)
    }
    

    Was this code helpful

    Response

    HTTP Status Code: 202

    {
    "message": "changed",
    "api_id": "5a9fcb68-582d-11e1-86da-6ff39efcb949"
    }
    

    Delete an Application

    This API deletes an Application permanently.

    API Endpoint

    DELETE https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/

    Arguments

    cascadeBoolean

    If cascade is set to true, the Endpoints associated with the Application, if any, are also deleted.

    When set to false, the Endpoints associated with the Application, if any, are not deleted. If a new_endpoint_application has been specified, then the Endpoints are reassociated with the given Application. If a new_endpoint_application is not specified, then the Endpoints remain orphaned (i.e. not associated with any Application).

    Defaults to true.

    new_endpoint_applicationString

    The app_id of the new Application to which the Endpoints should be associated upon deletion of this Application.

    Example Request

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    import plivo
    
    client = plivo.RestClient('<auth_id>','<auth_token>')
    response = client.applications.delete(
        app_id='21686794894743506', )
    print(response)
    
    # You can updated an application directly using the application object
    application = client.applications.get('21686794894743506')
    application.delete()
    print(response)
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    #
    # Example for Application Delete
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("<auth_id>","<auth_token>")
    
    begin
      response = api.applications.delete(
        '15784735442685051'
      )
      puts response
    rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    // Example for Application delete
    
    var plivo = require('plivo');
    
    (function main() {
        'use strict';
        
       // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
        var client = new plivo.Client("<auth_id>","<auth_token>");
        client.applications.delete(
            "15784735442685051", // app id
        ).then(function (response) {
            console.log(response);
        }, function (err) {
            console.error(err);
        });
    })();
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    <?php
    /**
     * Example for Application delete
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("<auth_id>","<auth_token>");
    
    try {
        $response = $client->applications->delete(
            '15784735442685051'
        );
        print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    package com.plivo.api.samples.application;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.application.Application;
    
    /**
    * Example for Application delete
    */
    class ApplicationDelete {
        public static void main(String [] args) {
            Plivo.init("<auth_id>","<auth_token>");
            try {
                Application.deleter("15784735442685051")
                    .delete();
    
                System.out.println("Deleted successfully.");
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    

    Was this code helpful

    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
    
    /**
     * Example for Application Delete
     */
    using System;
    using System.Collections.Generic;
    using Plivo;
    using Plivo.Exception;
    
    namespace PlivoExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new PlivoApi("<auth_id>","<auth_token>");
                try
                {
                    var response = api.Application.Delete(
                        appId:"15784735442685051"
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    

    Was this code helpful

    1
    2
    
    curl -X DELETE -i --user AUTH_ID:AUTH_TOKEN \
        https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    // Example for Application delete
    package main
    
    import (
    	"fmt"
    
    	"github.com/plivo/plivo-go/v7"
    )
    
    func main() {
    	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	err = client.Applications.Delete(
    		"15784735442685051",
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Println("Deleted successfully.")
    }
    

    Was this code helpful

    Response

    HTTP Status Code: 204

    Get Details of All Applications

    This API is used to get details of all the application that have been created under your Plivo account.

    API Endpoint

    GET https://api.plivo.com/v1/Account/{auth_id}/Application/

    Arguments

    subaccount string

    ID of the subaccount, in case only subaccount applications are needed.

    limit integer

    Used to display the number of results per page. The maximum number of results that can be fetched is 20.

    offset integer

    Denotes the number of value items by which the results should be offset.

    app_name string

    Returns applications that start with the provided value.

    Returns

    Returns a list of Application objects.

    Example Request

    1
    2
    3
    4
    5
    6
    7
    
    import plivo
    
    client = plivo.RestClient('<auth_id>','<auth_token>')
    response = client.applications.list(
        offset=0,
        limit=5, )
    print(response)
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    #
    # Example for Application List
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("<auth_id>","<auth_token>")
    
    begin
      response = api.applications.list(
        limit: 5,
        offset: 0
      )
      puts response
    rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    // Example for Application list
    
    var plivo = require('plivo');
    
    (function main() {
        'use strict';
        
       // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
        var client = new plivo.Client("<auth_id>","<auth_token>");
        client.applications.list(
            {
                offset: 0,
                limit: 5,
            },
        ).then(function (response) {
            console.log(response);
        }, function (err) {
            console.error(err);
        });
    })();
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    <?php
    /**
     * Example for Application list
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("<auth_id>","<auth_token>");
    
    try {
        $response = $client->applications->list(
            [
                'subaccount' => 'SUBACCOUNT_ID',
                'limit' => 0,
                'offset' => 3
            ]
        );
        print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
    

    Was this code helpful

    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
    
    package com.plivo.api.samples.application;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.application.Application;
    import com.plivo.api.models.base.ListResponse;
    
    /**
    * Example for Application list
    */
    class ApplicationList {
        public static void main(String [] args) {
            Plivo.init("<auth_id>","<auth_token>");
            try {
                ListResponse<Application> response = Application.lister()
                    .offset(0)
                    .limit(5)
                    .list();
    
                System.out.println(response);
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    

    Was this code helpful

    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
    
    /**
     * Example for Application List
     */
    using System;
    using System.Collections.Generic;
    using Plivo;
    using Plivo.Exception;
    
    namespace PlivoExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new PlivoApi("<auth_id>","<auth_token>");
                try
                {
                    var response = api.Application.List(
                        limit:5,
                        offset:0
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    

    Was this code helpful

    1
    2
    
    curl -i --user AUTH_ID:AUTH_TOKEN \
        https://api.plivo.com/v1/Account/{auth_id}/Application/
    

    Was this code helpful

    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
    
    // Example for Application list
    package main
    
    import (
    	"fmt"
    
    	"github.com/plivo/plivo-go/v7"
    )
    
    func main() {
    	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	response, err := client.Applications.List(
    		plivo.ApplicationListParams{
    			Offset: 0,
    			Limit:  5,
    		},
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Printf("Response: %#v\n", response)
    }
    

    Was this code helpful

    Pricing

    You can retrieve rates for a country for both inbound and outbound calls.

    API Endpoint

    BaseURI https://api.plivo.com/v1/Account/{auth_id}/Pricing/

    The Pricing object

    Attributes

    country string

    Name of the country

    country_code integer

    Country calling code of the country

    country_iso string

    ISO 3166 Alpha-2 code for the country

    message

    Pricing for outbound and inbound messages, and outbound networks list

    phone_numbers

    Pricing for local, mobile, national, and toll-free numbers. Monthly rental and one-time setup prices for numbers based on the number’s voice and/or SMS capabilities.

    voice

    Pricing for outbound and inbound voice calls, split by local, toll-free, and IP. Also specifies prefix-wise rates for outbound voice calls.

    Response

    {
      "api_id": "7ff5505c-93ca-11e7-9bde-024427e23b8a",
      "country": "United States",
      "country_code": 1,
      "country_iso": "US",
      "message": {
        "inbound": {
          "rate": "0.00000"
        },
        "outbound": {
          "rate": "0.00350"
        },
        "outbound_networks_list": [{
            "group_name": "US",
            "rate": "0.00350"
          },
          {
            "group_name": "United States - AT&T Mobility",
            "rate": "0.00350"
          }
        ]
      },
      "phone_numbers": {
        "local": {
          "rate": "1.0000",
          "rates": [{
              "capabilities": ["voice", "sms"],
              "rental_rate": "1.00",
              "setup_rate": "0.50"
            },
            {
              "capabilities": ["voice"],
              "rental_rate": "1.00",
              "setup_rate": "0.00"
            }]
        },
        "tollfree": {
          "rate": "1.00000",
          "rates": [{
              "capabilities": ["voice", "sms"],
              "rental_rate": "1.00",
              "setup_rate": "0.30"
            }]
        },
        "mobile": {
          "rate": "1.00000",
          "rates": [{
              "capabilities": ["sms"],
              "rental_rate": "2.00",
              "setup_rate": "0.30"
            }]
        },
        "national": {
          "rate": "1.00000",
          "rates": [{
              "capabilities": ["voice"],
              "rental_rate": "1.00",
              "setup_rate": "0.1000"
            }]
        }
      },
      "voice": {
        "inbound": {
          "ip": {
            "rate": "0.00300"
          },
          "local": {
            "rate": "0.00850"
          },
          "tollfree": {
            "rate": "0.02100"
          }
        },
        "outbound": {
          "ip": {
            "rate": "0.00300"
          },
          "local": {
            "rate": "0.00750"
          },
          "rates": [{
            "prefix": [
              "1"
            ],
            "rate": "0.00750"
          }],
          "tollfree": {
            "rate": null
          }
        }
      }
    }
    

    Retrieve pricing for a country

    Retrieves pricing for a specified country.

    API Endpoint

    GET https://api.plivo.com/v1/Account/{auth_id}/Pricing/

    Arguments

    country_iso required string

    The two-character country ISO code — for example, US for United States.

    Returns

    The Pricing object.

    Example Request

    1
    2
    3
    4
    5
    6
    
    import plivo
    
    client = plivo.RestClient('<auth_id>','<auth_token>')
    response = client.pricing.get(
        country_iso='GB', )
    print(response)
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    #
    # Example for Pricing Get
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("<auth_id>","<auth_token>")
    
    begin
      response = api.pricings.get(
        'GB'
      )
      puts response
    rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    // Example for Pricing get
    
    var plivo = require('plivo');
    
    (function main() {
        'use strict';
        
       // If auth id and auth token are not specified, Plivo will fetch them from the environment variables.
        var client = new plivo.Client("<auth_id>","<auth_token>");
        client.pricings.get(
            "GB", // country iso
        ).then(function (response) {
            console.log(response);
        }, function (err) {
            console.error(err);
        });
    })();
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    <?php
    /**
     * Example for Pricing get
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("<auth_id>","<auth_token>");
    
    try {
        $response = $client->pricing->get(
            'GB'
        );
        print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    package com.plivo.api.samples.pricing;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.pricing.Pricing;
    import com.plivo.api.models.pricing.Pricing;
    
    /**
    * Example for Pricing get
    */
    class PricingGet {
        public static void main(String [] args) {
            Plivo.init("<auth_id>","<auth_token>");
            try {
                Pricing response = Pricing.getter("GB")
                    .get();
    
                System.out.println(response);
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    

    Was this code helpful

    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
    
    /**
     * Example for Pricing Get
     */
    using System;
    using System.Collections.Generic;
    using Plivo;
    using Plivo.Exception;
    
    namespace PlivoExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new PlivoApi("<auth_id>","<auth_token>");
                try
                {
                    var response = api.Pricing.Get(
                        countryIso:"GB"
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    

    Was this code helpful

    1
    2
    
    curl -i --user auth_id:auth_token \
        https://api.plivo.com/v1/Account/{auth_id}/Pricing/?country_iso=US
    

    Was this code helpful

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    // Example for Pricing get
    package main
    
    import (
    	"fmt"
    
    	"github.com/plivo/plivo-go/v7"
    )
    
    func main() {
    	client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	response, err := client.Pricing.Get(
    		"GB",
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Printf("Response: %#v\n", response)
    }
    

    Was this code helpful

    Response

    HTTP Status Code: 200

    {
       "api_id":"7ff5505c-93ca-11e7-9bde-024427e23b8a",
       "country":"United States",
       "country_code":1,
       "country_iso":"US",
       "message":{
          "inbound":{
             "rate":"0.00000"
          },
          "outbound":{
             "rate":"0.00350"
          },
          "outbound_networks_list":[
             {
                "group_name":"US",
                "rate":"0.00350"
             },
             {
                "group_name":"United States - AT&T Mobility",
                "rate":"0.00350"
             }
          ]
       },
       "phone_numbers":{
          "local":{
             "rate":"0.80000"
          },
          "tollfree":{
             "rate":"1.00000"
          }
       },
       "voice":{
          "inbound":{
             "ip":{
                "rate":"0.00300"
             },
             "local":{
                "rate":"0.00850"
             },
             "tollfree":{
                "rate":"0.02100"
             }
          },
          "outbound":{
             "ip":{
                "rate":"0.00300"
             },
             "local":{
                "rate":"0.00750"
             },
             "rates":[
                {
                   "prefix":[
                      "1"
                   ],
                   "origination_prefix":[
                      "" // blank string represents default rate
                   ],
                   "rate":"0.00750"
                },
                {
                   "prefix":[
                      "1"
                   ],
                   "origination_prefix":[
                      "1232", "1434", "1652"
                   ],
                   "rate":"0.0150"
                }
             ],
             "tollfree":{
                "rate":null
             }
          }
       }
    }