Outcome
Post the year-end close: every income and expense balance still open through the last day of the year moves to retained earnings in one journal dated that day. Refused with fiscal_year_in_progress before the year has ended and nothing_to_close when no balance remains. A year already closed returns the standing close (alreadyClosed true) rather than a second one.
Before you start
- Verify the intended environment, authenticated identity and specifically approved organization context.
- The published application permission is periods:write. Discover the exact granted canonical Books workspace and bind it separately from action input.
- Approve the actual mutation, accounting inputs and any provider/recipient effects before CLI --confirm or MCP confirm:true. Fixture identifiers and simulated provider responses authorize no live operation.
Discover the target
topolo whoami --json
topolo actions get app_topolo_books.periods.year_ends.close --detail --json
topolo resources topolo-books --json
topolo workspaces list topolo-books --json
- Set BOOKS_WORKSPACE_ID to the exact granted workspace returned by discovery.
Request
POST /api/periods/year-ends/{fiscalYear}/close
Inspect and test this action. Save the reviewed input as payload.json; supply credential/resource context separately.
Input fields
| Field | Required | Meaning | Schema and constraints |
|---|---|---|---|
fiscalYear | Required | Fiscal year label interpreted with the workspace fiscal-year start month. | {"anyOf":[{"type":"integer","minimum":1900,"maximum":2999},{"type":"string","pattern":"^\d{4}$"}]} |
overrideSoftLock | Optional | Explicit override of a soft accounting lock; inspect the lock and obtain authority before posting. | {"type":"boolean"} |
Inspect nested fields and the complete input schema.
Effects
- Posts one hash-chained journal dated the last day of the fiscal year: each income and expense account's open balance is cleared and the net goes to the retained-earnings account.
- The profit and loss leaves this journal out, so the year still reports its result; the balance sheet keeps it, so retained earnings carry it forward.
Interpret the response
This reports a numeric fiscalYear label and close/posting evidence, not a new string resource identifier. Inspect returned journal evidence and the year-end reads.
Call app_topolo_books.periods.year_ends.list and confirm the year shows status closed with the close journal and profitMinor, or read the journal back with app_topolo_books.journals.get.
Inspect the success schema. CLI/MCP add their own transport envelope; CLI --detail requests the full result.
Worked examples
Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.
Run a reviewed request
Save the input from the selected worked example as payload.json. Validate and inspect the plan before calling the action; refused examples demonstrate errors and are not instructions to execute.
CLI:
topolo actions validate app_topolo_books.periods.year_ends.close --data @payload.json --json
topolo actions plan app_topolo_books.periods.year_ends.close --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.periods.year_ends.close --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --confirm --detail --json
MCP tool and arguments for the first successful example:
{
"tool": "topolo_call_action",
"arguments": {
"actionId": "app_topolo_books.periods.year_ends.close",
"input": {
"fiscalYear": "2025"
},
"resourceType": "workspace",
"resourceId": "<exact granted workspace id>",
"confirm": true,
"detail": true
}
}
Refused response · nothing_to_close
Input · payload.json:
{
"fiscalYear": "2024"
}
Captured response · HTTP 409
{
"error": "nothing_to_close",
"message": "No income or expense balance remains open for fiscal year 2024",
"details": {
"fiscalYear": 2024,
"startDate": "2024-01-01",
"endDate": "2024-12-31"
}
}
HTTP 409. SDK error code nothing_to_close. Read periods.year_ends.list and the year-end trial balance. There is no remaining income or expense balance to close; do not create a fabricated adjustment to force success.
Successful response · HTTP 201
Input · payload.json:
{
"fiscalYear": "2025"
}
Captured response · HTTP 201
{
"fiscalYear": 2025,
"journal": {
"id": "je_b7909cfc3f46474096150c7efa9ee3d4",
"organization_id": "org_close_muvnpl6v6",
"workspace_id": "ws_close_muvnpl6v6",
"sequence": 3,
"period_key": "2025-12",
"posted_on": "2025-12-31",
"event_type": "journal_posted",
"journal_type": "year_end_close",
"description": "Year end 2025: profit for the year transferred to retained earnings",
"reference": "YE-2025",
"source_app": "topolo-books",
"source_document_type": null,
"source_document_id": null,
"actor_type": "topolo_agent",
"actor_id": "usr_test",
"autonomy_level": null,
"correlation_id": null,
"idempotency_key": "year-end-close:2025",
"reverses_event_id": null,
"reversed_by_event_id": null,
"total_debit_minor": 900,
"total_credit_minor": 900,
"line_count": 2,
"previous_hash": "cd091c45bef353c79edddfa70449f7854bd34cf823352cc955fbb585e8d7d771",
"hash": "b483d489485c8912ffcf674b047e42f14df3e7662bfdae03896f6e8b4b8c4341",
"created_at": "2026-10-05T19:42:36.713Z",
"notes": null
},
"lines": [
{
"id": "jl_002e968a042a4712bddb38ed610d9edf",
"organization_id": "org_close_muvnpl6v6",
"workspace_id": "ws_close_muvnpl6v6",
"event_id": "je_b7909cfc3f46474096150c7efa9ee3d4",
"sequence": 3,
"line_no": 1,
"period_key": "2025-12",
"posted_on": "2025-12-31",
"account_id": "acc_35d48792985848889ab2e2d80ead39dc",
"amount_minor": 900,
"currency": "USD",
"document_currency": null,
"document_amount_minor": null,
"fx_rate": null,
"tax_rate_id": null,
"contact_id": null,
"dimensions": null,
"memo": "4000 Sales"
},
{
"id": "jl_97c8ef9351e9424a98d25756411c744c",
"organization_id": "org_close_muvnpl6v6",
"workspace_id": "ws_close_muvnpl6v6",
"event_id": "je_b7909cfc3f46474096150c7efa9ee3d4",
"sequence": 3,
"line_no": 2,
"period_key": "2025-12",
"posted_on": "2025-12-31",
"account_id": "acc_bf61facfb6e84888adc78a6d8e69d711",
"amount_minor": -900,
"currency": "USD",
"document_currency": null,
"document_amount_minor": null,
"fx_rate": null,
"tax_rate_id": null,
"contact_id": null,
"dimensions": null,
"memo": "Profit for the year transferred to retained earnings"
}
],
"profitMinor": 900,
"alreadyClosed": false
}
HTTP 201. Call app_topolo_books.periods.year_ends.list and confirm the year shows status closed with the close journal and profitMinor, or read the journal back with app_topolo_books.journals.get.
Successful response · HTTP 200
Input · payload.json:
{
"fiscalYear": "2025"
}
Captured response · HTTP 200
{
"fiscalYear": 2025,
"journal": {
"id": "je_b7909cfc3f46474096150c7efa9ee3d4",
"organization_id": "org_close_muvnpl6v6",
"workspace_id": "ws_close_muvnpl6v6",
"sequence": 3,
"period_key": "2025-12",
"posted_on": "2025-12-31",
"event_type": "journal_posted",
"journal_type": "year_end_close",
"description": "Year end 2025: profit for the year transferred to retained earnings",
"reference": "YE-2025",
"source_app": "topolo-books",
"source_document_type": null,
"source_document_id": null,
"actor_type": "topolo_agent",
"actor_id": "usr_test",
"autonomy_level": null,
"correlation_id": null,
"idempotency_key": "year-end-close:2025",
"reverses_event_id": null,
"reversed_by_event_id": null,
"total_debit_minor": 900,
"total_credit_minor": 900,
"line_count": 2,
"previous_hash": "cd091c45bef353c79edddfa70449f7854bd34cf823352cc955fbb585e8d7d771",
"hash": "b483d489485c8912ffcf674b047e42f14df3e7662bfdae03896f6e8b4b8c4341",
"created_at": "2026-10-05T19:42:36.713Z",
"notes": null
},
"lines": [
{
"id": "jl_002e968a042a4712bddb38ed610d9edf",
"organization_id": "org_close_muvnpl6v6",
"workspace_id": "ws_close_muvnpl6v6",
"event_id": "je_b7909cfc3f46474096150c7efa9ee3d4",
"sequence": 3,
"line_no": 1,
"period_key": "2025-12",
"posted_on": "2025-12-31",
"account_id": "acc_35d48792985848889ab2e2d80ead39dc",
"amount_minor": 900,
"currency": "USD",
"document_currency": null,
"document_amount_minor": null,
"fx_rate": null,
"tax_rate_id": null,
"contact_id": null,
"dimensions": null,
"memo": "4000 Sales"
},
{
"id": "jl_97c8ef9351e9424a98d25756411c744c",
"organization_id": "org_close_muvnpl6v6",
"workspace_id": "ws_close_muvnpl6v6",
"event_id": "je_b7909cfc3f46474096150c7efa9ee3d4",
"sequence": 3,
"line_no": 2,
"period_key": "2025-12",
"posted_on": "2025-12-31",
"account_id": "acc_bf61facfb6e84888adc78a6d8e69d711",
"amount_minor": -900,
"currency": "USD",
"document_currency": null,
"document_amount_minor": null,
"fx_rate": null,
"tax_rate_id": null,
"contact_id": null,
"dimensions": null,
"memo": "Profit for the year transferred to retained earnings"
}
],
"profitMinor": 900,
"alreadyClosed": true
}
HTTP 200. Call app_topolo_books.periods.year_ends.list and confirm the year shows status closed with the close journal and profitMinor, or read the journal back with app_topolo_books.journals.get.
Refused response · forbidden
Input · payload.json:
{
"fiscalYear": "2025"
}
Captured response · HTTP 403
{
"error": "forbidden"
}
HTTP 403. SDK error code forbidden. The credential lacks permission or the resource is outside its scope. Compare the published action permission and discovered workspace binding; obtain the appropriate authorization before another call.
Refused response · auth_error
Input · payload.json:
{
"fiscalYear": "2026"
}
Captured response · HTTP 401
{
"error": "API key validation failed"
}
HTTP 401. SDK error code auth_error. Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.
Verify the result
- Call app_topolo_books.periods.year_ends.list and confirm the year shows status closed with the close journal and profitMinor, or read the journal back with app_topolo_books.journals.get.
Errors and recovery
nothing_to_close(HTTP 409): Read periods.year_ends.list and the year-end trial balance. There is no remaining income or expense balance to close; do not create a fabricated adjustment to force success.forbidden(HTTP 403): The credential lacks permission or the resource is outside its scope. Compare the published action permission and discovered workspace binding; obtain the appropriate authorization before another call.auth_error(HTTP 401): Authenticate in the intended organization again. Verify whoami and the exact Books application/workspace binding before retrying; do not switch identity to work around a refusal.
These are observed local refusals. Shared authentication, schema validation and resource authorization can also refuse before the route. Preserve the actual error, details and request id.
Recovery boundary
Reopen the year: the close is reversed, adjustments can be posted, and the year is closed again.
Related actions
- List fiscal years: List every fiscal year the books touch with its dates, how many periods it holds and are locked, whether it has been closed, and the close journal with the profit it moved to retained earnings.
- Get balance sheet: Balance sheet at a date (default today): current and non-current assets and liabilities, equity with current-year and prior-years earnings computed from the ledger, and a balanced flag. compare adds the previous month or the previous year beside every figure. Amounts are natural-sign base-currency minor units. compare adds earlier columns, each stepping back again: previous_month by a month, previous_year by twelve. comparePeriods says how many, 1 to 11, and needs compare set. Read
columnsfor the date each column is drawn at andamountsMinorfor the figures in that order - Lock an accounting period: Soft-lock (override possible) or hard-lock (nothing posts) a YYYY-MM period. Postings into a locked period are refused with period_locked.
- List accounting periods: List the monthly accounting periods and their lock status, optionally for one fiscal year.
- Reopen a fiscal year: Reverse the year-end close so adjustments can be posted, then close the year again. Refused with fiscal_year_not_closed when there is no close to reverse.
Evidence
Actual Books route handlers and the exported Worker were exercised against five local SQLite D1 concern databases with all committed migrations, the real posting Durable Object and local R2. Route captures use synthetic verified Auth; Worker captures use synthetic Auth transports. Nexus, Brand, Notify, Pay, Mercury and Xero responses are explicitly simulated at the provider transport boundary. Captures prove local request/response behavior and canonical SDK projection, not live bank access, payment movement, email delivery, provider eligibility, tax compliance, encrypted custody, scheduled execution, deployment or production completion. Fixture identities, credentials, addresses and records authorize no live operation.