Topolo Docs Topolo Platform
Open workspace

Post journal draft

Validate and post a complete balanced draft through the journal serializer, atomically schedule its optional automatic reversal, then remove the draft. A stable draft idempotency key prevents a retry creating a duplicate event.

Outcome

Validate and post a complete balanced draft through the journal serializer, atomically schedule its optional automatic reversal, then remove the draft. A stable draft idempotency key prevents a retry creating a duplicate event.

Before you start

  • Verify the intended environment, authenticated identity and specifically approved organization context.
  • The published application permission is journals: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.journals.drafts.post --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.
  • draftId: Exact draft.id from journals.drafts.list/get. Posting or discarding removes the mutable draft.

Request

POST /api/journal-drafts/{draftId}/post

Inspect and test this action. Save the reviewed input as payload.json; supply credential/resource context separately.

Input fields

FieldRequiredMeaningSchema and constraints
draftIdRequiredExact draft.id from journals.drafts.list/get. Posting or discarding removes the mutable draft.{"type":"string","minLength":1}

Inspect nested fields and the complete input schema.

Effects

  • Posts one immutable balanced journal through the workspace serializer, then removes the editable draft. A retry cannot duplicate the event because the draft id is its idempotency key.

Interpret the response

Read $.journal.id for the returned journal identifier. Empty collections and nullable fields do not discover a target.

Call app_topolo_books.journals.get with the returned journal id and confirm the event and lines, then confirm the draft no longer appears in journals.drafts.list.

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.journals.drafts.post --data @payload.json --json
topolo actions plan app_topolo_books.journals.drafts.post --resource-type workspace --resource-id "$BOOKS_WORKSPACE_ID" --data @payload.json --json
topolo actions call app_topolo_books.journals.drafts.post --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.journals.drafts.post",
    "input": {
      "draftId": "jd_ef8abf153ae14b6491d2a0374121e096"
    },
    "resourceType": "workspace",
    "resourceId": "<exact granted workspace id>",
    "confirm": true,
    "detail": true
  }
}

Refused response · auth_error

Input · payload.json:

{
  "draftId": "jd_7f3c1b"
}

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.

Successful response · HTTP 201

Input · payload.json:

{
  "draftId": "jd_ef8abf153ae14b6491d2a0374121e096"
}

Captured response · HTTP 201

{
  "journal": {
    "id": "je_d746fce95d864eb0b5a7aa3c3f1cee4f",
    "organization_id": "org_journal-evidence_muvnpwo91",
    "workspace_id": "ws_journal-evidence_muvnpwo91",
    "sequence": 1,
    "period_key": "2026-09",
    "posted_on": "2026-09-06",
    "event_type": "journal_posted",
    "journal_type": "manual",
    "description": "Accrued professional fees",
    "reference": null,
    "source_app": "topolo-books",
    "source_document_type": null,
    "source_document_id": null,
    "actor_type": "topolo_agent",
    "actor_id": "usr_evidence",
    "autonomy_level": null,
    "correlation_id": null,
    "idempotency_key": "draft:jd_ef8abf153ae14b6491d2a0374121e096",
    "reverses_event_id": null,
    "reversed_by_event_id": null,
    "total_debit_minor": 25000,
    "total_credit_minor": 25000,
    "line_count": 2,
    "previous_hash": "",
    "hash": "209b67e3188a0650a2661caa577092dc743ac11e56ad789ff0f905a1bf69fc48",
    "created_at": "2026-10-05T19:42:51.595Z",
    "notes": "Signed engagement letter and calculation attached."
  },
  "lines": [
    {
      "id": "jl_f1f620d418dc41278935858679683bf7",
      "organization_id": "org_journal-evidence_muvnpwo91",
      "workspace_id": "ws_journal-evidence_muvnpwo91",
      "event_id": "je_d746fce95d864eb0b5a7aa3c3f1cee4f",
      "sequence": 1,
      "line_no": 1,
      "period_key": "2026-09",
      "posted_on": "2026-09-06",
      "account_id": "acc_8eff11bcd18140ecb674b9f57ed84906",
      "amount_minor": 25000,
      "currency": "GBP",
      "document_currency": null,
      "document_amount_minor": null,
      "fx_rate": null,
      "tax_rate_id": null,
      "contact_id": null,
      "dimensions": null,
      "memo": null
    },
    {
      "id": "jl_c14a19e229f947a58d26a3e19c9bcf30",
      "organization_id": "org_journal-evidence_muvnpwo91",
      "workspace_id": "ws_journal-evidence_muvnpwo91",
      "event_id": "je_d746fce95d864eb0b5a7aa3c3f1cee4f",
      "sequence": 1,
      "line_no": 2,
      "period_key": "2026-09",
      "posted_on": "2026-09-06",
      "account_id": "acc_ecddad9adb094b8f8ae7cb16b30b9c5f",
      "amount_minor": -25000,
      "currency": "GBP",
      "document_currency": null,
      "document_amount_minor": null,
      "fx_rate": null,
      "tax_rate_id": null,
      "contact_id": null,
      "dimensions": null,
      "memo": null
    }
  ],
  "draftId": "jd_ef8abf153ae14b6491d2a0374121e096"
}

