Sub Accounts
The sub-accounts feature enables an organization to create child accounts within the organization's master account. For example, an organization might want to create child accounts on the basis of its departments, geographical locations, or lines of business. Accounts can be created on three levels (parent > child > grandchild), enabling an organization to manage many account types under its master account.
Manage Sub Accounts
Create new sub account
To create a new sub account, you can use the following example code.
POST /api/account/subaccounts
{
"parentAccountId": "AbCdEf123456",
"name": "New Department",
"timezoneId": "Europe/Amsterdam",
"language": "en"
}
SubAccount subAccount = SubAccountBuilder.newSubAccount("New Department")
.withParentAccountId("AbCdEf123456")
.withLanguage("en")
.withTimezoneId("Europe/Amsterdam")
.build();
//Creates subAccount
Account account = eslClient.getAccountService().createSubAccount(subAccount);
SubAccount subAccount = SubAccountBuilder.NewSubAccount()
.WithName("New Department")
.WithParentAccountId("AbCdEf123456")
.WithLanguage("en")
.WithTimezoneId("Europe/Amsterdam")
.Build();
//Creates subAccount
Account account = ossClient.AccountService.createSubAccount(subAccount);
Update a Sub Account
To update an existing Sub Account, you can use the following example code.
PUT /api/account/subaccounts/{accountId}
{
"parentAccountId": "123456AbCdEf",
"name": "Updated Department",
"timezoneId": "CET",
"language": "en"
}
SubAccount updateSubAccount = SubAccountBuilder.newSubAccount()
.withName("Updated Department")
.withParentAccountId("123456AbCdEf")
.withLanguage("en")
.withTimezoneId("CET")
.build();
//Updates subAccount
eslClient.getAccountService().updateSubAccount(updateSubAccount, account.getId());
SubAccount updateSubAccount = SubAccountBuilder.NewSubAccount()
.WithName("Updated Department")
.WithParentAccountId("123456AbCdEf")
.WithLanguage("en")
.WithTimezoneId("CET")
.Build();
//Updates subAccount
ossClient.AccountService.updateSubAccount(updateSubAccount, account.Id);
Retrieves a list of Sub Accounts
To retrieve a list of Sub Accounts what are created based on the current account, you can use the following example code.
GET /api/account/subaccounts
subAccounts = eslClient.getAccountService().getSubAccounts();
subAccounts = ossClient.AccountService.getSubAccounts();
Retrieves a list of Accessible Accounts
To retrieve a list of Accounts what the current user is attached to, you can use the following example code.
GET /api/account/accessibleaccounts
accessibleAccounts = eslClient.getAccountService().getAccessibleAccounts();
accessibleAccounts = ossClient.AccountService.getAccessibleAccounts();
List Sub Accounts API Keys
To retrieves a list of API keys for this current user in the subaccounts, you can use the following example code.
GET /api/account/subaccountApiKeys
subAccountApiKeys = eslClient.getAccountService().getSubAccountApiKeys();
subAccountApiKeys = eslClient.getAccountService().getSubAccountApiKeys();