Delete a Subaccount

Permanently delete a Subaccount. This also 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.

cascade is set to false by default when not specified.

Response

HTTP Status Code: 204

Example Request

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

client = plivo.RestClient()
response = client.subaccounts.delete(
    auth_id='SAXXXXXXXXXXXXXXXXXX',
    cascade=True )
print(response)

# Or, you could delete the subaccount directly using the subaccount object
subaccount = client.subaccounts.get(
    auth_id='SAXXXXXXXXXXXXXXXXXX', )
response = subaccount.delete(cascade=True)
print(response)
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("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")

begin
  response = api.subaccounts.delete(
    'SAXXXXXXXXXXXXXXXXXX’,
     true
  )
  puts response
rescue PlivoRESTError => e
  puts 'Exception: ' + e.message
End
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';

    // As the auth_id and auth_token are unspecified, Plivo will fetch them from the PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN environment variables.
    var client = new plivo.Client();
    client.subaccounts.delete(
        "SAXXXXXXXXXXXXXXXXXX", // subauth id
         true  //cascade=true/false
    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();
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("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");

try {
    $response = $client->subaccounts->delete(
        'SAXXXXXXXXXXXXXXXXXX',
         true
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r(ex);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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();
        try {
            Subaccount.deleter("SAXXXXXXXXXXXXXXXXXX").cascade(true)
                .delete();

            System.out.println("Deleted successfully.");
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
            try
            {
                var response = api.Subaccount.Delete(
                    id:"SAXXXXXXXXXXXXXXXXXX",
                    cascade: true
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}
1
2
curl -X DELETE --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Subaccount/{subauth_id}/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Example for Subaccount delete
package main

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

func main() {
	client, err := plivo.NewClient("", "", &plivo.ClientOptions{})
	if err != nil {
		panic(err)
	}
	err = client.Subaccounts.Delete(
		"SAXXXXXXXXXXXXXXXXXX",
                       plivo.SubaccountDeleteParams{Cascade:true},
	)
	if err != nil {
		panic(err)
	}
	fmt.Println("Deleted successfully.")
}