HTTP 201. Call app_topolo_books.journals.get with the returned journal id and confirm the event and lines, then confirm the draft no longer appears in journals.drafts.list.

Refused response · journal_draft_incomplete

Input · payload.json:

{
  "draftId": "jd_ad62470177ad4161ba97a15e8e431989"
}

Captured response · HTTP 400

{
  "error": "journal_draft_incomplete",
  "message": "Choose a posting date before posting this draft"
}

HTTP 400. SDK error code journal_draft_incomplete. Read the draft and supply a posting date, complete accounts and balanced signed minor-unit lines through journals.drafts.update. Posting is a separate confirmed action.

Successful response · HTTP 201

Input · payload.json:

{
  "draftId": "jd_ad62470177ad4161ba97a15e8e431989"
}

Captured response · HTTP 201

{
  "journal": {
    "id": "je_4e89e578d1af4e9fb32412fa745f00a6",
    "organization_id": "org_journal-draft_muvnpsmk5",
    "workspace_id": "ws_journal-draft_muvnpsmk5",
    "sequence": 1,
    "period_key": "2026-09",
    "posted_on": "2026-09-06",
    "event_type": "journal_posted",
    "journal_type": "manual",
    "description": "Accrual",
    "reference": null,
    "source_app": "topolo-books",
    "source_document_type": null,
    "source_document_id": null,
    "actor_type": "topolo_agent",
    "actor_id": "usr_drafts",
    "autonomy_level": null,
    "correlation_id": null,
    "idempotency_key": "draft:jd_ad62470177ad4161ba97a15e8e431989",
    "reverses_event_id": null,
    "reversed_by_event_id": null,
    "total_debit_minor": 25000,
    "total_credit_minor": 25000,
    "line_count": 2,
    "previous_hash": "",
    "hash": "2b061d9f88cc1a1bda892cf5549bdb426a5b95d6d443e0321d988fb0c1518a5b",
    "created_at": "2026-10-05T19:42:46.336Z",
    "notes": null
  },
  "lines": [
    {
      "id": "jl_8780e35044df4f26a4cb25ee39a4cc2d",
      "organization_id": "org_journal-draft_muvnpsmk5",
      "workspace_id": "ws_journal-draft_muvnpsmk5",
      "event_id": "je_4e89e578d1af4e9fb32412fa745f00a6",
      "sequence": 1,
      "line_no": 1,
      "period_key": "2026-09",
      "posted_on": "2026-09-06",
      "account_id": "acc_46f59abfdaea410888374bade9e2bbf9",
      "amount_minor": 25000,
      "currency": "GBP",
      "document_currency": null,
      "document_amount_minor": null,
      "fx_rate": null,
      "tax_rate_id": null,
      "contact_id": null,
      "dimensions": null,
      "memo": null
    },
    {
      "id": "jl_3576108c36154331b8bb7b83ec5f3b42",
      "organization_id": "org_journal-draft_muvnpsmk5",
      "workspace_id": "ws_journal-draft_muvnpsmk5",
      "event_id": "je_4e89e578d1af4e9fb32412fa745f00a6",
      "sequence": 1,
      "line_no": 2,
      "period_key": "2026-09",
      "posted_on": "2026-09-06",
      "account_id": "acc_faa5d599baf343f4938b67cae43d8da3",
      "amount_minor": -25000,
      "currency": "GBP",
      "document_currency": null,
      "document_amount_minor": null,
      "fx_rate": null,
      "tax_rate_id": null,
      "contact_id": null,
      "dimensions": null,
      "memo": null
    }
  ],
  "draftId": "jd_ad62470177ad4161ba97a15e8e431989"
}

HTTP 201. Call app_topolo_books.journals.get with the returned journal id and confirm the event and lines, then confirm the draft no longer appears in journals.drafts.list.

Verify the result

  • Call app_topolo_books.journals.get with the returned journal id and confirm the event and lines, then confirm the draft no longer appears in journals.drafts.list.

Errors and recovery

  • 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.
  • journal_draft_incomplete (HTTP 400): Read the draft and supply a posting date, complete accounts and balanced signed minor-unit lines through journals.drafts.update. Posting is a separate confirmed action.

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

Reverse the returned journal. Posted events are immutable.

  • Get journal draft: Read one editable journal draft with its ordered lines.
  • Get journal: Read one journal event with every line, its account and its debit or credit, which is what reconciles against the ledger.
  • Get trial balance: Every account holding a balance at the date, each on one side only: debitMinor carries a debit balance, creditMinor a credit balance, and the other is zero. Accounts that net to nothing are left out. totalDebitMinor and totalCreditMinor are the sums of those balances and must agree, which is what balanced reports. These are balances, not turnover: they do not add up everything ever posted to an account, which would count both sides of every entry and count an expense again when a year-end close reverses it.
  • List journals: List posted journal events, filtered by date range or period, searched across description, reference and journal type, and sorted by sequence, posted date, description or amount. Newest first unless you say otherwise.
  • Reverse a journal: Post the reversal of a journal: the same lines negated, dated as requested (default the original date). A journal can be reversed once; corrections are reversals, never edits.

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.