Application API

The Application API lets you perform actions on your Plivo application.

The following actions can be performed with the Application API.

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

Prerequisites

  1. Sign up for a free Plivo trial account.
  2. Check out our Helper Libraries page and install the right helper based on the programming language you want to use.
  3. Buy a Plivo phone number. A phone number is required to receive calls. You can buy a Plivo phone number in over 20+ countries through the Buy Numbers tab on your Plivo account UI. Check the Voice API coverage page for all the supported countries.
  4. Use a web hosting service to host your web application. There are many inexpensive cloud hosting providers that you can use for just a few dollars a month. Follow the instructions of your hosting provider to host your web application.

Create an Application

Create an application on Plivo by calling this API. Creating an application is usually the first step, after which you would attach this application either to a number or an endpoint.

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

Code

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

auth_id = "Your AUTH_ID"
auth_token = "Your AUTH_TOKEN"
p = plivo.RestAPI(auth_id, auth_token)

params = {
  # The URL Plivo will fetch when a call executes this application
  'answer_url': 'http://example.com',
  'app_name': 'Testing_App' # The name of your application
}
# Create a new application
response = p.create_application(params)
print str(response)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require 'rubygems'
require 'plivo'
include Plivo

AUTH_ID = "Your AUTH_ID"
AUTH_TOKEN = "Your AUTH_TOKEN"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

params = {
  # The URL Plivo will fetch when a call executes this application
  'answer_url' => 'http://example.com',
  'app_name' => 'Testing_App' # The name of your application
}
# Create a new application
response = p.create_application(params)
print response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
var plivo = require('plivo');
var p = plivo.RestAPI({
  authId: 'Your AUTH_ID',
  authToken: 'Your AUTH_TOKEN'
});

var params = {
  // The URL Plivo will fetch when a call executes this application
  'answer_url': 'http://example.com',
  'app_name': 'Testing_App' // The name of your application
};
// Create a new application
var response = p.create_application(params);
console.log(response);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?php
    require 'vendor/autoload.php';
    use Plivo\RestAPI;

    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";
    $p = new RestAPI($auth_id, $auth_token);

    $params = array(
            # The URL Plivo will fetch when a call executes this application
            'answer_url' => 'http://example.com',
            'app_name' => 'Testing_App' # The name of your application
        );
    // Create an Application
    $response = $p->create_application($params);
    print_r ($response['response']);
?>
 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 plivoexample;

import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.application.Application;
import com.plivo.helper.exception.PlivoException;

public class App {
    public static void main(String[] args) throws IllegalAccessException {
        String auth_id = "Your AUTH_ID";
        String auth_token = "Your AUTH_TOKEN";
        RestAPI api = new RestAPI(auth_id, auth_token, "v1");

        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        // The URL Plivo will fetch when a call executes this application
        parameters.put("answer_url","http://example.com");
        parameters.put("app_name","Testing_App"); // The name of your application

        try {
            // Create an Application
            Application resp = api.createApplication(params);
            System.out.println((resp));
        } catch (PlivoException e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
}
 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
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;

namespace apps
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");
            // Create a new application
            IRestResponse<GenericResponse> resp = plivo.create_application(new Dictionary<string,string>()
            {
                // The URL Plivo will fetch when a call executes this application
                {"answer_url", "http://example.com"},
                {"app_name", "Testing_App"} // The name of your application
            });

            //Prints the response
            Console.Write(resp.Content);
        }
    }
}
1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{"answer_url": "http://example.com", "app_name": "Testing_App"}' \
    https://api.plivo.com/v1/Account/{auth_id}}/Application/

Sample Response

(201, {
        u'message': u'created',
        u'app_id': u'21935628481970026',
        u'api_id': u'a50543a6-8a64-11e4-b153-22000abcaa64'
    }
)

Get Details of All Applications

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

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

Code

 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
import plivo

auth_id = "Your AUTH_ID"
auth_token = "Your AUTH_TOKEN"
p = plivo.RestAPI(auth_id, auth_token)

