Following are the rules describing relations in the accounts hierarchy:
Each flespi object (channel, device, subaccount etc.) has ONE owner defined by cid parameter (which corresponds to a particular customer_id).
Each account has ONE parent defined by owner_id parameter. Master account’s owner_id=0. Each account (except the fourth level accounts) can have multiple child accounts.
Parent account can MANAGE all its child accounts’ objects.
Child accounts objects can USE parent account objects.
Rule 1 establishes the position of each object relative to the subaccounts hierarchy. It also states that from the parent's point of view subaccount is a flespi object with cid equals to parent's customer_id which is equal to owner_id for subaccount's customer.
Rule 2 defines the tree-like structure of subaccounts which in general case looks like:
Rules 3 and 4 define the rights of accounts going downward and upward through the hierarchy. Note that rules 3 and 4 use “parent-child” notation, which means that account can manage object from its “branch” of hierarchy “tree” only, and child object can use parent’s objects from it’s “chain” of parents up to the master account only.