Browse the extensions reference

Record Opening Balance

post/extensions/roboledger/{graph_id}/operations/record-opening-balance

Part of RoboLedger: Ledger & Events.

Record the balance sheet an entity's books start from, when its history does not come with them: one balance per balance-sheet account (assets, liabilities, equity), in cents, debit or credit in the account's normal direction. It posts as one opening entry dated the day before the entity's first fiscal month, so every month's opening balances include it and no month's activity does: the cash flow and the equity statement start from it rather than counting it. Name the equity account that takes any difference between debits and credits (equity_element_id, usually Opening Balance Equity); unbalanced balances without one are refused, and an income or expense account is refused, since income before the books begin is in retained earnings. One per entity: recording it again replaces it, until the entity's first close, after which a correction is an adjusting entry in an open month. Set up the fiscal calendar first; moving its start (change-calendar-start) moves the opening with it.

Idempotency: supply an Idempotency-Key header to make safe retries; replays within 24 hours return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Authentication

Authenticate in any one of these ways — not all of them:

  • API key in the X-API-Key header.
  • Bearer token in the Authorization header.

Path parameters

NameTypeDescription
graph_idrequiredstringGraph Id

Constraints: matches ^(kg[a-f0-9]{16,}(?:_[a-zA-Z0-9]{1,20})?|sec(?:_[a-zA-Z0-9]{1,20})?|library)$

Header parameters

NameTypeDescription
Idempotency-KeyoptionalstringIdempotency-Key

Request body

Required, application/json.

FieldTypeDescription
entity_idoptionalstring

The entity whose books start here; omit for the group parent.

balancesrequiredOpeningBalanceInput[]

One balance per balance-sheet account (assets, liabilities, equity). An income or expense account is refused: income before the books begin is already in retained earnings.

Constraints: at least 1 item

OpeningBalanceInput fields
FieldTypeDescription
element_idrequiredstring

The balance-sheet account, by id.

debit_amountoptionalinteger

Debit balance in cents.

Default: 0

Constraints: at least 0

credit_amountoptionalinteger

Credit balance in cents.

Default: 0

Constraints: at least 0

equity_element_idoptionalstring

The equity account that takes any difference between debits and credits, usually Opening Balance Equity. Required when the balances do not balance; a non-zero balance left there is a review item.

memooptionalstring

The entry's memo; defaults to 'Opening balances'.

Example request

curl
curl -X POST "https://api.robosystems.ai/extensions/roboledger/{graph_id}/operations/record-opening-balance" \
  -H "X-API-Key: $ROBOSYSTEMS_API_KEY" \
  -H "Idempotency-Key: <Idempotency-Key>" \
  -H "Content-Type: application/json" \
  -d '{
  "balances": [
    {
      "element_id": "string"
    }
  ]
}'

Responses

200 Successful Response

FieldTypeDescription
operationrequiredstring

Kebab-case operation name

operationIdrequiredstring

op_-prefixed ULID for audit and SSE correlation

statusrequiredstring

Operation lifecycle state

One of: completed, pending, failed

resultoptionalJournalEntryResponse

Command-specific result payload

JournalEntryResponse fields
FieldTypeDescription
idrequiredstring
transaction_idoptionalstring
typerequiredstring
statusrequiredstring
posting_daterequiredstring (date)
memooptionalstring
provenanceoptionalstring
reversal_ofoptionalstring
posted_atoptionalstring (date-time)
line_itemsrequiredJournalEntryLineItemResponse[]

One line in a journal entry response.

JournalEntryLineItemResponse fields
FieldTypeDescription
idrequiredstring
element_idrequiredstring
debit_amountrequiredinteger
credit_amountrequiredinteger
descriptionoptionalstring
line_orderrequiredinteger
flow_qnameoptionalstring

The cash flow row this line carries, when tagged; null means the account's default flow.

total_debitrequiredinteger
total_creditrequiredinteger
atrequiredstring

ISO-8601 UTC timestamp

createdByoptionalstring

User ID that initiated the operation

idempotentReplayoptionalboolean

True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

Default: false

StatusMeaning
400Invalid request
401Authentication required
403Access denied
404Resource not found
409Idempotency-Key conflict — key reused with different body
422Validation error
429Rate limit exceeded
500Internal server error