Acreum Docs
Agents

Plans

List plan runs

GET
/v1/plans

The organization's plan runs, newest first: previews (kept 7 days) and commits, each without its plan and report. Filter by status, mode or session_id; search matches the description. Read one run, with its plan and report, at GET /v1/plans/{id}. A legal-entity-scoped principal sees only the runs it made itself.

Required scope: plans:preview

Pagination: cursor

Error codes: INVALID_CURSOR, VALIDATION_FAILED

Authorization

access-token
headerAuthorizationBearer <token>

Query Parameters

status?string
Value in"previewed""committed""held""released""undone""failed"
mode?string
Value in"preview""commit"
session_id?string

Only runs committed with this session_id.

Formatuuid
cursor?string
limit?number

1..100, default 100

Range1 <= value <= 100
sort?string

Default: -created_at

Value in"created_at""-created_at"
search?string

Case-insensitive substring match on: description.

ids?string

Up to 100 ids; returns those rows regardless of other filters and ignores search.

Response Body

application/json
  1. response
data*array<>
meta*
curl -X GET 'https://api.acreum.io/v1/plans'
{  "data": [    {      "created_at": "2019-08-24T14:15:22Z",      "description": "string",      "fingerprint": "sha256:9f2c…",      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "mode": "preview",      "principal_id": "string",      "principal_kind": "user",      "released_at": "2019-08-24T14:15:22Z",      "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82",      "status": "previewed",      "undo_mode": "clean",      "undone_at": "2019-08-24T14:15:22Z"    }  ],  "meta": {    "api_version": "2026-04-23",    "limit": 50,    "next_cursor": "eyJpZCI6ICJhYmMifQ==",    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f"  }}

Commit a plan

POST
/v1/plans

Runs a plan inside one database transaction and keeps it when every step succeeds. The body is EITHER a full plan (steps, as for a preview) OR the plan_id of a preview, never both.

A plan_id is re-executed, not replayed, and only by the principal that previewed it (or a caller holding plans:release; a plan-only key or a legal-entity-scoped or security-group-restricted principal never counts as holding it); any other plan_id answers PLAN_NOT_FOUND. The run must do what its preview showed: the same rows written per step, and the same step responses once ids and timestamps are set aside. Otherwise nothing is kept and the answer is 409 PLAN_DRIFT, unless the body says allow_drift: true (only with plan_id; with steps it is refused as VALIDATION_FAILED, context.pointer /allow_drift). Sequence-allocated numbers (a document number, for example) and date fields defaulted to today can differ between preview and commit, and show as drift.

When any step fails or is skipped, nothing is kept and the answer is still 200, with committed: false and the report saying why (summary.first_error); the run is stored with status failed. A plan that runs out of its time budget answers 504 PLAN_TIMEOUT with the report in context.report, and keeps nothing either.

The Idempotency-Key is required and seeds each non-GET step's own key (sha256 of this key, a newline, then the step's ref), so a retry does not run the plan twice. Retrying with the same Idempotency-Key replays the stored answer, even after the run was undone. Each step writes its own audit row; the commit adds one plans.commit.

Required scope: plans:commit

Error codes: VALIDATION_FAILED, IDEMPOTENCY_KEY_REQUIRED, INVALID_IDEMPOTENCY_KEY, IDEMPOTENCY_CONFLICT, PLAN_NOT_FOUND, PLAN_DRIFT, PLAN_ROUTE_NOT_PLANNABLE, PLAN_DUPLICATE_REF, PLAN_REF_FORWARD, PLAN_TOO_LARGE, PLAN_TIMEOUT, PLAN_ORG_BUSY, PLAN_RAW_DB_ACCESS

Authorization

access-token
headerAuthorizationBearer <token>

Header Parameters

Idempotency-Key*string

Client-chosen key that makes this mutation safe to retry. Required — a request without one is rejected with IDEMPOTENCY_KEY_REQUIRED. Reusing a key with the same body replays the original response for ~24 hours; reusing it with a different body returns IDEMPOTENCY_CONFLICT.

Match^[A-Za-z0-9_-]{1,255}$
Lengthlength <= 255

Request Body

application/json
  1. body
allow_drift?boolean

With plan_id only (refused with steps): commit even when the run no longer matches its preview (a lookup answers differently, or a step writes different rows). Sequence-allocated numbers (a document number, for example) and date fields defaulted to today can differ between preview and commit, and show as drift.

Defaultfalse
description?string

What the plan is for, in a sentence. Only with steps; part of the fingerprint.

Lengthlength <= 500
plan_id?string

The plan_id a preview returned. The stored plan is re-executed (not replayed) and must do what its preview showed, or the commit is refused with PLAN_DRIFT. Only the principal that previewed it can commit it, unless the caller holds plans:release (a plan-only key or a legal-entity-scoped principal never counts as holding it). Send this or steps, not both.

Formatuuid
session_id?string

Groups this run with other runs of one build, so they can be undone together.

Formatuuid
steps?array<>

The steps, run in order, as for a preview. Send this or plan_id, not both.

Items1 <= items <= 50

Response Body

application/json
  1. response
data*
meta*
curl -X POST 'https://api.acreum.io/v1/plans' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{}'
{  "data": {    "committed": true,    "diff_summary": [      "e1: create legal entity 'Acme Holdings LLC' (+42 accounts)"    ],    "fingerprint": "sha256:9f2c…",    "journal_entries": [      {        "entry_date": "2019-08-24",        "journal_entry_id": "string",        "legal_entity_id": "string",        "lines": [          {            "account_id": "string",            "credit": "1234.50",            "debit": "1234.50"          }        ],        "source_type": "string",        "step": "string",        "total_credit": "1234.50",        "total_debit": "1234.50"      }    ],    "mode": "commit",    "plan_id": "string",    "scheduled_effects": [      {        "acts_on": {          "count": 1,          "ids": [            "string"          ],          "table": "loans"        },        "handler": "loan_rolling_window",        "next_run_at": "2019-08-24T14:15:22Z"      }    ],    "steps": [      {        "blocked_by": [          "string"        ],        "duration_ms": 12,        "error": {          "code": "VALIDATION_FAILED",          "detail": "maturity_date must be after start_date",          "next_action": "fix_step",          "pointer": "/steps/3/body/maturity_date",          "retryable": false        },        "http_status": 201,        "index": 0,        "reason": "blocked",        "ref": "e1",        "resource": {          "id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",          "table": "legal_entities"        },        "response": {},        "status": "ok"      }    ],    "summary": {      "error": 1,      "first_error": {        "code": "VALIDATION_FAILED",        "detail": "maturity_date must be after start_date",        "next_action": "fix_step",        "pointer": "/steps/3/body/maturity_date",        "retryable": false,        "step": "l1"      },      "journal_total_debit": "1234.50",      "ok": 3,      "skipped": 1,      "tables_touched": {        "accounts": 42,        "legal_entities": 1      }    },    "truncated": true,    "warnings": [      "string"    ],    "would_fire": {      "events": [        {          "event": "LoanActivatedEvent",          "step": "a1"        }      ],      "jobs": [        {          "count": 1,          "job_type": "loan_accrual",          "step": "a1"        }      ]    },    "writes": [      {        "count": 42,        "ids": [          "string"        ],        "job_types": [          "loan_accrual"        ],        "op": "insert",        "step": "e1",        "table": "accounts"      }    ]  },  "meta": {    "api_version": "2026-04-23",    "cursor": {      "has_more": true,      "next": "eyJpZCI6ICJhYmMifQ=="    },    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",    "total_count": 1234  }}
GET
/v1/plans/capabilities

Everything an agent needs to write a plan, in one call: the routes a non-GET step may call (plannable_routes, the operations marked x-plannable in this contract; every GET under /v1/ is plannable without a mark), the limits (max_steps, the time budget, plans per instance), the $<ref> reference grammar with examples, the headers a step may send, and every plan error code with its retryable flag and next_action. Read it before the first preview, instead of probing routes one by one. It is the same for every caller and changes only with a deploy.

Required scope: plans:preview

Authorization

access-token
headerAuthorizationBearer <token>

Response Body

application/json
  1. response
data*
meta*
curl -X GET 'https://api.acreum.io/v1/plans/capabilities'
{  "data": {    "error_codes": [      {        "code": "PLAN_TIMEOUT",        "http_status": 504,        "next_action": "fix_step",        "retryable": true      }    ],    "implicitly_plannable": "Every GET under /v1/ is plannable.",    "limits": {      "max_concurrent_per_instance": 2,      "max_steps": 50,      "time_budget_ms": 20000    },    "plannable_routes": [      {        "method": "POST",        "operation_id": "Loans.activate",        "path": "/v1/loans/{id}/activate"      }    ],    "references": {      "examples": [        "string"      ],      "grammar": "string"    },    "step_headers": [      "if-match",      "x-contract-version"    ]  },  "meta": {    "api_version": "2026-04-23",    "cursor": {      "has_more": true,      "next": "eyJpZCI6ICJhYmMifQ=="    },    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",    "total_count": 1234  }}

Preview a plan

POST
/v1/plans/preview

Runs a plan — an ordered list of API calls — inside one database transaction that is always rolled back, and reports what each step would do. Nothing the plan writes is kept: no rows, no audit entries, no idempotency keys. The steps' post-commit work runs inside the same transaction and rolls back with it: the jobs it would queue are never kept, and the events it publishes are recorded, not delivered. The only record is the stored preview, whose id is plan_id.

Each step is a real call to a /v1/ route, made with your own credentials, so every route keeps its own scopes and validation; this endpoint grants nothing beyond plans:preview. A non-GET step must call a route marked x-plannable in this contract, otherwise the step fails with PLAN_ROUTE_NOT_PLANNABLE.

A later step uses an earlier response by writing a whole string "$<ref>/<json-pointer>" in its body, or a path segment $<ref> followed by the pointer (/v1/legal-entities/$e1/data/id). A failed step rolls back only itself; steps that reference it are skipped, independent steps still run.

The report puts summary (counts, first_error with its pointer into the submitted plan and its next_action) and diff_summary (one line per step) first, then the capped detail: steps, writes (every captured row, grouped), journal_entries, scheduled_effects (the enabled scheduled jobs that will act on the plan's rows, and when they next run) and would_fire (the jobs and events the post-commit work would queue and publish, per step). A plan that runs out of its time budget answers 504 PLAN_TIMEOUT with the report of what did run in context.report.

Required scope: plans:preview

Error codes: VALIDATION_FAILED, INVALID_IDEMPOTENCY_KEY, PLAN_ROUTE_NOT_PLANNABLE, PLAN_DUPLICATE_REF, PLAN_REF_FORWARD, PLAN_REF_UNRESOLVED, PLAN_TOO_LARGE, PLAN_TIMEOUT, PLAN_ORG_BUSY, PLAN_RAW_DB_ACCESS

Authorization

access-token
headerAuthorizationBearer <token>

Header Parameters

Idempotency-Key?string

Optional. Seeds each non-GET step's own idempotency key (sha256 of this key, a newline, then the step's ref), so a preview and a later commit of the same plan with the same key derive the same step keys. A preview keeps nothing, so it never replays.

Match^[A-Za-z0-9_-]{1,255}$
Lengthlength <= 255

Request Body

application/json
  1. body
description?string

What the plan is for, in a sentence. Part of the fingerprint.

Lengthlength <= 500
steps*array<>

The steps, run in order.

Items1 <= items <= 50

Response Body

application/json
  1. response
data*
meta*
curl -X POST 'https://api.acreum.io/v1/plans/preview' \  -H 'Content-Type: application/json' \  -d '{  "steps": [    {      "method": "POST",      "path": "/v1/properties",      "ref": "e1"    }  ]}'
{  "data": {    "committed": false,    "diff_summary": [      "e1: create legal entity 'Acme Holdings LLC' (+42 accounts)"    ],    "fingerprint": "sha256:9f2c…",    "journal_entries": [      {        "entry_date": "2019-08-24",        "journal_entry_id": "string",        "legal_entity_id": "string",        "lines": [          {            "account_id": "string",            "credit": "1234.50",            "debit": "1234.50"          }        ],        "source_type": "string",        "step": "string",        "total_credit": "1234.50",        "total_debit": "1234.50"      }    ],    "mode": "preview",    "plan_id": "string",    "scheduled_effects": [      {        "acts_on": {          "count": 1,          "ids": [            "string"          ],          "table": "loans"        },        "handler": "loan_rolling_window",        "next_run_at": "2019-08-24T14:15:22Z"      }    ],    "steps": [      {        "blocked_by": [          "string"        ],        "duration_ms": 12,        "error": {          "code": "VALIDATION_FAILED",          "detail": "maturity_date must be after start_date",          "next_action": "fix_step",          "pointer": "/steps/3/body/maturity_date",          "retryable": false        },        "http_status": 201,        "index": 0,        "reason": "blocked",        "ref": "e1",        "resource": {          "id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",          "table": "legal_entities"        },        "response": {},        "status": "ok"      }    ],    "summary": {      "error": 1,      "first_error": {        "code": "VALIDATION_FAILED",        "detail": "maturity_date must be after start_date",        "next_action": "fix_step",        "pointer": "/steps/3/body/maturity_date",        "retryable": false,        "step": "l1"      },      "journal_total_debit": "1234.50",      "ok": 3,      "skipped": 1,      "tables_touched": {        "accounts": 42,        "legal_entities": 1      }    },    "truncated": true,    "warnings": [      "string"    ],    "would_fire": {      "events": [        {          "event": "LoanActivatedEvent",          "step": "a1"        }      ],      "jobs": [        {          "count": 1,          "job_type": "loan_accrual",          "step": "a1"        }      ]    },    "writes": [      {        "count": 42,        "ids": [          "string"        ],        "job_types": [          "loan_accrual"        ],        "op": "insert",        "step": "e1",        "table": "accounts"      }    ]  },  "meta": {    "api_version": "2026-04-23",    "cursor": {      "has_more": true,      "next": "eyJpZCI6ICJhYmMifQ=="    },    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",    "total_count": 1234  }}
POST
/v1/plans/sessions/{session_id}/undo

Undoes every committed run of a session (the session_id given at commit) that you can undo, newest first, in one transaction: a conflict or blocker on any run refuses them all. Runs already undone, and failed runs, are skipped, so repeating the call answers 200 with no runs. A session with no runs you can see answers PLAN_NOT_FOUND. Each run is undone as POST /v1/plans/{id}/undo describes.

Required scope: plans:commit

Error codes: INVALID_IDEMPOTENCY_KEY, IDEMPOTENCY_CONFLICT, PLAN_NOT_FOUND, PLAN_UNDO_CONFLICT, PLAN_UNDO_BLOCKED

Authorization

access-token
headerAuthorizationBearer <token>

Path Parameters

session_id*string

Header Parameters

Idempotency-Key?string

Client-chosen key that makes this mutation safe to retry. Optional — a request without one is processed normally, with no replay protection. Reusing a key with the same body replays the original response for ~24 hours; reusing it with a different body returns IDEMPOTENCY_CONFLICT.

Match^[A-Za-z0-9_-]{1,255}$
Lengthlength <= 255

Response Body

application/json
  1. response
data*
meta*
curl -X POST 'https://api.acreum.io/v1/plans/sessions/string/undo'
{  "data": {    "runs": [      {        "archived": [          {            "ids": [              "string"            ],            "table": "properties"          }        ],        "compensated": [          {            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",            "kind": "capital_contribution"          }        ],        "deleted": [          {            "ids": [              "string"            ],            "table": "properties"          }        ],        "kept": [          {            "ids": [              "string"            ],            "table": "properties"          }        ],        "restored": [          {            "ids": [              "string"            ],            "table": "properties"          }        ],        "run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",        "undo_mode": "clean",        "voided": [          {            "document_id": "b792e8ae-2cb4-4209-85b9-32be4c2fcdd6",            "moved_to_current_period": true          }        ]      }    ],    "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82"  },  "meta": {    "api_version": "2026-04-23",    "cursor": {      "has_more": true,      "next": "eyJpZCI6ICJhYmMifQ=="    },    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",    "total_count": 1234  }}

Get a plan run

GET
/v1/plans/{id}

One plan run in your organization, with the plan as submitted and the stored report. A run that does not exist, belongs to another organization, or (for a legal-entity-scoped principal) was made by another principal, answers PLAN_NOT_FOUND.

Required scope: plans:preview

Error codes: PLAN_NOT_FOUND, VALIDATION_FAILED

Authorization

access-token
headerAuthorizationBearer <token>

Path Parameters

id*string

Response Body

application/json
  1. response
data*
meta*
curl -X GET 'https://api.acreum.io/v1/plans/string'
{  "data": {    "created_at": "2019-08-24T14:15:22Z",    "description": "string",    "fingerprint": "sha256:9f2c…",    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "mode": "preview",    "plan": {},    "principal_id": "string",    "principal_kind": "user",    "released_at": "2019-08-24T14:15:22Z",    "report": {},    "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82",    "status": "previewed",    "undo_mode": "clean",    "undone_at": "2019-08-24T14:15:22Z"  },  "meta": {    "api_version": "2026-04-23",    "cursor": {      "has_more": true,      "next": "eyJpZCI6ICJhYmMifQ=="    },    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",    "total_count": 1234  }}
POST
/v1/plans/{id}/release

Releases a committed run: its status becomes released and released_at is set (kept when already set). Committed runs start released until hold ships, so for now this confirms the status. An undone or failed run answers 409 PLAN_NOT_HELD.

Required scope: plans:release

Error codes: INVALID_IDEMPOTENCY_KEY, IDEMPOTENCY_CONFLICT, PLAN_NOT_FOUND, PLAN_NOT_HELD

Authorization

access-token
headerAuthorizationBearer <token>

Path Parameters

id*string

Header Parameters

Idempotency-Key?string

Client-chosen key that makes this mutation safe to retry. Optional — a request without one is processed normally, with no replay protection. Reusing a key with the same body replays the original response for ~24 hours; reusing it with a different body returns IDEMPOTENCY_CONFLICT.

Match^[A-Za-z0-9_-]{1,255}$
Lengthlength <= 255

Response Body

Possible error codes: INVALID_IDEMPOTENCY_KEY

application/json
  1. response
code*string
detail*string
errors?array<>
instance*string
next_action?string

What the caller does next. Sent only by codes that declare it (the PLAN_* codes).

Value in"fix_step""re_preview""retry_later""split_plan""use_plan_mode""release_first""contact_operator"
request_id*string
retryable?boolean

Whether the same request can succeed unchanged later. Sent only by codes that declare it (the PLAN_* codes).

status*number
title*string
type*string
curl -X POST 'https://api.acreum.io/v1/plans/string/release'
{  "code": "DOCUMENT_ALREADY_POSTED",  "detail": "Document doc_01 is already posted.",  "errors": [    {      "code": "INVALID_VALUE",      "field": "amount",      "message": "must be > 0"    }  ],  "instance": "/v1/documents/doc_01/post",  "next_action": "fix_step",  "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",  "retryable": true,  "status": 409,  "title": "Document already posted",  "type": "https://docs.acreum.io/errors/DOCUMENT_ALREADY_POSTED"}

Get a plan run's report

GET
/v1/plans/{id}/report

The run's stored report, in the shape the preview or commit answered. The stored report is capped (truncated: true says a cap cut something). With full=true, a committed run answers with writes rebuilt without the cap from the rows it persisted; a preview keeps nothing, so it answers the stored report unchanged, and so does a run that failed.

Required scope: plans:preview

Error codes: PLAN_NOT_FOUND, VALIDATION_FAILED

Authorization

access-token
headerAuthorizationBearer <token>

Path Parameters

id*string

Query Parameters

full?boolean

For a committed run, rebuild writes without the caps from the rows the run persisted (every id listed). A preview, and a run that failed, answer the stored report unchanged.

Response Body

application/json
  1. response
data*
meta*
curl -X GET 'https://api.acreum.io/v1/plans/string/report'
{  "data": {    "committed": true,    "diff_summary": [      "e1: create legal entity 'Acme Holdings LLC' (+42 accounts)"    ],    "fingerprint": "sha256:9f2c…",    "journal_entries": [      {        "entry_date": "2019-08-24",        "journal_entry_id": "string",        "legal_entity_id": "string",        "lines": [          {            "account_id": "string",            "credit": "1234.50",            "debit": "1234.50"          }        ],        "source_type": "string",        "step": "string",        "total_credit": "1234.50",        "total_debit": "1234.50"      }    ],    "mode": "preview",    "plan_id": "string",    "scheduled_effects": [      {        "acts_on": {          "count": 1,          "ids": [            "string"          ],          "table": "loans"        },        "handler": "loan_rolling_window",        "next_run_at": "2019-08-24T14:15:22Z"      }    ],    "steps": [      {        "blocked_by": [          "string"        ],        "duration_ms": 12,        "error": {          "code": "VALIDATION_FAILED",          "detail": "maturity_date must be after start_date",          "next_action": "fix_step",          "pointer": "/steps/3/body/maturity_date",          "retryable": false        },        "http_status": 201,        "index": 0,        "reason": "blocked",        "ref": "e1",        "resource": {          "id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",          "table": "legal_entities"        },        "response": {},        "status": "ok"      }    ],    "summary": {      "error": 1,      "first_error": {        "code": "VALIDATION_FAILED",        "detail": "maturity_date must be after start_date",        "next_action": "fix_step",        "pointer": "/steps/3/body/maturity_date",        "retryable": false,        "step": "l1"      },      "journal_total_debit": "1234.50",      "ok": 3,      "skipped": 1,      "tables_touched": {        "accounts": 42,        "legal_entities": 1      }    },    "truncated": true,    "warnings": [      "string"    ],    "would_fire": {      "events": [        {          "event": "LoanActivatedEvent",          "step": "a1"        }      ],      "jobs": [        {          "count": 1,          "job_type": "loan_accrual",          "step": "a1"        }      ]    },    "writes": [      {        "count": 42,        "ids": [          "string"        ],        "job_types": [          "loan_accrual"        ],        "op": "insert",        "step": "e1",        "table": "accounts"      }    ]  },  "meta": {    "api_version": "2026-04-23",    "cursor": {      "has_more": true,      "next": "eyJpZCI6ICJhYmMifQ=="    },    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",    "total_count": 1234  }}
POST
/v1/plans/{id}/undo

Undoes a committed run in one transaction, all-or-nothing. Allowed while the run is held, and for now also released (until hold ships). Only the principal that committed the run, or a caller holding plans:release (never a plan-only key or a legal-entity-scoped or security-group-restricted principal), can undo it; any other run id answers PLAN_NOT_FOUND.

The run's captured rows are walked newest first. The answer's undo_mode says which of two ways it went:

  • clean: the run posted nothing to the ledger. A row it created is deleted, an existing row it changed is put back as it was before the run, and a row it deleted is re-inserted (listed under restored).
  • compensating: the run posted to the ledger, applied a credit, or created a loan hedge (a hedge create always undoes this way, even a swap with no premium, so its settlement check runs). Each posting is reversed through its module's own reversal, newest first: a capital contribution is reversed, a distribution declaration undone, a credit memo or vendor credit un-applied (all listed under compensated, with the documents they void), and any other posted document voided through the normal void path (listed under voided). Each reversal lands in the ledger and both entries stay. When the original's period is closed or locked, the reversal is dated into the current open period (voided[].moved_to_current_period); with no open period the undo is refused (see below, cause NO_OPEN_PERIOD_FOR_CORRECTION). A row the ledger still references is retired instead of deleted and listed under archived: a loan becomes cancelled, a legal entity inactive, a party or contact is_active = false, any other table status = 'archived' where it allows it. A row that cannot be retired is left as it is and listed under kept. Changed rows are put back and deleted rows re-inserted as above.

A background job the run queued is deleted while it is still pending. Once it has finished it stays, listed under kept, and the rows it wrote are undone with the run (a job queued by a run runs as part of that run, so its writes are the run's).

Refusals, each leaving everything as it was: 409 PLAN_UNDO_CONFLICT when something outside the run changed (or removed) a row since, or took the key of a row undo would re-insert, naming the row; 409 PLAN_UNDO_BLOCKED when a row the run created is referred to by something outside the run (a loan included, before it is cancelled), when a job the run queued is running right now, or when a journal entry the run posted is still unreversed after the voids, with each blocking table, ids and the plan run that created them in context.blockers; 409 PLAN_UNDO_BLOCKED also when a module's reversal refuses (a payment applied since, a reconciled document, a submitted payment run), with the module's own code in context.cause, or when the run only posted a document or activated a loan that existed before it (create and post, or create and activate, in the same plan); 409 PLAN_UNDO_BLOCKED also when the run inserted capital_events that no module reversal of the run accounts for, with context: { table: 'capital_events', id, blockers: [], reason: 'no_compensator' }, and when a loan hedge the run created has settlement rows written since outside the run (an edit of its terms), named in context.blockers; and 409 PLAN_NOT_HELD when the run is not held or released (undoing it again, for one). Audit rows stay. The run ends undone.

Required scope: plans:commit

Error codes: INVALID_IDEMPOTENCY_KEY, IDEMPOTENCY_CONFLICT, PLAN_NOT_FOUND, PLAN_NOT_HELD, PLAN_UNDO_CONFLICT, PLAN_UNDO_BLOCKED

Authorization

access-token
headerAuthorizationBearer <token>

Path Parameters

id*string

Header Parameters

Idempotency-Key?string

Client-chosen key that makes this mutation safe to retry. Optional — a request without one is processed normally, with no replay protection. Reusing a key with the same body replays the original response for ~24 hours; reusing it with a different body returns IDEMPOTENCY_CONFLICT.

Match^[A-Za-z0-9_-]{1,255}$
Lengthlength <= 255

Response Body

application/json
  1. response
data*
meta*
curl -X POST 'https://api.acreum.io/v1/plans/string/undo'
{  "data": {    "archived": [      {        "ids": [          "string"        ],        "table": "properties"      }    ],    "compensated": [      {        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",        "kind": "capital_contribution"      }    ],    "deleted": [      {        "ids": [          "string"        ],        "table": "properties"      }    ],    "kept": [      {        "ids": [          "string"        ],        "table": "properties"      }    ],    "restored": [      {        "ids": [          "string"        ],        "table": "properties"      }    ],    "run_id": "dded282c-8ebd-44cf-8ba5-9a234973d1ec",    "undo_mode": "clean",    "voided": [      {        "document_id": "b792e8ae-2cb4-4209-85b9-32be4c2fcdd6",        "moved_to_current_period": true      }    ]  },  "meta": {    "api_version": "2026-04-23",    "cursor": {      "has_more": true,      "next": "eyJpZCI6ICJhYmMifQ=="    },    "request_id": "018f0b3d-2b1e-7c8a-9d4b-1a2b3c4d5e6f",    "total_count": 1234  }}