# Get details all existing applications
params = {
  'limit' : '10', # The number of results per page
  'offset' : '0' # The number of value items by which the results should be offset
}

response = p.get_applications(params)
print str(response)

# Print the total number of apps
print "Total count: %s" % (response[1]['meta']['total_count'])

# Print public_uri, default_app, default_endpoint
for i in range(0,response[1]['meta']['total_count']):
  print "--------"
  print "App Name: %s" % (response[1]['objects'][i]['app_name'])
  print "Answer URL: %s" % (response[1]['objects'][i]['answer_url'])
  print "Hangup URL: %s" % (response[1]['objects'][i]['hangup_url'])
  print "Message URL: %s" % (response[1]['objects'][i]['message_url'])
 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
32
require 'rubygems'
require 'plivo'
include Plivo

AUTH_ID = "Your AUTH_ID"
AUTH_TOKEN = "Your AUTH_TOKEN"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

# Get details all existing applications
params = {
  'limit' => '10', # The number of results per page
  'offset' => '0' # The number of value items by which the results should be offset
}

response = p.get_applications(params)
print response

# Print the total number of apps
puts "Total count: " + response[1]['meta']['total_count']

# Print public_uri, default_app, default_endpoint
count = response[1]['meta']['total_count']
for i in (0..count-1)
    name = response[1]['objects'][i]['app_name']
    answer_url = response[1]['objects'][i]['answer_url']
    hangup_url = response[1]['objects'][i]['hangup_url']
    message_url = response[1]['objects'][i]['message_url']
    puts "App Name: #{name}"
    puts "Answer URL: #{answer_url}"
    puts "Hangup URL: #{hangup_url}"
    puts "Message URL: #{message_url}"
end
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var plivo = require('plivo');
var p = plivo.RestAPI({
  authId: 'Your AUTH_ID',
  authToken: 'Your AUTH_TOKEN'
});

// Filtering the records
var params = {
  'limit': '10', // The number of results per page
  'offset': '0', // The number of items by which the results should be offset
};

p.get_applications(params, function (status, response) {
  console.log('Status: ', status);
  console.log('API Response:\n', response);
  console.log("Total count: " + response.meta.total_count);
  for (var i = 0; i < response.meta.total_count; i++) {
    console.log("--------");
    console.log("App Name: " + response.objects[i].app_name);
    console.log("Answer URL: " + response.objects[i].answer_url);
    console.log("Hangup URL: " + response.objects[i].hangup_url);
    console.log("Message URL: " + response.objects[i].message_url);
  }
});
 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
<?php
    require 'vendor/autoload.php';
    use Plivo\RestAPI;

    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";
    $p = new RestAPI($auth_id, $auth_token);

    // Get Details of all existing Applications
    $response = $p->get_applications();
    print_r ($response['response']);

    // Print the total number of Applications
    echo "<br>Total count: " . ($response['response']['meta']['total_count']);

    // Print public_uri, default_app, default_endpoint
    $count = ($response['response']['meta']['total_count']);
    for ($i=0; $i<$count; $i++) {
        echo "<br>--------";
        echo "<br>App Name: "    . $response['response']['objects'][$i]['app_name'];
        echo "<br>Answer URL: "  . $response['response']['objects'][$i]['answer_url'];
        echo "<br>Hangup URL: "  . $response['response']['objects'][$i]['hangup_url'];
        echo "<br>Message URL: " . $response['response']['objects'][$i]['message_url'];
    }
?>
 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
32
33
34
35
36
37
38
package plivoexample;

import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.application.ApplicationFactory;
import com.plivo.helper.exception.PlivoException;

