Finance · Accounting
List balance segments
Lists account balances grouped by dimension combination and restriction for an organization and mandate. It accepts optional filters, sorting, pagination and an opening-balances option, and returns a count and balance segments.
Permissions
Send an API key of the organization in the path, using the X-API-Key header.
Who may call it
- The caller must have organization access.
- The caller needs both
mandate.readandposting.readpermissions.
Request
Path parameters
-
organizationIdidrequired -
mandateIdidrequired
Body
Content-Type: application/json
-
rangeobject2 properties
-
fromobjectrequired2 properties
-
yearintegerrequired2000–3000
-
monthIndexintegerrequired1–12
-
-
toobjectrequired2 properties
-
yearintegerrequired2000–3000
-
monthIndexintegerrequired1–12
-
-
-
accountFilterobject5 properties
-
groupsstring[]capitalAssetliquidAssetcashequityCapitaldebtCapitalrevenueexpensestaticstaticDebitstaticCreditdebtorcreditor -
typesstring[]assetliabilityrevenueexpensedebtorcreditormisc -
classesstring[]permanenttemporarypersonmisc -
accounts(integer[] | integer)[] -
accountNamestring
-
-
dimensionsobject[]2 properties
-
dimensionIdidrequired -
optionKeystringrequired1–64 characters
-
-
combinationKeystring -
restrictionstringnullabledonor -
includeOpeningBalancesboolean -
sortobject of stringdefault
{"account":"asc"}ascdescKeys: one of 5 values
accountdebitcreditopeningDebitopeningCredit -
limitinteger0–100 · default
50 -
offsetintegerat least 0 · default
0 -
returnCountbooleandefault
false
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
--request POST 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/finance/accounting/balance-segments/list' \
--header 'X-API-Key: YOUR_API_KEY'const response = await fetch("https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/finance/accounting/balance-segments/list", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY"
},
redirect: 'error',
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`campai HTTP ${response.status}`);
const text = await response.text();
const result = text ? JSON.parse(text) : null;
console.log(JSON.stringify(result, null, 2));<?php
$context = stream_context_create(['http' => [
'method' => 'POST',
'header' => [
'X-API-Key: YOUR_API_KEY',
],
'timeout' => 30,
'follow_location' => 0,
'ignore_errors' => true,
]]);
$text = @file_get_contents('https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/finance/accounting/balance-segments/list', false, $context);
preg_match('/^HTTP\/\S+ (\d{3})/', $http_response_header[0] ?? '', $match);
$status = (int) ($match[1] ?? 0);
if ($text === false || $status < 200 || $status >= 300) {
throw new RuntimeException("campai HTTP $status (0 means no response)");
}
$result = $text === '' ? null : json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR), PHP_EOL;
No request that worked has been recorded yet, so the body is not shown.
Response
200 Successful response
Content-Type: application/json
-
countintegerat least 0
-
accountBalanceSegmentsobject[]15 properties
-
accountinteger1–999999999
-
accountNamestring -
dimensionsobject[]2 properties
-
dimensionIdid -
optionKeystring1–64 characters
-
-
combinationKeystring -
restrictionstringnullabledonor -
debitintegerat most 9999999999
-
creditintegerat most 9999999999
-
openingDebitintegerat most 9999999999
-
openingCreditintegerat most 9999999999
-
balanceinteger0–9999999999
-
balanceTypestringnonedebitcredit -
balanceAmountintegerat most 9999999999
-
openingBalanceinteger0–9999999999
-
openingBalanceTypestringnonedebitcredit -
openingBalanceAmountintegerat most 9999999999
-
{
"count": 0,
"accountBalanceSegments": [
{
"account": 1,
"dimensions": [
{
"dimensionId": "000000000000000000000001",
"optionKey": "string"
}
],
"combinationKey": "string",
"restriction": "donor",
"debit": 1,
"credit": 1,
"balance": 0,
"balanceType": "none",
"balanceAmount": 1
}
]
}
Errors
Other errors
| Status | Error | When |
|---|---|---|
| 404 | Accounting plan is missing. Please make sure you have setup your finances app properly. | If the organization's accounting plan is missing, the endpoint returns HTTP 404 with message key finance.accounting.getAccountingPlan.notFound. |
Errors nearly every request can meet are listed under Errors.