Corrections
Goal: Correct a value without losing the original - and document why.
Corrections happen. The point is that every correction is documented, justified, and traceable, and a correction never edits the original: it is a new record that links to it. This is the digital version of "don't use white-out": you cross it out, write the correction next to it, and say why.
A correction is a record: the data before, the data after, the fields that changed, the reason, who made it and when. Corrections are kept in their own hash chain, in their own container, apart from the Activity Log's events. It does not edit the record it describes; the app or process that holds that record applies the change. Corrections stay in Provenance's storage, where a change after the fact shows up when the chain is verified, and where the storage's own immutability policy (Protected, or Locked once a person has locked it) holds them for their retention period. See the Compliance Matrix.
Where you make one
Corrections are made through the API, by the app that holds the records. There is no Amend button on a node
and no correction window in the workspace today. That is also why a correction needs a scope: the name of the
body of data it belongs to, such as a study. A correction always describes a change to a scope's data, so
ScopeKey is required.
You need Provenance set up first. Without it the correction routes are
refused with 503 PROVENANCE_NOT_PROVISIONED. A call with no identity behind it gets 401 first.
Make a correction
POST /ox-api/provenance/amendments, with a token the API accepts (see
Call the API from your app); the call has to be attributable to a person,
or it is refused with 401. The body:
| Field | What it is |
|---|---|
ScopeKey | The scope the correction belongs to. Required |
EntityType, EntityID | What was corrected, and which one. Required |
OriginalRecord | The whole record before the correction. Required |
AmendedRecord | The corrected record. Required |
ChangedFields | The paths of the fields that changed: at least one. Required |
ReasonCategory | One of the workspace's reasons (below). Required |
ReasonText | The justification in words. Required; it may be empty unless the workspace requires free text for every reason |
Name, Description | Optional |
Who made the correction, when, and its status are the server's, never yours. A body key the route does not read
is refused by name, with 400 UNKNOWN_BODY_KEY, never dropped. The answer is 201 with the stored record, with
its RecordID, PreviousHash and Hash.
Reasons
A reason has to be one of the workspace's list. Read it with GET /ox-api/provenance/reason-categories. Unless
the workspace has set its own, the list is:
| Reason | When |
|---|---|
data-entry-error | A typo or a wrong value entered |
transcription-error | Misread from paper or an instrument |
equipment-malfunction | A sensor failure or a device error |
protocol-deviation | A change of procedure or workflow |
recalculation | A formula or unit change |
delayed-entry | Added later from notes |
other | Say what happened in the justification |
Any other value is refused with 400 "Reason category is not configured for this workspace.", and the answer lists
the ones allowed. The list, and whether free text is required, are set by a proposal: the Provenance window has no
control for them. To make one, ask Thinky, or have an agent you bring send it through the OpenX MCP server's
manage_proposals tool for the provenance kind; a person then accepts it in Proposals. See
Provenance.
Optional: require a second approver
Turn this on when a correction should not take effect on one person's say-so. It is a Provenance setting too, set by a proposal. With it on, the flow becomes:
- Someone submits the correction. Its status is
pending. With it off, a correction isapprovedas soon as it is stored. - A second person approves it (
POST /ox-api/provenance/amendments/{id}/approve,scopeKeyon the query string, no body) or rejects it (POST /ox-api/provenance/amendments/{id}/reject, with aRejectionReasonthat is required and not blank). - The approver cannot be the person who submitted it. The server checks this, whatever the app shows:
403 "Maker/checker: the approver cannot be the amendment author." The server checks the status of the record
whose id you give, and refuses with 409 "Amendment is not pending" when that record is not
pending: an id that belongs to an approval or rejection record. An unknown id is 404 "Amendment not found". - A correction is decided once. Approving or rejecting one that already has a decision is refused with 409 "Amendment was already approved; the first decision stands." (or "rejected"). If two decisions arrive at the same moment, one is recorded and the other gets 409 "The amendment log kept changing while this decision was being recorded; try again."; trying again then gets the already-decided answer.
An approval or a rejection is a new record that carries the new status. The first record is not rewritten. Both approved and rejected corrections stay in the chain; a rejected one documents that a change was proposed and why it was declined.
Read the chain
GET /ox-api/provenance/amendments/chain?scopeKey=...&entityId=... returns every correction record for one
entity, approvals and rejections included (each is its own record), oldest first, in the order of their chain
links rather than by any timestamp a caller sent. entityId is
required. GET /ox-api/provenance/amendments finds corrections by entityId, entityType, reasonCategory,
amendedBy, status and dates.
A submitted correction keeps its own Status of pending for good, because its approval or rejection is a new
record. So the list tells you how it was decided: a decided correction carries Decision (approved or
rejected) and DecisionRecordID (the record of that decision, the first one, which stands). status=pending
lists only corrections nobody has decided yet, and status=approved or status=rejected finds the decided ones
along with their decision records.
original -> correction 1 -> correction 2
(kept) (links back) (links back)
Each link is part of a SHA-256 chain, so an insertion, a removal or a reorder is detectable. The verify route
(POST /ox-api/provenance/events/verify) checks the Activity Log's events unless you give it
target=DomainAmendments on the query string and the ScopeKey in the body. The records live under the same immutability policy as the rest of
Provenance.
Good habits
- Pick the most specific reason; keep
otherfor what truly fits nowhere. - Write a justification an auditor who was not there would understand.
- Put the real before and after in
OriginalRecordandAmendedRecord; the diff you give is the diff that is kept. - Export the chain on a schedule if you keep an archive.
Next steps
- See the whole record -> Activity log
- The endpoints in full -> REST API: Change history
- A correction stuck pending? -> Corrections troubleshooting
On fathym.com: OpenX provenance →