public class App {
    public static void main(String[] args) throws IllegalAccessException {
        String auth_id = "Your AUTH_ID";
        String auth_token = "Your AUTH_TOKEN";
        RestAPI api = new RestAPI(auth_id, auth_token, "v1");

        // Get details all existing applications
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        // The number of results per page
        params.put("limit","10");
        // The number of items by which the results should be offset
        params.put("offset", "0");

        try {
            ApplicationFactory resp = api.getApplications(params);
            System.out.println(resp);

            // Print the total number of apps
            System.out.println("Total count: " + resp.meta.total_count);
            for (int i = 0; i < resp.meta.total_count; i++) {
                System.out.println("--------");
                System.out.println("App Name: " + resp.objects[i].app_name);
                System.out.println("Answer URL: " + resp.objects[i].answer_url);
                System.out.println("Hangup URL: " + resp.objects[i].hangup_url);
                System.out.println("Message URL: " + resp.objects[i].message_url);
            }
        } catch (PlivoException e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
}
 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
32
33
34
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;

namespace apps
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");
            // Get details of all existing applications
            IRestResponse<ApplicationList> res = plivo.get_applications(new Dictionary<string, string>(){});

            //Prints the response
            Console.Write(res.Content);

            // Prints the total number of apps
            Console.WriteLine("Total count : " + res.Data.meta.total_count);

            // Prints the public_uri, default_app
            int count = res.Data.meta.total_count;
            for (int i = 0; i < count; i++)
            {
                Console.WriteLine("--------");
                Console.WriteLine("App Name: {0}", res.Data.objects[i].app_name);
                Console.WriteLine("Answer URL: {0}", res.Data.objects[i].answer_url);
                Console.WriteLine("Hangup URL: {0}", res.Data.objects[i].hangup_url);
                Console.WriteLine("Message URL: {0}", res.Data.objects[i].message_url);
            }
        }
    }
}
1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Application/

Sample Response

(200, {
        u'meta': {
            u'previous': None,
            u'total_count': 7,
            u'offset': 0,
            u'limit': 10,
            u'next': None
        },
        u'objects': [
            {
                u'fallback_method': u'POST',
                u'default_app': False,
                u'app_name': u'Testing_App',
                u'sub_account': None,
                u'production_app': False,
                u'enabled': True,
                u'app_id': u'21935628481970026',
                u'public_uri': False,
                u'hangup_url': u'http://example.com',
                u'sip_uri': u'sip:21935628481970026@app.plivo.com',
                u'default_endpoint_app': False,
                u'answer_url': u'http://example.com',
                u'message_url': u'',
                u'resource_uri': u'/v1/Account/xxxxxxxxxxxxxxxxx/Application/21935628481970026/',
                u'hangup_method': u'POST',
                u'message_method': u'POST',
                u'fallback_answer_url': u'',
                u'answer_method': u'POST'
            },
            {
                u'fallback_method': u'POST',
                u'default_app': False,
                u'app_name': u'Receive SMS',
                u'sub_account': None,
                u'production_app': False,
                u'enabled': True,
                u'app_id': u'26469261154421101',
                u'public_uri': False,
                u'hangup_url': u'http://morning-ocean-4669.herokuapp.com/response/conference/',
                u'sip_uri': u'sip:26469261154421101@app.plivo.com',
                u'default_endpoint_app': False,
                u'answer_url': u'http://morning-ocean-4669.herokuapp.com/response/conference/',
                u'message_url': u'http://morning-ocean-4669.herokuapp.com/message/',
                u'resource_uri': u'/v1/Account/xxxxxxxxxxxxxxxxx/Application/26469261154421101/',
                u'hangup_method': u'POST',
                u'message_method': u'GET',
                u'fallback_answer_url': u'',
                u'answer_method': u'GET'
            }
        ]
    }
)

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.

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

Code

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

auth_id = "Your_AUTH_ID"
auth_token = "Your_AUTH_TOKEN"
p = plivo.RestAPI(auth_id, auth_token)

# Get details of a single application
params = {
    # Application ID for which to retrieve details
    'app_id': '16631550192125875'
}

response = p.get_application(params)
print str(response)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require 'rubygems'
require 'plivo'
include Plivo

AUTH_ID = "Your AUTH_ID"
AUTH_TOKEN = "Your AUTH_TOKEN"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

