# Reverse Ledger Entries
Source: https://fragment.dev/guides/reverse-ledger-entries
[Documentation index](https://fragment.dev/llms.txt)
To correct mistakes, you can reverse a Ledger Entry that you've posted to Fragment. Reversing a Ledger Entry posts a new Ledger Entry that offsets the original Ledger Entry.
[Visual: reversals. View on the HTML page.](https://fragment.dev/guides/reverse-ledger-entries)
## Reversing Entries
Call the `reverseLedgerEntry` mutation to reverse a posted Ledger Entry:
```graphql title="reverseLedgerEntry mutation" expandable
mutation ReverseLedgerEntry(
$id: ID!
) {
reverseLedgerEntry(
id: $id
) {
__typename
... on ReverseLedgerEntryResult {
reversingLedgerEntry {
ik
id
type
posted
created
reverses {
id
created
}
reversalPosition
}
reversedLedgerEntry {
ik
id
type
posted
created
reversedBy {
id
created
}
reversalPosition
reversedAt
}
isIkReplay
}
... on Error {
code
message
}
}
}
```
```json title="reverseLedgerEntry variables"
{
"id": ""
}
```
You cannot reverse a Ledger Entry using `ik` because the reversing, reversed, and any subsequent reposting of the Ledger Entry will all share the same `ik`. This ensures all versions of a Ledger Entry are [idempotent](https://fragment.dev/markdown/api-reference/ledger-overview.md#idempotency). Attempting to reverse a reversing Ledger Entry will return `isIkReplay: true`.
The new, reversing, Ledger Entry will have:
- Ledger Lines of the opposite `amount` values in the same currency as the original Ledger Entry.
- The same `posted` timestamp as the original Ledger Entry. This ensures that the net balance change at the `posted` timestamp is 0.
- A unique `created` timestamp, set to the time of posting.
- The same Tags and Groups as the original Ledger Entry.
- A `reverses` field that points to the original Ledger Entry.
- A `reversalPosition` value of one greater than the original Ledger Entry. This position value is 1 indexed.
The reversed Ledger Entry will be updated to include:
- A `reversedBy` field that points to the reversing Ledger Entry.
- A `reversedAt` timestamp that is the `created` timestamp of the reversing Ledger Entry.
After calling `reverseLedgerEntry`, both the reversing and reversed Ledger Entries are immutable and can no longer be updated using `updateLedgerEntry`.
## Reposting Entries
Once a Ledger Entry has been reversed, it can be reposted by using the same `ik` value. Any Entry Type can be used for the reposted Ledger Entry. To do so, simply use the `addLedgerEntry` or `reconcileTx` mutation.
```graphql title="addLedgerEntry mutation" expandable
mutation AddLedgerEntry(
$ik: SafeString!
$entry: LedgerEntryInput!
) {
addLedgerEntry(
ik: $ik,
entry: $entry
) {
__typename
... on AddLedgerEntryResult {
entry {
type
created
posted
reversalPosition
}
lines {
amount
key
description
account {
path
}
}
}
... on Error {
code
message
}
}
}
```
```json title="addLedgerEntry variables"
{
"ik": "add-ledger-entry",
"entry": {
"ledger": {
"ik": "quickstart-ledger"
},
"type": "user_funds_account",
"posted": "1234-01-01T01:01:01",
"parameters": {
"user_id": "testing-user",
"funding_amount": "400"
}
}
}
```
```graphql title="reconcileTx mutation" expandable
mutation ReconcileTx(
$entry: LedgerEntryInput!
) {
reconcileTx(
entry: $entry
) {
... on ReconcileTxResult {
entry {
type
created
posted
reversalPosition
}
lines {
amount
key
description
account {
path
}
}
}
... on Error {
code
message
}
}
}
```
```json title="reconcileTx variables"
{
"entry": {
"type": "user_funding",
"ledger": {
"ik": "quickstart-ledger"
},
"parameters": {
"txId": "tx_12345",
"customerId": "customer-1"
}
}
}
```
The newly posted Ledger Entry will have a `reversalPosition` value of one greater than the previous reversal Ledger Entry.
## Querying Reversals
Use the [ledgerEntryHistory](https://fragment.dev/markdown/api-reference/ledger-queries.md#ledgerentryhistory) query to get the full history of a Ledger Entry with reversals. [Lookups](https://fragment.dev/markdown/guides/query-data.md#ledger-entries-lookup) by IK for a reversing or reversed Ledger Entry will return a `ledger_entry_not_found` `BadRequestError`.
Additionally, Ledger Entries have a [`reversalHistory`](https://fragment.dev/markdown/api-reference/ledger-types.md#core-types-ledgerentry) field that returns a list of all Ledger Entries and their reversals that share an `ik`.
## Hidden Filter
Once a Ledger Entry has been reversed it is hidden from your list of Ledger Entries. For debugging, you can [query hidden Ledger Entries](https://fragment.dev/markdown/guides/query-data.md#ledger-entries-list-hidden).