Skip to content

Reverse a posted entry and post what it should have said, in one transaction

POST
/v1/entities/{entity_id}/entries/{entry_id}/correct
curl --request POST \
--url https://example.com/v1/entities/example/entries/example/correct \
--header 'Content-Type: application/json' \
--data '{ "reason": "example", "replacement": { "legs": [ { "account": "example", "commodity": "example", "amount": "-12.00", "memo": "example", "tax_code": "example" } ], "dt": "example", "narration": "example", "origin": "example", "code": "", "comment": "", "tags": [ [ "example" ] ] }, "dt": "example", "narration": "example" }'

Reverse a posted entry and post what it should have said, linked to the original (issue 0006).

reverse withdraws a booking; this restates it, which is the ordinary case. An entry on the wrong account, for the wrong amount or on the wrong date usually needs replacing, not just withdrawing.

Both halves land in one transaction, so there is no moment at which the original is reversed and nothing stands in its place, and a concurrent report cannot see the books with the entry missing. The replacement is an ordinary entry (account paths and exact decimal amounts) and goes through the same balance, account, precision and period-lock rules as any other posting. A correction that would land in a closed month is refused; reopen the month to fix it.

For a statement line, POST /lines/{id}/reexplain does this and the re-explanation together, so the line is never momentarily unexplained.

entry_id
required
Entry Id
string
entity_id
required
Entity Id

The entity this path is relative to

string

The entity this path is relative to

Media typeapplication/json
EntryCorrectionSubmission

Reverse a posted entry and post what it should have said, in one transaction.

A reversal says only “this was wrong”. A correction says what was meant, which is the ordinary case: an entry booked to the wrong account, for the wrong amount or on the wrong date is restated, not just withdrawn. Doing both in one command means the books never pass through a state, visible to a concurrent report, where the original is reversed and nothing stands in its place.

Nothing is edited. The original stays posted and in the sums, an exact mirror is posted beside it, and the replacement is posted as its own entry. All three carry the actor that wrote them, and one entry.corrected audit action records why.

object
reason
required
Reason

Why the original was wrong; recorded verbatim

string
>= 1 characters
replacement
required
EntryReplacement

What the corrected entry should have said: the same shape as writing one, minus the reason.

There is one reason for the whole correction, and it belongs to the correction, not the replacement. A separate reason on the replacement would invite two different sentences about one act.

object
legs
required
Legs

Every leg of the replacement; nets to zero per commodity

Array<object>
>= 2 items
EntryLeg

One leg of a manual journal entry: an account, a currency and a signed amount.

Unlike a line booking’s legs, these are the whole entry. No cash leg is supplied for you, because there is no statement line behind this entry. Two legs or more, netting to zero per commodity.

object
account
required
Account

Account path (preferred) or stable account id

string
>= 1 characters <= 255 characters
commodity
required
Commodity
string
>= 1 characters <= 64 characters
amount
required
Amount

Signed decimal amount in whole commodity units; never a JSON number

string
memo
Any of:
string
<= 4096 characters
tax_code
Any of:
string
<= 255 characters
dt
required
Dt

The replacement’s date, YYYY-MM-DD

string
narration
required
Narration
string
>= 1 characters <= 4096 characters
origin
Any of:
string
code
Code

Hledger tcode

string
"" <= 255 characters
comment
Comment
string
"" <= 4096 characters
tags
Any of:
Array<Array<string>>
dt
Any of:
string
narration
Any of:
string

Successful Response

Media typeapplication/json
EntryCorrection
object
entity_id
required
Entity Id
string
legal_name
required
Legal Name
string
base_currency
required
Base Currency
string
snapshot_seq
required
Snapshot Seq
integer
correction_id
required
Correction Id
string
original_id
required
Original Id
string
mirror_id
required
Mirror Id
string
replacement_id
required
Any of:
string
audit_seq
required
Audit Seq

The entry.corrected audit action’s event sequence

integer
entry
required
Entry

The mirror that was posted

object
id
required
Id
string
dt
required
Dt
string
narration
required
Narration
string
status
required
Status
string
origin
required
Origin
string
version
required
Version
integer
code
required
Code
string
comment
required
Comment
string
tags
required
Tags
Array<Array<string>>
created_at
required
Created At
string
created_by
required
Created By
string
postings
required
Postings
Array<object>
Posting
object
id
required
Id
string
seq
required
Seq
integer
account_id
required
Account Id
string
account_path
required
Account Path
string
commodity
required
Commodity
string
amount_micros
required
Amount Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
memo
required
Any of:
string
tax_code
required
Any of:
string
links
required
Links
object
key
additional properties
string
replacement
required
Entry

The entry that now stands in the original’s place

object
id
required
Id
string
dt
required
Dt
string
narration
required
Narration
string
status
required
Status
string
origin
required
Origin
string
version
required
Version
integer
code
required
Code
string
comment
required
Comment
string
tags
required
Tags
Array<Array<string>>
created_at
required
Created At
string
created_by
required
Created By
string
postings
required
Postings
Array<object>
Posting
object
id
required
Id
string
seq
required
Seq
integer
account_id
required
Account Id
string
account_path
required
Account Path
string
commodity
required
Commodity
string
amount_micros
required
Amount Micros

Signed integer micro-units (millionths) as a base-10 string; never a JSON number.

string
/^-?(0|[1-9][0-9]*)$/
memo
required
Any of:
string
tax_code
required
Any of:
string
links
required
Links
object
key
additional properties
string
links
required
Links
object
key
additional properties
string

Example

{
"entry": {
"postings": [
{
"amount_micros": "-12000000"
}
]
},
"replacement": {
"postings": [
{
"amount_micros": "-12000000"
}
]
}
}

Bad Request

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Unauthorized

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Forbidden

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Not Found

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Conflict

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Precondition Failed

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Unprocessable Content

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Internal Server Error

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}

Service Unavailable

Media typeapplication/json
ErrorEnvelope
object
error
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
retryable
required
Retryable
boolean
details
required
Details
Array<object>
object
key
additional properties
any
request_id
Any of:
string
next_action
Any of:
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"retryable": true,
"details": [
{}
],
"request_id": "example",
"next_action": {}
}
}