# Get details of a single application
params = {
    # Application ID for which to retrieve details
    'app_id' => '16631550192125875'
}

response = p.get_application(params)
puts response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
var plivo = require('plivo');
var p = plivo.RestAPI({
  authId: 'Your_AUTH_ID',
  authToken: 'Your_AUTH_TOKEN'
});

var params = {
    // Application ID for which to retrieve details
    'app_id': '16631550192125875'
};
p.get_application(params, function (status, response) {
    console.log('Status: ', status);
    console.log('API Response:\n', response);
});
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?php
    require 'vendor/autoload.php';
    use Plivo\RestAPI;

    $auth_id = "Your_AUTH_ID";
    $auth_token = "Your_AUTH_TOKEN";
    $p = new RestAPI($auth_id, $auth_token);

    // Get details of Single Application
    $params = array(
        # Application ID for which to retrieve details
        'app_id' => '16631550192125875'
    );
    $response = $p->get_application($params);
    print_r ($response['response']);
?>
 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 plivoexample;

import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.application.Application;
import com.plivo.helper.exception.PlivoException;

public class App {
    public static void main(String[] args) throws IllegalAccessException {
        String auth_id = "Your AUTH_ID";
        String auth_token = "Your AUTH_TOKEN";
        RestAPI api = new RestAPI(auth_id, auth_token, "v1");

        // Get details of a single application
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        // Application ID for which to retrieve details
        params.put("app_id","16631550192125875");

        try {
            Application resp = api.getApplication(params);
            System.out.println(resp);
        } catch (PlivoException e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;

namespace apps
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");

            // Get details of a single application
            IRestResponse<Application> res1 = plivo.get_application(new Dictionary<string, string>()
            {
                {"app_id","16631550192125875"} // Application ID for which to retrieve details
            });

            // Prints the response
            Console.Write(res1.Content);
        }
    }
}
1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Application/16631550192125875/

Sample Response

(200, {
       u'fallback_method': u'GET',
       u'default_app': True,
       u'app_name': u'Phone TTS',
       u'sub_account': None,
       u'production_app': False,
       u'enabled': True,
       u'app_id': u'16631550192125875',
       u'api_id': u'e90bca98-8a69-11e4-ac1f-22000ac51de6',
       u'hangup_url': u'http://mysterious-reaches-5041.herokuapp.com/response/speak/',
       u'sip_uri': u'sip:16631550192125875@app.plivo.com',
       u'default_endpoint_app': False,
       u'answer_url': u'https://morning-ocean-4669.herokuapp.com/speech/',
       u'public_uri': False,
       u'message_url': u'https://morning-ocean-4669.herokuapp.com/response/conference/',
       u'resource_uri': u'/v1/Account/xxxxxxxxxxxxxxxxx/Application/16631550192125875/',
       u'hangup_method': u'POST',
       u'message_method': u'POST',
       u'fallback_answer_url': u'',
       u'answer_method': u'GET'
   }
)

Modify an Application

Modify an application using this API.

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

Code

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

auth_id = "Your AUTH_ID"
auth_token = "Your AUTH_TOKEN"
p = plivo.RestAPI(auth_id, auth_token)

params = {
    # ID of the application to be modified
    'app_id' : '16631550192125875',
    # Vales to be updated
    'answer_url': 'http://exampletest.com'
}

response = p.modify_application(params)
print str(response)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
require 'rubygems'
require 'plivo'
include Plivo

AUTH_ID = "Your AUTH_ID"
AUTH_TOKEN = "Your AUTH_TOKEN"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

# Modify an application
params = {
    # ID of the application to be modified
    'app_id' => '16631550192125875',
    # Values to be updated
    'answer_url' => 'http://exampletest.com'
}

response = p.modify_application(params)
print response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<?php
    require 'vendor/autoload.php';
    use Plivo\RestAPI;

    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";
    $p = new RestAPI($auth_id, $auth_token);

    # Modify an Application
    $params = array(
        # ID of the application for which has to be modified
        'app_id' => '16631550192125875',
        # Values to be updated
        'answer_url' => 'http://yourexample.com'
    );
    $response = $p->modify_application($params);
    print_r ($response['response']);
