GET
/accounts/code/{code}/balance Get account balance by code with layer details
Get account balance by code with layer details
Parameters
| Name | In | Type | Description |
|---|---|---|---|
coderequired | path | string | Account code (customer-defined identifier) |
as_of_date | query | string date | Count the entries effective by the end of this date (Y-m-d, in the ledger's timezone), past, today or future. Omit it for the current balance: every posting committed by the moment of the request, whatever its effective date. overdue and future split the encumbrances recorded by this date by due date, so an encumbrance due later is in future but not yet in the encumbrance layer. |
layer | query | string enum: settled | pending | encumbrance | Filter by specific layer |
Responses
200Balance retrieved successfully
{
"success": true,
"data": {
"account_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
"account_code": "1000",
"account_name": "Cash",
"account_type": "asset",
"normal_balance": "debit",
"balances": {
"settled": "1000.00",
"pending": "50.00",
"overdue": "20.00",
"future": "80.00"
},
"layer_details": {},
"currency": "GBP",
"as_of_date": "2025-01-15",
"calculated_at": "2026-01-15T10:30:00Z"
}
} 401Unauthenticated
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 403Forbidden
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 404Account not found
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 422A malformed as_of_date or an unknown layer
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} Examples
curl https://ledga.io/api/v1/accounts/code/{code}/balance \
-H "Authorization: Bearer sk_xxxxxxxx_your_secret" use Ledga\Api\LedgaClient;
$ledga = new LedgaClient('sk_xxxxxxxx_your_secret');
$balance = $ledga->accounts->getBalanceByCode('1000');