Resolve a dispute for merchant
const url = 'http://localhost:8080/v1/operations/dispute_resolve_merchant.v1';const options = { method: 'POST', headers: { 'Idempotency-Key': 'pay-2026-11-14-0001', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"accounts":{"dispute_item":"2060:dsp-0001","merchant_balance":"2030:merch-coffee"},"amounts":{"amount":{"amount":"100.00","currency":"ETB"}}}'};
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/operations/dispute_resolve_merchant.v1 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: pay-2026-11-14-0001' \ --data '{ "accounts": { "dispute_item": "2060:dsp-0001", "merchant_balance": "2030:merch-coffee" }, "amounts": { "amount": { "amount": "100.00", "currency": "ETB" } } }'Books dispute_resolve_merchant.v1 (worked entries E24). The request binds each role to an account and gives each amount; the template turns it into one balanced entry, which the ledger posts in one transaction. The client decides whether the operation is allowed (ADR-0002); the ledger decides how it is booked.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”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
object
object
Greater than zero.
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.
Client references, copied into the entry, never used for accounting. At most 32 keys and 4096 bytes in all. The key template is reserved.
object
When the event happened, if the client knows (an offline payment). Informational: the entry is posted now, into the open period (INV-12).
Example
{ "accounts": { "dispute_item": "2060:dsp-0001", "merchant_balance": "2030:merch-coffee" }, "amounts": { "amount": { "amount": "100.00", "currency": "ETB" } }}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"}Conflict
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
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
missing_amount (2004)
{ "type": "urn:mezgeb:problem:missing_amount", "title": "An amount the template needs is missing", "status": 422, "code": "missing_amount", "rule": 2004, "detail": "An amount the template needs is missing.", "name": "amount", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}unexpected_amount (2005)
{ "type": "urn:mezgeb:problem:unexpected_amount", "title": "The template does not use this amount", "status": 422, "code": "unexpected_amount", "rule": 2005, "detail": "The template does not use this amount.", "name": "tip", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}non_positive_amount (2006)
{ "type": "urn:mezgeb:problem:non_positive_amount", "title": "An amount is not positive", "status": 422, "code": "non_positive_amount", "rule": 2006, "detail": "An amount is not positive.", "name": "merchant_fee", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}missing_account (2007)
{ "type": "urn:mezgeb:problem:missing_account", "title": "A role the template books has no account", "status": 422, "code": "missing_account", "rule": 2007, "detail": "A role the template books has no account.", "role": "payee_wallet", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}unexpected_account (2008)
{ "type": "urn:mezgeb:problem:unexpected_account", "title": "The template has no such role", "status": 422, "code": "unexpected_account", "rule": 2008, "detail": "The template has no such role.", "role": "fee_revenue", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}bound_account_not_found (2009)
{ "type": "urn:mezgeb:problem:bound_account_not_found", "title": "The account bound to a role does not exist", "status": 422, "code": "bound_account_not_found", "rule": 2009, "detail": "The account bound to a role does not exist.", "role": "payee_wallet", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}account_not_allowed (2010)
{ "type": "urn:mezgeb:problem:account_not_allowed", "title": "The account is not allowed for its role", "status": 422, "code": "account_not_allowed", "rule": 2010, "detail": "The account is not allowed for its role.", "role": "payer_wallet", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}same_account (2011)
{ "type": "urn:mezgeb:problem:same_account", "title": "Two roles are bound to the same account", "status": 422, "code": "same_account", "rule": 2011, "detail": "Two roles are bound to the same account.", "role": "payee_wallet", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}reserved_metadata (2012)
{ "type": "urn:mezgeb:problem:reserved_metadata", "title": "The metadata sets a reserved key", "status": 422, "code": "reserved_metadata", "rule": 2012, "detail": "The metadata sets a reserved key.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}amount_not_whole_balance (2014)
{ "type": "urn:mezgeb:problem:amount_not_whole_balance", "title": "The amount is not the item's whole balance", "status": 422, "code": "amount_not_whole_balance", "rule": 2014, "detail": "The amount is not the item's whole balance.", "role": "withdrawal_in_transit", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}account_not_new (2015)
{ "type": "urn:mezgeb:problem:account_not_new", "title": "The item account has already been used", "status": 422, "code": "account_not_new", "rule": 2015, "detail": "The item account has already been used.", "role": "pending_withdrawal", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}fee_exceeds_amount (2016)
{ "type": "urn:mezgeb:problem:fee_exceeds_amount", "title": "The fees are more than the amount", "status": 422, "code": "fee_exceeds_amount", "rule": 2016, "detail": "The fees are more than the amount.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}amount_currency_mismatch (2017)
{ "type": "urn:mezgeb:problem:amount_currency_mismatch", "title": "The amounts are in different currencies", "status": 422, "code": "amount_currency_mismatch", "rule": 2017, "detail": "The amounts are in different currencies.", "name": "payer_fee", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}amount_too_large (2018)
{ "type": "urn:mezgeb:problem:amount_too_large", "title": "An amount is too large", "status": 422, "code": "amount_too_large", "rule": 2018, "detail": "An amount is too large.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}missing_metadata (2019)
{ "type": "urn:mezgeb:problem:missing_metadata", "title": "A metadata key the template requires is missing", "status": 422, "code": "missing_metadata", "rule": 2019, "detail": "A metadata key the template requires is missing.", "name": "channel", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}invalid_metadata (2020)
{ "type": "urn:mezgeb:problem:invalid_metadata", "title": "A metadata value is not allowed", "status": 422, "code": "invalid_metadata", "rule": 2020, "detail": "A metadata value is not allowed.", "name": "channel", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}missing_refunded_entry (2021)
{ "type": "urn:mezgeb:problem:missing_refunded_entry", "title": "A refund must name the entry it refunds", "status": 422, "code": "missing_refunded_entry", "rule": 2021, "detail": "A refund must name the entry it refunds.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}unexpected_refunded_entry (2022)
{ "type": "urn:mezgeb:problem:unexpected_refunded_entry", "title": "Only a refund template names an entry to refund", "status": 422, "code": "unexpected_refunded_entry", "rule": 2022, "detail": "Only a refund template names an entry to refund.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}too_few_lines (1001)
{ "type": "urn:mezgeb:problem:too_few_lines", "title": "An entry needs at least 2 lines", "status": 422, "code": "too_few_lines", "rule": 1001, "detail": "An entry needs at least 2 lines.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}too_many_lines (1002)
{ "type": "urn:mezgeb:problem:too_many_lines", "title": "An entry has too many lines", "status": 422, "code": "too_many_lines", "rule": 1002, "detail": "An entry has too many lines.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}metadata_too_large (1003)
{ "type": "urn:mezgeb:problem:metadata_too_large", "title": "The metadata is too large", "status": 422, "code": "metadata_too_large", "rule": 1003, "detail": "The metadata is too large.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}amount_not_positive (1004)
{ "type": "urn:mezgeb:problem:amount_not_positive", "title": "A line amount is not positive", "status": 422, "code": "amount_not_positive", "rule": 1004, "detail": "A line amount is not positive.", "line": 1, "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}account_not_found (1005)
{ "type": "urn:mezgeb:problem:account_not_found", "title": "A line names an account that does not exist", "status": 422, "code": "account_not_found", "rule": 1005, "detail": "A line names an account that does not exist.", "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"}currency_mismatch (1007)
{ "type": "urn:mezgeb:problem:currency_mismatch", "title": "A line's currency is not its account's", "status": 422, "code": "currency_mismatch", "rule": 1007, "detail": "A line's currency is not its account's.", "line": 1, "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}duplicate_line (1008)
{ "type": "urn:mezgeb:problem:duplicate_line", "title": "Two lines share an account and side", "status": 422, "code": "duplicate_line", "rule": 1008, "detail": "Two lines share an account and side.", "line": 2, "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}amount_overflow (1009)
{ "type": "urn:mezgeb:problem:amount_overflow", "title": "The amounts are too large", "status": 422, "code": "amount_overflow", "rule": 1009, "detail": "The amounts are too large.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}unbalanced (1010)
{ "type": "urn:mezgeb:problem:unbalanced", "title": "Debits and credits differ", "status": 422, "code": "unbalanced", "rule": 1010, "detail": "ETB debits 10000 ≠ credits 9999.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}account_total_overflow (1011)
{ "type": "urn:mezgeb:problem:account_total_overflow", "title": "An account's totals would be too large", "status": 422, "code": "account_total_overflow", "rule": 1011, "detail": "An account's totals would be too large.", "line": 0, "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"}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.