Recalculate Opening Balance

POST /api/v1/accounts/:id/recalculate-opening-balance

Recomputes opening_balance/opening_balance_date from the earliest statement on file for this account (ordered by period_start), and updates the account with the result. Useful after uploading an earlier statement than the one the account's opening balance was originally derived from.

Path Parameters

ParameterTypeDescription
idstringAccount ID

Example Request

curl -X POST "https://statements.finopsbricks.com/api/v1/accounts/acc123xyz/recalculate-opening-balance" \
  -H "api-key: fob_stm_xxxxxxxxxxxx" \
  -H "api-secret: xxxxxxxxxxxxxxxx"

Response

{
  "data": {
    "id": "acc123xyz",
    "opening_balance": 10000.00,
    "opening_balance_date": "2024-01-01"
  }
}

Errors

CodeDescription
401Invalid or missing API credentials
403API key lacks accounts:edit permission
404Account not found, or no statements on file for this account
400The earliest statement has no opening balance information (NO_OPENING_BALANCE_DATA)