?>
 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
package plivoexample;

import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.application.GenericResponse;
import com.plivo.helper.exception.PlivoException;

public class App {
    public static void main(String[] args) throws IllegalAccessException {
        String auth_id = "Your AUTH_ID";
        String auth_token = "Your AUTH_TOKEN";
        RestAPI api = new RestAPI(auth_id, auth_token, "v1");

        // Modify an application
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        // ID of the application to be modified
        params.put("app_id","16631550192125875");
        // Values to be updated
        params.put("answer_url", "http://exampletest.com");

        try {
            GenericResponse resp = api.editApplication(params);
            System.out.println(getFields(resp));
        } catch (PlivoException e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
}
 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
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;

namespace apps
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");

            // Modify an application
            IRestResponse<GenericResponse> res = plivo.modify_application(new Dictionary<string, string>()
            {
                {"app_id","16631550192125875"}, // ID of the application that has to be modified
                {"answer_url","http://exampletest.com"} // Values that have to be updated
            });

            //Prints the response
            Console.Write(res.Content);
        }
    }
}
1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN  \
    -H "Content-Type: application/json" \
    -d '{"answer_url": "http://exampletest.com"}' \
    https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/

Sample Response

(202, {
       u'message': u'changed',
       u'api_id': u'6d886ed4-8a6a-11e4-ac1f-22000ac51de6'
    }    
)

Delete an Application

This API would delete the Plivo application. Use this API wisely, once an application is deleted, it cannot be retrived.

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

Code

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

auth_id = "Your AUTH_ID"
auth_token = "Your AUTH_TOKEN"
p = plivo.RestAPI(auth_id, auth_token)

# Delete an application
params = {
    # ID of the application to be deleted
    'app_id' : '16631550192125875'
}

response = p.delete_application(params)
print str(response)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
require 'rubygems'
require 'plivo'
include Plivo

AUTH_ID = "Your AUTH_ID"
AUTH_TOKEN = "Your AUTH_TOKEN"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

# Delete an application
params = {
    # ID of the application to be deleted
    'app_id' => '16631550192125875'
}

response = p.delete_application(params)
print response
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<?php
    require 'vendor/autoload.php';
    use Plivo\RestAPI;

    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";
    $p = new RestAPI($auth_id, $auth_token);

    /// Delete an Application
    $params = array(
        // ID of the application to be deleted
        'app_id' => '16631550192125875'
    );
    $response = $p->delete_application($params);
    print_r ($response);
?>
 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 plivoexample;

import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.application.GenericResponse;
import com.plivo.helper.exception.PlivoException;

public class App {
    public static void main(String[] args) throws IllegalAccessException {
        String auth_id = "Your AUTH_ID";
        String auth_token = "Your AUTH_TOKEN";
        RestAPI api = new RestAPI(auth_id, auth_token, "v1");

        // Modify an application
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        // ID of the application to be deleted
        params.put("app_id","16631550192125875");

        try {
            GenericResponse resp = api.deleteApplication(params);
            System.out.println(getFields(resp));
        } catch (PlivoException e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;

namespace apps
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");

            // Delete an application
            IRestResponse<GenericResponse> res3 = plivo.delete_application(new Dictionary<string,string>()
            {
              {"app_id","16631550192125875"}  // ID of the application to be deleted
            });

            // Prints the response
            Console.Write(res3.Content);
        }
    }
}
1
2
curl -X DELETE -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Application/{app_id}/

Sample Response

Sample successful output    
(204, '')

Sample unsuccessful output
(404, {
       u'api_id': u'5fbdd916-8f64-11e4-b153-22000abcaa64', 
       u'error': u'not found'
   }
)

Next Step

Learn how to manage Plivo Endpoints.

  1. Account API
  2. Application API
  3. Endpoint API
  4. Number API
  5. Phone Number API
  6. Pricing API
  7. API Pagination