# Update account hierarchy access settings for a customer

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

When the customer is part of an [account hierarchy](https://www.chargebee.com/docs/account-hierarchy.html), this operation updates the access privileges that both the customer and its parent have to the customer's data.

**Terminology** The term "parent" usually refers to the customer with the ID `[payment_owner_id](/docs/api/customers/customer-object#relationship_payment_owner_id)`. However, if the `payment_owner_id` is the same as the child's ID (given by the path parameter), the "parent" is identified by `[parent_id](/docs/api/customers/customer-object#relationship_parent_id)`.

**Tip** You cannot use this endpoint to change the `parent_id`, `invoice_owner_id` or `payment_owner_id` for the customer. To change them, [unlink the customer](/docs/api/customers/delink-a-customer) and then call [Link a customer](/docs/api/customers/link-a-customer) with the updated values.

## Sample Request

### Deletes any custom parent/child access settings defined and applies the site defaults

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWlG3y2dt/update_hierarchy_settings \
     -u {site_api_key}:\
     -d use_default_hierarchy_settings="true"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Customer.UpdateHierarchySettings("__test__KyVnHhSBWlG3y2dt")
		.UseDefaultHierarchySettings(true)
		.Request();

Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    customerAction "github.com/chargebee/chargebee-go/v3/actions/customer"
    "github.com/chargebee/chargebee-go/v3/models/customer"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := customerAction.UpdateHierarchySettings("__test__KyVnHhSBWlG3y2dt", &customer.UpdateHierarchySettingsRequestParams{
        UseDefaultHierarchySettings : chargebee.Bool(true),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.CustomerUpdateHierarchySettingsRequest{
    UseDefaultHierarchySettings : chargebee.Bool(true),
}
  res, err := client.Customer.UpdateHierarchySettings("__test__KyVnHhSBWlG3y2dt", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Customer.updateHierarchySettings("__test__KyVnHhSBWlG3y2dt")
            .useDefaultHierarchySettings(true)
            .request();

        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.customer.params.CustomerUpdateHierarchySettingsParams;
import com.chargebee.v4.models.customer.responses.CustomerUpdateHierarchySettingsResponse;

public class CustomerUpdateHierarchySettings {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        CustomerUpdateHierarchySettingsParams params = CustomerUpdateHierarchySettingsParams.builder()
            .useDefaultHierarchySettings(true)
            .build();

        CustomerUpdateHierarchySettingsResponse response = client
            .customers()
            .updateHierarchySettings("__test__KyVnHhSBWlG3y2dt", params);

        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.customer.updateHierarchySettings("__test__KyVnHhSBWlG3y2dt", {
        use_default_hierarchy_settings: true
    });

    console.log(result);
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->customer()->updateHierarchySettings("__test__KyVnHhSBWlG3y2dt", [
    "use_default_hierarchy_settings" => true
]);
$customer = $result->customer;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Customer.update_hierarchy_settings("__test__KyVnHhSBWlG3y2dt",
    cb_client.Customer.UpdateHierarchySettingsParams(
        use_default_hierarchy_settings=True
    )
)
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Customer.update_hierarchy_settings("__test__KyVnHhSBWlG3y2dt",{
  :use_default_hierarchy_settings => "true"
})

customer = result.customer
```

### Updates all of the "parent_account_access" and "child_account_access" settings for a customer.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWlGoZ2e7/update_hierarchy_settings \
     -u {site_api_key}:\
     -d use_default_hierarchy_settings="false" \
     -d "child_account_access[portal_edit_subscriptions]"="YES" \
     -d "child_account_access[portal_download_invoices]"="YES" \
     -d "child_account_access[send_subscription_emails]"="true" \
     -d "child_account_access[send_payment_emails]"="true" \
     -d "child_account_access[send_invoice_emails]"="true" \
     -d "parent_account_access[portal_edit_child_subscriptions]"="VIEW_ONLY" \
     -d "parent_account_access[portal_download_child_invoices]"="YES" \
     -d "parent_account_access[send_subscription_emails]"="false" \
     -d "parent_account_access[send_payment_emails]"="false" \
     -d "parent_account_access[send_invoice_emails]"="false"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Customer.UpdateHierarchySettings("__test__KyVnHhSBWlGoZ2e7")
		.UseDefaultHierarchySettings(false)
		.ChildAccountAccessPortalEditSubscriptions(Customer.CustomerChildAccountAccess.PortalEditSubscriptionsEnum.Yes)
		.ChildAccountAccessPortalDownloadInvoices(Customer.CustomerChildAccountAccess.PortalDownloadInvoicesEnum.Yes)
		.ChildAccountAccessSendSubscriptionEmails(true)
		.ChildAccountAccessSendPaymentEmails(true)
		.ChildAccountAccessSendInvoiceEmails(true)
		.ParentAccountAccessPortalEditChildSubscriptions(Customer.CustomerParentAccountAccess.PortalEditChildSubscriptionsEnum.ViewOnly)
		.ParentAccountAccessPortalDownloadChildInvoices(Customer.CustomerParentAccountAccess.PortalDownloadChildInvoicesEnum.Yes)
		.ParentAccountAccessSendSubscriptionEmails(false)
		.ParentAccountAccessSendPaymentEmails(false)
		.ParentAccountAccessSendInvoiceEmails(false)
		.Request();

Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    customerAction "github.com/chargebee/chargebee-go/v3/actions/customer"
    "github.com/chargebee/chargebee-go/v3/models/customer"
    customerEnum "github.com/chargebee/chargebee-go/v3/models/customer/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := customerAction.UpdateHierarchySettings("__test__KyVnHhSBWlGoZ2e7", &customer.UpdateHierarchySettingsRequestParams{
        UseDefaultHierarchySettings : chargebee.Bool(false),
        ChildAccountAccess : &customer.UpdateHierarchySettingsChildAccountAccessParams{
            PortalEditSubscriptions : customerEnum.ChildAccountAccessPortalEditSubscriptionsYes,
            PortalDownloadInvoices : customerEnum.ChildAccountAccessPortalDownloadInvoicesYes,
            SendSubscriptionEmails : chargebee.Bool(true),
            SendPaymentEmails : chargebee.Bool(true),
            SendInvoiceEmails : chargebee.Bool(true),
        },
        ParentAccountAccess : &customer.UpdateHierarchySettingsParentAccountAccessParams{
            PortalEditChildSubscriptions : customerEnum.ParentAccountAccessPortalEditChildSubscriptionsViewOnly,
            PortalDownloadChildInvoices : customerEnum.ParentAccountAccessPortalDownloadChildInvoicesYes,
            SendSubscriptionEmails : chargebee.Bool(false),
            SendPaymentEmails : chargebee.Bool(false),
            SendInvoiceEmails : chargebee.Bool(false),
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.CustomerUpdateHierarchySettingsRequest{
    UseDefaultHierarchySettings : chargebee.Bool(false),
    ChildAccountAccess : &chargebee.CustomerUpdateHierarchySettingsChildAccountAccess{
        PortalEditSubscriptions : chargebee.CustomerChildAccountAccessPortalEditSubscriptionsYes,
        PortalDownloadInvoices : chargebee.CustomerChildAccountAccessPortalDownloadInvoicesYes,
        SendSubscriptionEmails : chargebee.Bool(true),
        SendPaymentEmails : chargebee.Bool(true),
        SendInvoiceEmails : chargebee.Bool(true),
    },
    ParentAccountAccess : &chargebee.CustomerUpdateHierarchySettingsParentAccountAccess{
        PortalEditChildSubscriptions : chargebee.CustomerParentAccountAccessPortalEditChildSubscriptionsViewOnly,
        PortalDownloadChildInvoices : chargebee.CustomerParentAccountAccessPortalDownloadChildInvoicesYes,
        SendSubscriptionEmails : chargebee.Bool(false),
        SendPaymentEmails : chargebee.Bool(false),
        SendInvoiceEmails : chargebee.Bool(false),
    },
}
  res, err := client.Customer.UpdateHierarchySettings("__test__KyVnHhSBWlGoZ2e7", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Customer.updateHierarchySettings("__test__KyVnHhSBWlGoZ2e7")
            .useDefaultHierarchySettings(false)
            .childAccountAccessPortalEditSubscriptions(Customer.ChildAccountAccess.PortalEditSubscriptions.YES)
            .childAccountAccessPortalDownloadInvoices(Customer.ChildAccountAccess.PortalDownloadInvoices.YES)
            .childAccountAccessSendSubscriptionEmails(true)
            .childAccountAccessSendPaymentEmails(true)
            .childAccountAccessSendInvoiceEmails(true)
            .parentAccountAccessPortalEditChildSubscriptions(Customer.ParentAccountAccess.PortalEditChildSubscriptions.VIEW_ONLY)
            .parentAccountAccessPortalDownloadChildInvoices(Customer.ParentAccountAccess.PortalDownloadChildInvoices.YES)
            .parentAccountAccessSendSubscriptionEmails(false)
            .parentAccountAccessSendPaymentEmails(false)
            .parentAccountAccessSendInvoiceEmails(false)
            .request();

        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.customer.params.CustomerUpdateHierarchySettingsParams;
import com.chargebee.v4.models.customer.responses.CustomerUpdateHierarchySettingsResponse;

public class CustomerUpdateHierarchySettings {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        CustomerUpdateHierarchySettingsParams.ChildAccountAccessParams childAccountAccessParams =
            CustomerUpdateHierarchySettingsParams.ChildAccountAccessParams.builder()
                .portalEditSubscriptions(CustomerUpdateHierarchySettingsParams.ChildAccountAccessParams.PortalEditSubscriptions.YES)
                .portalDownloadInvoices(CustomerUpdateHierarchySettingsParams.ChildAccountAccessParams.PortalDownloadInvoices.YES)
                .sendSubscriptionEmails(true)
                .sendPaymentEmails(true)
                .sendInvoiceEmails(true)
                .build();

        CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams parentAccountAccessParams =
            CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams.builder()
                .portalEditChildSubscriptions(CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams.PortalEditChildSubscriptions.VIEW_ONLY)
                .portalDownloadChildInvoices(CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams.PortalDownloadChildInvoices.YES)
                .sendSubscriptionEmails(false)
                .sendPaymentEmails(false)
                .sendInvoiceEmails(false)
                .build();

        CustomerUpdateHierarchySettingsParams params = CustomerUpdateHierarchySettingsParams.builder()
            .useDefaultHierarchySettings(false)
            .childAccountAccess(childAccountAccessParams)
            .parentAccountAccess(parentAccountAccessParams)
            .build();

        CustomerUpdateHierarchySettingsResponse response = client
            .customers()
            .updateHierarchySettings("__test__KyVnHhSBWlGoZ2e7", params);

        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.customer.updateHierarchySettings("__test__KyVnHhSBWlGoZ2e7", {
        use_default_hierarchy_settings: false,
        child_account_access: {
            portal_edit_subscriptions: "yes",
            portal_download_invoices: "yes",
            send_subscription_emails: true,
            send_payment_emails: true,
            send_invoice_emails: true
        },
        parent_account_access: {
            portal_edit_child_subscriptions: "view_only",
            portal_download_child_invoices: "yes",
            send_subscription_emails: false,
            send_payment_emails: false,
            send_invoice_emails: false
        }
    });

    console.log(result);
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->customer()->updateHierarchySettings("__test__KyVnHhSBWlGoZ2e7", [
    "use_default_hierarchy_settings" => false,
    "child_account_access" => [
        "portal_edit_subscriptions" => "yes",
        "portal_download_invoices" => "yes",
        "send_subscription_emails" => true,
        "send_payment_emails" => true,
        "send_invoice_emails" => true
    ],
    "parent_account_access" => [
        "portal_edit_child_subscriptions" => "view_only",
        "portal_download_child_invoices" => "yes",
        "send_subscription_emails" => false,
        "send_payment_emails" => false,
        "send_invoice_emails" => false
    ]
]);
$customer = $result->customer;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Customer.update_hierarchy_settings("__test__KyVnHhSBWlGoZ2e7",
    cb_client.Customer.UpdateHierarchySettingsParams(
        use_default_hierarchy_settings=False,
        child_account_access=cb_client.Customer.UpdateHierarchySettingsChildAccountAccessParams(
            portal_edit_subscriptions=chargebee.Customer.ChildAccountAccessPortalEditSubscriptions.YES,
            portal_download_invoices=chargebee.Customer.ChildAccountAccessPortalDownloadInvoices.YES,
            send_subscription_emails=True,
            send_payment_emails=True,
            send_invoice_emails=True
        ),
        parent_account_access=cb_client.Customer.UpdateHierarchySettingsParentAccountAccessParams(
            portal_edit_child_subscriptions=chargebee.Customer.ParentAccountAccessPortalEditChildSubscriptions.VIEW_ONLY,
            portal_download_child_invoices=chargebee.Customer.ParentAccountAccessPortalDownloadChildInvoices.YES,
            send_subscription_emails=False,
            send_payment_emails=False,
            send_invoice_emails=False
        )
    )
)
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Customer.update_hierarchy_settings("__test__KyVnHhSBWlGoZ2e7",{
  :use_default_hierarchy_settings => "false",
  :child_account_access => {
    :portal_edit_subscriptions => "YES",
    :portal_download_invoices => "YES",
    :send_subscription_emails => "true",
    :send_payment_emails => "true",
    :send_invoice_emails => "true"
  },
  :parent_account_access => {
    :portal_edit_child_subscriptions => "VIEW_ONLY",
    :portal_download_child_invoices => "YES",
    :send_subscription_emails => "false",
    :send_payment_emails => "false",
    :send_invoice_emails => "false"
  }
})

customer = result.customer
```

### Updates only some of the "parent_account_access" and "child_account_access" settings for a customer

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/customers/__test__KyVnHhSBWlGQc2e0/update_hierarchy_settings \
     -u {site_api_key}:\
     -d use_default_hierarchy_settings="false" \
     -d "parent_account_access[portal_edit_child_subscriptions]"="YES" \
     -d "parent_account_access[portal_download_child_invoices]"="YES" \
     -d "parent_account_access[send_invoice_emails]"="false" \
     -d "child_account_access[portal_download_invoices]"="YES" \
     -d "child_account_access[send_invoice_emails]"="true"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Customer.UpdateHierarchySettings("__test__KyVnHhSBWlGQc2e0")
		.UseDefaultHierarchySettings(false)
		.ParentAccountAccessPortalEditChildSubscriptions(Customer.CustomerParentAccountAccess.PortalEditChildSubscriptionsEnum.Yes)
		.ParentAccountAccessPortalDownloadChildInvoices(Customer.CustomerParentAccountAccess.PortalDownloadChildInvoicesEnum.Yes)
		.ParentAccountAccessSendInvoiceEmails(false)
		.ChildAccountAccessPortalDownloadInvoices(Customer.CustomerChildAccountAccess.PortalDownloadInvoicesEnum.Yes)
		.ChildAccountAccessSendInvoiceEmails(true)
		.Request();

Customer customer = result.Customer;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    customerAction "github.com/chargebee/chargebee-go/v3/actions/customer"
    "github.com/chargebee/chargebee-go/v3/models/customer"
    customerEnum "github.com/chargebee/chargebee-go/v3/models/customer/enum"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := customerAction.UpdateHierarchySettings("__test__KyVnHhSBWlGQc2e0", &customer.UpdateHierarchySettingsRequestParams{
        UseDefaultHierarchySettings : chargebee.Bool(false),
        ParentAccountAccess : &customer.UpdateHierarchySettingsParentAccountAccessParams{
            PortalEditChildSubscriptions : customerEnum.ParentAccountAccessPortalEditChildSubscriptionsYes,
            PortalDownloadChildInvoices : customerEnum.ParentAccountAccessPortalDownloadChildInvoicesYes,
            SendInvoiceEmails : chargebee.Bool(false),
        },
        ChildAccountAccess : &customer.UpdateHierarchySettingsChildAccountAccessParams{
            PortalDownloadInvoices : customerEnum.ChildAccountAccessPortalDownloadInvoicesYes,
            SendInvoiceEmails : chargebee.Bool(true),
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.CustomerUpdateHierarchySettingsRequest{
    UseDefaultHierarchySettings : chargebee.Bool(false),
    ParentAccountAccess : &chargebee.CustomerUpdateHierarchySettingsParentAccountAccess{
        PortalEditChildSubscriptions : chargebee.CustomerParentAccountAccessPortalEditChildSubscriptionsYes,
        PortalDownloadChildInvoices : chargebee.CustomerParentAccountAccessPortalDownloadChildInvoicesYes,
        SendInvoiceEmails : chargebee.Bool(false),
    },
    ChildAccountAccess : &chargebee.CustomerUpdateHierarchySettingsChildAccountAccess{
        PortalDownloadInvoices : chargebee.CustomerChildAccountAccessPortalDownloadInvoicesYes,
        SendInvoiceEmails : chargebee.Bool(true),
    },
}
  res, err := client.Customer.UpdateHierarchySettings("__test__KyVnHhSBWlGQc2e0", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Customer := res.Customer
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Customer.updateHierarchySettings("__test__KyVnHhSBWlGQc2e0")
            .useDefaultHierarchySettings(false)
            .parentAccountAccessPortalEditChildSubscriptions(Customer.ParentAccountAccess.PortalEditChildSubscriptions.YES)
            .parentAccountAccessPortalDownloadChildInvoices(Customer.ParentAccountAccess.PortalDownloadChildInvoices.YES)
            .parentAccountAccessSendInvoiceEmails(false)
            .childAccountAccessPortalDownloadInvoices(Customer.ChildAccountAccess.PortalDownloadInvoices.YES)
            .childAccountAccessSendInvoiceEmails(true)
            .request();

        Customer customer = result.customer();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.customer.Customer;
import com.chargebee.v4.models.customer.params.CustomerUpdateHierarchySettingsParams;
import com.chargebee.v4.models.customer.responses.CustomerUpdateHierarchySettingsResponse;

public class CustomerUpdateHierarchySettings {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams parentAccountAccessParams =
            CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams.builder()
                .portalEditChildSubscriptions(CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams.PortalEditChildSubscriptions.YES)
                .portalDownloadChildInvoices(CustomerUpdateHierarchySettingsParams.ParentAccountAccessParams.PortalDownloadChildInvoices.YES)
                .sendInvoiceEmails(false)
                .build();

        CustomerUpdateHierarchySettingsParams.ChildAccountAccessParams childAccountAccessParams =
            CustomerUpdateHierarchySettingsParams.ChildAccountAccessParams.builder()
                .portalDownloadInvoices(CustomerUpdateHierarchySettingsParams.ChildAccountAccessParams.PortalDownloadInvoices.YES)
                .sendInvoiceEmails(true)
                .build();

        CustomerUpdateHierarchySettingsParams params = CustomerUpdateHierarchySettingsParams.builder()
            .useDefaultHierarchySettings(false)
            .parentAccountAccess(parentAccountAccessParams)
            .childAccountAccess(childAccountAccessParams)
            .build();

        CustomerUpdateHierarchySettingsResponse response = client
            .customers()
            .updateHierarchySettings("__test__KyVnHhSBWlGQc2e0", params);

        Customer customer = response.getCustomer();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.customer.updateHierarchySettings("__test__KyVnHhSBWlGQc2e0", {
        use_default_hierarchy_settings: false,
        parent_account_access: {
            portal_edit_child_subscriptions: "yes",
            portal_download_child_invoices: "yes",
            send_invoice_emails: false
        },
        child_account_access: {
            portal_download_invoices: "yes",
            send_invoice_emails: true
        }
    });

    console.log(result);
    const customer = result.customer;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->customer()->updateHierarchySettings("__test__KyVnHhSBWlGQc2e0", [
    "use_default_hierarchy_settings" => false,
    "parent_account_access" => [
        "portal_edit_child_subscriptions" => "yes",
        "portal_download_child_invoices" => "yes",
        "send_invoice_emails" => false
    ],
    "child_account_access" => [
        "portal_download_invoices" => "yes",
        "send_invoice_emails" => true
    ]
]);
$customer = $result->customer;
```

#### Python

```python
import chargebee
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Customer.update_hierarchy_settings("__test__KyVnHhSBWlGQc2e0",
    cb_client.Customer.UpdateHierarchySettingsParams(
        use_default_hierarchy_settings=False,
        parent_account_access=cb_client.Customer.UpdateHierarchySettingsParentAccountAccessParams(
            portal_edit_child_subscriptions=chargebee.Customer.ParentAccountAccessPortalEditChildSubscriptions.YES,
            portal_download_child_invoices=chargebee.Customer.ParentAccountAccessPortalDownloadChildInvoices.YES,
            send_invoice_emails=False
        ),
        child_account_access=cb_client.Customer.UpdateHierarchySettingsChildAccountAccessParams(
            portal_download_invoices=chargebee.Customer.ChildAccountAccessPortalDownloadInvoices.YES,
            send_invoice_emails=True
        )
    )
)
customer = response.customer
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Customer.update_hierarchy_settings("__test__KyVnHhSBWlGQc2e0",{
  :use_default_hierarchy_settings => "false",
  :parent_account_access => {
    :portal_edit_child_subscriptions => "YES",
    :portal_download_child_invoices => "YES",
    :send_invoice_emails => "false"
  },
  :child_account_access => {
    :portal_download_invoices => "YES",
    :send_invoice_emails => "true"
  }
})

customer = result.customer
```

## Sample Response

```json
{
  "customer": {
    "id": "__test__KyVnHhSBWlG3y2dt",
    "relationship": {
      "invoice_owner_id": "__test__KyVnHhSBWlG3y2dt",
      "parent_id": "__test__KyVnHhSBWlG5Z2dv",
      "payment_owner_id": "__test__KyVnHhSBWlG3y2dt",
      "root_id": "__test__KyVnHhSBWlG5Z2dv"
    },
    "use_default_hierarchy_settings": true,
    "parent_account_access": {
      "portal_download_child_invoices": "yes",
      "portal_edit_child_subscriptions": "view_only",
      "send_invoice_emails": true,
      "send_payment_emails": true,
      "send_subscription_emails": false
    },
    "child_account_access": {
      "portal_download_invoices": "view_only",
      "portal_edit_subscriptions": "yes",
      "send_invoice_emails": true,
      "send_payment_emails": true,
      "send_subscription_emails": true
    },
    "allow_direct_debit": false,
    "auto_collection": "on",
    "card_status": "no_card",
    "created_at": 1517505763,
    "deleted": false,
    "excess_payments": 0,
    "first_name": "Bella",
    "last_name": "Brown",
    "net_term_days": 0,
    "object": "customer",
    "pii_cleared": "active",
    "preferred_currency_code": "USD",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "resource_version": 1517505763000,
    "taxability": "taxable",
    "unbilled_charges": 0,
    "updated_at": 1517505763
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/customers/{customer-id}/update_hierarchy_settings

## Input Parameters

- `use_default_hierarchy_settings` (optional, boolean, default=true)
  Decides if Chargebee should apply settings from the [Chargebee Billing UI](https://www.chargebee.com/docs/1.0/account-hierarchy.html#advanced-mode) or from this API request.
  
  -   If set to `true`: Chargebee removes existing settings stored in the `parent_account_access` and `child_account_access` attributes of the customer. The settings configured in the Chargebee Billing UI apply for the customer.
  -   If set to `false`: Chargebee replaces existing settings stored in the `parent_account_access` and `child_account_access` parameters with those passed in this API call. If any of those parameters are not passed, they remain unchanged for the customer.

- `parent_account_access` (optional, enumerated string)
  Parameters for parent\_account\_access
  - `portal_edit_child_subscriptions` (optional, enumerated string)
    Sets parent's level of access to child subscriptions on the Self-Serve Portal.
    Possible enum values:
      - `yes`
        The parent account can view and edit the subscriptions of the child account.
      - `view_only`
        The parent account can only view the subscriptions of the child account.
      - `no`
        The parent account cannot view or edit the subscriptions of the child account.
  - `portal_download_child_invoices` (optional, enumerated string)
    Sets parent's level of access to child invoices on the Self-Serve Portal.
    Possible enum values:
      - `yes`
        The parent account can view and download the invoices of the child account.
      - `view_only`
        The parent account can only view the invoices of the child account.
      - `no`
        The parent account can neither view nor download the invoices of the child account.
  - `send_subscription_emails` (optional, boolean)
    If `true` , the parent account will receive subscription-related emails sent to the child account.
  - `send_payment_emails` (optional, boolean)
    If `true` , the parent account will receive payment-related emails sent to the child account.
  - `send_invoice_emails` (optional, boolean)
    If `true` , the parent account will receive invoice-related emails sent to the child account.

- `child_account_access` (optional, enumerated string)
  When the customer is part of an [account hierarchy](https://www.chargebee.com/docs/account-hierarchy.html) , this attribute defines the level of access that the customer has to its own information.
  - `portal_edit_subscriptions` (optional, enumerated string)
    Determines the child's access to its own subscriptions in the Self-Serve Portal.
    Possible enum values:
      - `yes`
        The child account can view and edit its subscriptions.
      - `view_only`
        The child account can only view its subscriptions.
  - `portal_download_invoices` (optional, enumerated string)
    Determines the child's access to its own invoices in the Self-Serve Portal.
    Possible enum values:
      - `yes`
        The child account can both view and download its invoices.
      - `view_only`
        The child account can view but not download its invoices.
      - `no`
        The child account cannot view or download its own invoices.
  - `send_subscription_emails` (optional, boolean)
    If `true` , the child account receives email notifications for its subscriptions.
  - `send_payment_emails` (optional, boolean)
    If `true` , the child account receives email notifications for payment-related activities for its invoices.
  - `send_invoice_emails` (optional, boolean)
    If `true` , the child account receives email notifications for its invoices.

## Returns

- `customer` (Customer object)
  Resource object representing customer
