> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating Account Hierarchies

Subscribe supports two-level account hierarchies for payment and reporting. You may define parent and children accounts. A parent can have multiple children, but a child may have only one parent, and a child may not be a parent to another account.

A parent can pay for its own AutoBills or one-time transactions, or for any of its children's AutoBills or one-time transactions, by including the parent’s Payment Method on an AutoBill with the child's Account.

Children may have Payment Methods that differ from their Parent's, and can use either to pay for their AutoBills.

When two accounts are linked or unlinked (as parent and child), an email will be sent to both.

Create an Account hierarchy, by adding credit to the parent’s Account and transferring the credit to the child’s Account:

```
 
 // Create a new Account object for parent
 $parent = new Account();
 
 // Provide basic account information
 $parent->setName('Somebody Q. Customer'); // Customer name
 $parent->setMerchantAccountId('IN9430-8421');
 // Unique customer id
 
 // Create a new Account object for child
 $child = new Account();
 $child->setName('Somebody Q. Customer Jr.'); // Customer name
 $child->setMerchantAccountId('IN9430-8421JR'); 
 // Unique customer id
 
 // Establish a parent->child relationship between 
 // $parent and $child
 $childrenAdded = $parent->addChildren($parent, array($child))
 
 //Grant credit to the parent
 $curAmt = new CurrencyAmount ;
 $curAmt->setCurrency('USD');
 $curAmt->setAmount(100.00);
 
 $cr = new Credit();
 $cr->setCurrencyAmounts(array($curAmt));
 
 // Now make the SOAP API call to grant credit to the parent
 $response = $parent->grantCredit($cr);
 if ($response['returnCode'] == 200) {
    // Credit successfully granted to the account
    $updatedAcct = $response->['account'];
 }
 else {
    // Error while granting credit to the account
    print $response['returnString'] . "\n";
 }
 //Define credits to be transferred from parent to child
 $curTranAmt = new CurrencyAmount ;
 $curTranAmt->setCurrency('USD');
 $curTranAmt->setAmount(12.34);
 
 $crTran = new Credit();
 $crTran->setCurrencyAmounts(array($curTranAmt));
 
 //Transfer specified credits from parent to child account
 $response = $parent->transferCredit($child, $crTran);
 if ($response['returnCode'] == 200) {
    // Credit successfully granted to the account
 }
 else {
 // Error while transferring credit between accounts
 print $response['returnString'] . "\n";
```

For more information on methods related to Account hierarchy, see The Account Object in the Subscribe API Guide.

**Parent topic:**[Working with Accounts](../topics/ProgGuide_Accounts)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.