Reverse an entry
const url = 'http://localhost:8080/v1/entries/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/reversal';const options = { method: 'POST', headers: { 'Idempotency-Key': 'pay-2026-11-14-0001', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"reason":"booking_error","note":"Credited to the wrong wallet; see ticket OPS-118."}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/v1/entries/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/reversal \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: pay-2026-11-14-0001' \ --data '{ "reason": "booking_error", "note": "Credited to the wrong wallet; see ticket OPS-118." }'Posts the exact mirror of an entry posted by mistake (INV-14). The requester is the authenticated caller. A refunded entry, a refund or a reversal cannot be reversed; correct those with an adjustment.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”An entry ID.
The entry.
Header Parameters
Section titled “Header Parameters”Makes a write safe to retry. The same key with the same request returns the original result; with a different request, 409 idempotency_key_reused. Keys are per client and kept for at least 30 days (ADR-0008).
Request Bodyrequired
Section titled “Request Bodyrequired”object
Example
{ "reason": "booking_error", "note": "Credited to the wrong wallet; see ticket OPS-118."}Responses
Section titled “Responses”Replayed
object
An entry ID.
Posting order (INV-12).
When the event happened, if the client knows (an offline payment). Informational: the entry is posted now, into the open period (INV-12).
object
An account ID.
An amount with its currency (ADR-0005, ADR-0009).
object
A decimal amount, with at most the currency’s minor-unit digits (ETB: 2). Never a JSON number.
An ISO 4217 code the ledger supports.
object
object
The signed ledger receipt (spec §7.2, INV-26): proof, verifiable with the public key alone, that the ledger recorded this entry at this position of its hash chain. null only for entries posted before the chain began.
The entry’s link in the hash chain, signed. Verify the signature over mezgeb.receipt.v1\0, the position (8 bytes, big-endian), the entry ID (16 bytes) and the hash, with the key key_id from /v1/keys.
object
An entry ID.
A SHA-256 hash, in lower-case hex.
A SHA-256 hash, in lower-case hex.
Example
{ "kind": "standard", "template": "merchant_payment.v1", "lines": [ { "side": "debit", "amount": { "amount": "39.20", "currency": "ETB" } } ]}Headers
Section titled “Headers”true when the response repeats an earlier request with the same key.
Posted
object
An entry ID.
Posting order (INV-12).
When the event happened, if the client knows (an offline payment). Informational: the entry is posted now, into the open period (INV-12).
object
An account ID.
An amount with its currency (ADR-0005, ADR-0009).
object
A decimal amount, with at most the currency’s minor-unit digits (ETB: 2). Never a JSON number.
An ISO 4217 code the ledger supports.
object
object
The signed ledger receipt (spec §7.2, INV-26): proof, verifiable with the public key alone, that the ledger recorded this entry at this position of its hash chain. null only for entries posted before the chain began.
The entry’s link in the hash chain, signed. Verify the signature over mezgeb.receipt.v1\0, the position (8 bytes, big-endian), the entry ID (16 bytes) and the hash, with the key key_id from /v1/keys.
object
An entry ID.
A SHA-256 hash, in lower-case hex.
A SHA-256 hash, in lower-case hex.
Example
{ "id": "0192f3c4-0000-7000-8000-000000000007", "sequence": 8, "kind": "standard", "template": "merchant_payment.v1", "period_id": 12, "recorded_at": "2026-11-14T09:30:12.418205Z", "event_time": null, "lines": [ { "account": "0192f3c4-0000-7000-8000-000000000002", "side": "debit", "amount": { "amount": "100.00", "currency": "ETB" } }, { "account": "0192f3c4-0000-7000-8000-000000000004", "side": "credit", "amount": { "amount": "98.00", "currency": "ETB" } }, { "account": "0192f3c4-0000-7000-8000-000000000005", "side": "credit", "amount": { "amount": "2.00", "currency": "ETB" } } ], "metadata": { "template": "merchant_payment.v1", "channel": "qr", "order": "order-81" }, "reverses": null, "refunds": null, "authorization": null, "receipt": null}Headers
Section titled “Headers”The URL of the created resource.
Bad request
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
invalid_request
{ "type": "urn:mezgeb:problem:invalid_request", "title": "The request is malformed", "status": 400, "code": "invalid_request", "detail": "The request is malformed.", "errors": [ { "pointer": "/amounts/amount", "detail": "\"10.255\" has more decimal places than ETB allows" } ], "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}idempotency_key_required
{ "type": "urn:mezgeb:problem:idempotency_key_required", "title": "An Idempotency-Key header is required", "status": 400, "code": "idempotency_key_required", "detail": "An Idempotency-Key header is required.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Unauthenticated
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
unauthenticated
{ "type": "urn:mezgeb:problem:unauthenticated", "title": "Authentication is required", "status": 401, "code": "unauthenticated", "detail": "Authentication is required.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Forbidden
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
forbidden
{ "type": "urn:mezgeb:problem:forbidden", "title": "The caller may not do this", "status": 403, "code": "forbidden", "detail": "The caller may not do this.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Not found
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
not_found
{ "type": "urn:mezgeb:problem:not_found", "title": "Not found", "status": 404, "code": "not_found", "detail": "Not found.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}The entry cannot be reversed
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
already_reversed
{ "type": "urn:mezgeb:problem:already_reversed", "title": "The entry is already reversed", "status": 409, "code": "already_reversed", "detail": "The entry is already reversed.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}cannot_reverse_reversal
{ "type": "urn:mezgeb:problem:cannot_reverse_reversal", "title": "A reversal cannot be reversed", "status": 409, "code": "cannot_reverse_reversal", "detail": "A reversal cannot be reversed.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}refunded_entry_cannot_be_reversed
{ "type": "urn:mezgeb:problem:refunded_entry_cannot_be_reversed", "title": "The entry has refunds", "status": 409, "code": "refunded_entry_cannot_be_reversed", "detail": "The entry has refunds.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}cannot_reverse_refund
{ "type": "urn:mezgeb:problem:cannot_reverse_refund", "title": "A refund cannot be reversed", "status": 409, "code": "cannot_reverse_refund", "detail": "A refund cannot be reversed.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}idempotency_key_reused
{ "type": "urn:mezgeb:problem:idempotency_key_reused", "title": "The idempotency key was used for a different request", "status": 409, "code": "idempotency_key_reused", "detail": "Idempotency key \"pay-0001\" was already used for a different request.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Refused
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
reason_not_allowed
{ "type": "urn:mezgeb:problem:reason_not_allowed", "title": "The reason is unknown or not for this kind of entry", "status": 422, "code": "reason_not_allowed", "detail": "The reason is unknown or not for this kind of entry.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}insufficient_funds (1012)
{ "type": "urn:mezgeb:problem:insufficient_funds", "title": "An account would go below zero", "status": 422, "code": "insufficient_funds", "rule": 1012, "detail": "Line 0 would take account 0192f3c4-0000-7000-8000-000000000002 below zero.", "line": 0, "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}account_not_open (1006)
{ "type": "urn:mezgeb:problem:account_not_open", "title": "An account is not open", "status": 422, "code": "account_not_open", "rule": 1006, "detail": "An account is not open.", "line": 0, "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}account_is_held
{ "type": "urn:mezgeb:problem:account_is_held", "title": "The account is a hold's held account", "status": 422, "code": "account_is_held", "detail": "The account is a hold's held account.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Rate limited
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
rate_limited
{ "type": "urn:mezgeb:problem:rate_limited", "title": "Too many requests", "status": 429, "code": "rate_limited", "detail": "Too many requests.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Headers
Section titled “Headers”Seconds to wait before retrying.
Internal error
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
internal_error
{ "type": "urn:mezgeb:problem:internal_error", "title": "Internal error", "status": 500, "code": "internal_error", "detail": "Internal error.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}template_defect (2013)
{ "type": "urn:mezgeb:problem:template_defect", "title": "The template books a role it does not declare", "status": 500, "code": "template_defect", "rule": 2013, "detail": "The template books a role it does not declare.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Unavailable
RFC 9457 Problem Details, with Mezgeb’s stable code.
object
urn:mezgeb:problem:<code>.
This occurrence: urn:uuid:<request id>.
A stable error code. Never renumbered or reused; see docs/api/errors.md.
The posting rule (1001–1012) or template rule (2001–2022) that refused the request.
The zero-based line of the entry at fault.
The template role at fault.
The amount or metadata key at fault.
For invalid_request: each field at fault.
object
A JSON Pointer into the request body.
Examples
busy
{ "type": "urn:mezgeb:problem:busy", "title": "The accounts are busy; retry later", "status": 503, "code": "busy", "detail": "An account stayed locked longer than the lock timeout. Retry after the Retry-After interval.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}contention
{ "type": "urn:mezgeb:problem:contention", "title": "Conflicted with concurrent operations; retry later", "status": 503, "code": "contention", "detail": "Conflicted with concurrent operations; retry later.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}no_open_period
{ "type": "urn:mezgeb:problem:no_open_period", "title": "No accounting period is open", "status": 503, "code": "no_open_period", "detail": "No accounting period is open.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}Headers
Section titled “Headers”Seconds to wait before retrying.