Accounts
The chart of accounts. Every entry posts to one account; balances are read per account or by code.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /accounts | List all accounts in a ledger |
| POST | /accounts | Create a new account |
| GET | /accounts/{accountId} | Get a specific account |
| PUT | /accounts/{accountId} | Update an account |
| DELETE | /accounts/{accountId} | Delete an account |
| GET | /accounts/{accountId}/balance-history | Get account balance history |
| POST | /accounts/initialize-defaults | Initialize default chart of accounts for a ledger |
| GET | /accounts/{accountId}/entries | Get all entries for an account with rolling balance |
| GET | /accounts/code/{code} | Get a specific account by its code |
| GET | /accounts/code/{code}/balance | Get account balance by code with layer details |
| GET | /accounts/{accountId}/balance | Get account balance with layer details |
| GET | /accounts/{accountId}/balance/point-in-time | Get an account point-in-time balance for a single layer |
| GET | /accounts/code/{code}/balance/point-in-time | Get an account point-in-time balance for a single layer, by code |
Create an account
code is unique within the ledger. type sets the normal balance side unless normal_balance overrides it. category is system for internal/GL accounts or customer for end-user balances.
curl -X POST https://ledga.io/api/v1/accounts \
-H "Authorization: Bearer sk_xxxxxxxx_your_secret" \
-H "Content-Type: application/json" \
-d '{ "code": "2100", "name": "Customer wallet", "type": "liability", "category": "customer" }'$account = $ledga->accounts->create([
'code' => '2100',
'name' => 'Customer wallet',
'type' => 'liability',
'category' => 'customer',
]);Rules
- Types:
asset,liability,equity,revenue,expense. Assets and expenses are debit-normal; the rest credit-normal. parent_codenests accounts.GET /accounts?tree=truereturns the hierarchy unpaginated.is_system: trueaccounts cannot be deleted.- Balances:
GET /accounts/{id}/balanceorGET /accounts/code/{code}/balance; add/point-in-time?as_of=…for one layer at a past date. GET /accounts/{id}/entrieslists postings with a running balance;/balance-historygives balances over a date range.