List all Subaccounts

    Returns a list of subaccounts. The subaccounts are returned 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

    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. Read more about offset based pagination here.

    Returns

    An array of Subaccount objects.

    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/MAXXXXXXXXXXXXXXXXXX/",
          "auth_id": "SAXXXXXXXXXXXXXXXXXX",
          "auth_token": "MTZjYWM0YzVjNjMwZmVmODFiNWJjNWJmOGJjZjgw",
          "created": "2014-07-17",
          "enabled": false,
          "modified": null,
          "name": "Chewbacca",
          "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Subaccount/SAXXXXXXXXXXXXXXXXXX/"
        },
        {
          "account": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/",
          "auth_id": "SAXXXXXXXXXXXXXXXXXX",
          "auth_token": "OTdhMjYwMWYxOGMyNpFjNzUwYWM3YWI3NjY4Y2Ey",
          "created": "2012-09-23",
          "enabled": true,
          "modified": "2012-09-23",
          "name": "new",
          "resource_uri": "/v1/Account/MAXXXXXXXXXXXXXXXXXX/Subaccount/SAXXXXXXXXXXXXXXXXXX/"
        }
      ]
    }
    

    Example Request

    1
    2
    3
    4
    5
    6
    7
    
    import plivo
    
    client = plivo.RestClient()
    response = client.subaccounts.list(
        offset=0,
        limit=5, )
    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 List
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")
    
    begin
      response = api.subaccounts.list(
        limit: 5,
        offset: 0,
      )
      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
    19
    20
    
    // Example for Subaccount list
    
    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.list(
            {
                offset: 0,
                limit: 5,
            },
        ).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 list
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
    
    try {
        $response = $client->subaccounts->list(
            3,
            2
        );
        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
    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();
            try {
                ListResponse<Subaccount> response = Subaccount.lister()
                    .offset(0)
                    .limit(5)
                    .list();
    
                System.out.println(response);
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    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("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
                try
                {
                    var response = api.Subaccount.List(
                        limit:5,
                        offset:0
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    
    1
    2
    
    curl -i --user AUTH_ID:AUTH_TOKEN \
        https://api.plivo.com/v1/Account/{auth_id}/Subaccount/
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    // Example for Subaccount list
    package main
    
    import "fmt"
    import "github.com/plivo/plivo-go"
     
    func main() {
    	client, err := plivo.NewClient("", "", &plivo.ClientOptions{})
    	if err != nil {
    		panic(err)
    	}
    	response, err := client.Subaccounts.List(
    		plivo.SubaccountListParams{
    			Offset: 0,
    			Limit: 5,
    		},
    	)
    	if err != nil {
    		panic(err)
    	}
    	fmt.Printf("Response: %#v\n", response)
    }