Commit and undo
Commit exactly what you previewed, retry safely, and undo a run until something else depends on it.
Commit
POST /v1/plans
Idempotency-Key: onboard-acme-2026-11-06-1
Content-Type: application/json
{ "plan_id": "2643af76-4f65-40a9-998a-599a2a9facf3" }- Scope:
plans:commit, plus the scopes of the routes the steps call. - The body is either
{ "plan_id": … }or a full plan (description+steps), never both. - Optional:
session_id(see Sessions) andallow_drift: true(only withplan_id). - A
plan_idis re-executed, not replayed from storage. Only the principal that previewed it can commit it, or a caller holdingplans:releasethat is org-wide and not a plan-only key. For anyone else it isPLAN_NOT_FOUND. - If any step fails or is skipped, nothing is kept:
200withcommitted: falseand the report. - On success:
200withcommitted: true. Each step writes its own audit row.
Drift
The commit must write the same rows per step, and the steps must answer the same responses
once ids and timestamps are set aside. Otherwise nothing is kept and the answer is
409 PLAN_DRIFT (re_preview). Preview again and look at what changed.
Send allow_drift: true only when you have checked the difference is harmless, such as a
document number from a sequence or a date that defaults to today.
Retrying a commit
Use a new Idempotency-Key for each new commit attempt. Reuse a key only to retry the same
request whose answer you lost.
- The key is required on commit. Missing:
400 IDEMPOTENCY_KEY_REQUIRED. Not matching^[A-Za-z0-9_-]{1,255}$:400 INVALID_IDEMPOTENCY_KEY. - Every
200answer is stored under the key,committed: falseincluded. The same key with the same body replays the stored answer; the plan does not run again.- Lost the answer (dropped connection)? Retry with the same key and body.
- Got
committed: false? The same key replays the same failure. A failed commit does not use up the preview: theplan_idstays committable with a new key. 504 PLAN_TIMEOUTis not stored. Nothing was kept; split the plan and send it with a new key.
- The same key with a different body (a new
plan_idafter a fix) is409 IDEMPOTENCY_CONFLICT. Commit with a new key. - A preview's
plan_idcommits once. Committing it again with a new key isPLAN_NOT_FOUND. To build the same thing again, preview again.
Undo
POST /v1/plans/{id}/undoUndoes a committed run in one transaction, all or nothing, newest row first. Only the
principal that committed it, or an org-wide caller holding plans:release, can undo it.
The answer's undo_mode says how:
clean: the run posted nothing to the ledger. Rows it created are deleted, rows it changed are put back, rows it deleted are re-inserted.compensating: the run posted (a loan activation posts a drawdown). Posted documents are voided through the normal void path, so a reversal lands in the ledger and both entries stay. Rows the ledger still references are retired instead of deleted: a loan becomescancelled, a legal entityinactive, a party inactive. Rows that cannot be retired are listed underkept.
The answer lists deleted, restored, voided, archived and kept. The run ends
undone.
Undo is refused once outside rows depend on the run
If anything outside the run now refers to a row it created (a lease on your property, a
payment on your loan, another plan's rows), undo answers 409 PLAN_UNDO_BLOCKED and changes
nothing. context.blockers lists each blocking table, the ids and the blocking_run_id
(null when it is not a plan's row). If something outside the run changed a row the run
updated, it is 409 PLAN_UNDO_CONFLICT. A job the run queued that is running right now
also blocks. Undoing twice is 409 PLAN_NOT_HELD.
So read back right after you commit, and undo at once if it is wrong. The longer you wait, the more likely a user or a scheduled job has built on your rows.
Sessions
When one build needs several plans (a later part needs earlier parts really committed, or
the time budget forces a split), give every commit the same session_id. Then
POST /v1/plans/sessions/{session_id}/undoundoes the session's runs newest first in one transaction. A blocker or conflict on any run refuses them all. Runs already undone, and failed runs, are skipped.
Release
POST /v1/plans/{id}/release (scope plans:release) answers 204 and only confirms the
status: committed runs are already released, and undo works on them. You do not need to
call it.