Latest Legacy

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.

Response

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

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)
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
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);
    });
})();
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);
}
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();
        }
    }
}
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);
            }
        }
    }
}
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}/
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)
}