Account sets
Named groups of accounts (or other sets) with one aggregated balance.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /account-sets | List all account sets |
| POST | /account-sets | Create a new account set |
| GET | /account-sets/{accountSetId} | Get a specific account set |
| PUT | /account-sets/{accountSetId} | Update an account set |
| DELETE | /account-sets/{accountSetId} | Delete an account set |
| POST | /account-sets/{accountSetId}/members | Add an account or nested set to this account set |
| DELETE | /account-sets/{accountSetId}/members | Remove an account or nested set from this account set |
| GET | /account-sets/{accountSetId}/balance | Get aggregated balance for all accounts in this set |
| GET | /account-sets/{accountSetId}/accounts | Get all accounts in this set (recursively includes nested sets) |
Create a set and add members
curl -X POST https://ledga.io/api/v1/account-sets \
-H "Authorization: Bearer sk_xxxxxxxx_your_secret" \
-H "Content-Type: application/json" \
-d '{ "code": "OPERATING_EXPENSES", "name": "Operating expenses" }'
curl -X POST https://ledga.io/api/v1/account-sets/{accountSetId}/members \
-H "Authorization: Bearer sk_xxxxxxxx_your_secret" \
-H "Content-Type: application/json" \
-d '{ "member_type": "account", "member_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a" }'use Ledga\Api\Enums\AccountSetMemberType;
$set = $ledga->accountSets->create(['code' => 'OPERATING_EXPENSES', 'name' => 'Operating expenses']);
$ledga->accountSets->addMember($set->id, AccountSetMemberType::Account, $account->id);Rules
member_typeisaccountoraccount_set; sets nest.GET /account-sets/{id}/balancesums every member, recursively.GET /account-sets/{id}/accountslists the resolved accounts, recursively.DELETE /account-sets/{id}/memberswith the same body removes a member.