Midaz allows the concept of "child-accounts," enabling parents to create accounts for their children, as shown in Figure 1. In this figure, entity 123 has portfolio 1 which contains accounts 1 (BRL), 2 (USD), and 3 (BTC). Entity 626 is a child of entity 123 and has account 98 (BTC) as a child-account of account 3 (BTC).
Thus, for regulatory purposes and similar considerations, portfolio 1 of entity 123 owns 4 accounts (3 of its own + 1 from entity 626), however, in the client's application flows, entity 626 (the child) will only be able to access their own account (98), as shown on Figure 1.
Implementation
To create the portfolio for the entityId 123, the Create a Portfolio endpoint should be called.
POST /v1/organizations/{{id}}/ledgers/{{id}}/portfolios
Given that in this example the entityId 123 has BRL, USD, and BTC accounts, the POST /accounts endpoint would be called three times.
Once this is done, the account for the child (entityId 626) could be created by calling the same POST /accounts, but with the parentAccountId being the id of the BTC account of the entityId 123 as shown below.
POST /v1/organizations/{{id}}/ledgers/{{id}}/portfolios/{{id}}/accounts