We can use the add ledger account to category endpoint to add an account to a category. For this, we simply need the ids of both the parent category and the ledger account we will be nesting under it.
curl --request PUT \
--url https://app.moderntreasury.com/api/ledger_account_categories/f1c7e474-e6d5-4741-9f76-04510c8b6d7a/ledger_accounts/7244f59-cfd8-8dfa-9466-7de9f42b0b1a9 \
--header 'Accept: application/json'
After we add an account to a category, it can be removed by using the remove ledger account from category endpoint. This does not affect the underlying transactions, which are immutable, or the underlying account: it simply removes the newly excluded account balance from the category balance calculation.
Finally, to add several accounts to a category, we can use the list ledger transactions endpoint to query transactions by metadata and programmatically add them into a category using the same API call above repeatedly.
Updated 3 months ago