API · Contract: openapi/mezgeb.v1.yaml
Every error is an RFC 9457 Problem Details document (application/problem+json)
with a stable code. Clients match on code, never on title or detail,
which may be reworded. A code is never renumbered, reused or removed; a new
rule gets a new code. Posting and template rules also carry their numeric
rule (crates/core/src/error.rs, crates/ops/src/error.rs), and fields
such as line, role or name that say exactly what was at fault.
The contract has a worked example of every code (components/examples),
and a test (crates/api/tests/openapi.rs) fails if a posting or template
rule has no code here.
"type" : " urn:mezgeb:problem:insufficient_funds " ,
"title" : " An account would go below zero " ,
"code" : " insufficient_funds " ,
"detail" : " Line 0 would take account 0192f3c4-0000-7000-8000-000000000002 below zero. " ,
"instance" : " urn:uuid:0192f3c4-0000-7000-8000-00000000abcd "
Code
HTTP
Rule
Meaning
Source
invalid_request
400
The request is malformed
request: bad JSON, an unknown field, a bad UUID, amount, currency or time
idempotency_key_required
400
An Idempotency-Key header is required
request: a write without Idempotency-Key
unauthenticated
401
Authentication is required
step 2.08: no token, or an invalid or expired one
forbidden
403
The caller may not do this
step 2.08: the token lacks the scope
not_found
404
Not found
an account, entry, hold, period, adjustment, device or voucher that does not exist, or that the caller may not see
idempotency_key_reused
409
The idempotency key was used for a different request
LedgerError::IdempotencyKeyReused
rate_limited
429
Too many requests
API gateway: per-client rate limit
internal_error
500
Internal error
LedgerError::Storage, or a template defect (TemplateError 2013)
not_implemented
501
Not implemented yet
a receipt of a voucher already returned: late receipts settle from step 2.13
busy
503
The accounts are busy; retry later
LedgerError::Busy (Retry-After)
contention
503
Conflicted with concurrent operations; retry later
LedgerError::Contention (Retry-After)
no_open_period
503
No accounting period is open
LedgerError::NoOpenPeriod
Code
HTTP
Rule
Meaning
Source
too_few_lines
422
1001
An entry needs at least 2 lines
PostingError::TooFewLines
too_many_lines
422
1002
An entry has too many lines
PostingError::TooManyLines
metadata_too_large
422
1003
The metadata is too large
PostingError::MetadataTooLarge
amount_not_positive
422
1004
A line amount is not positive
PostingError::AmountNotPositive
account_not_found
422
1005
A line names an account that does not exist
PostingError::AccountNotFound
account_not_open
422
1006
An account is not open
PostingError::AccountNotOpen
currency_mismatch
422
1007
A line’s currency is not its account’s
PostingError::CurrencyMismatch
duplicate_line
422
1008
Two lines share an account and side
PostingError::DuplicateLine
amount_overflow
422
1009
The amounts are too large
PostingError::AmountOverflow
unbalanced
422
1010
Debits and credits differ
PostingError::Unbalanced
account_total_overflow
422
1011
An account’s totals would be too large
PostingError::AccountTotalOverflow
insufficient_funds
422
1012
An account would go below zero
PostingError::InsufficientFunds
Code
HTTP
Rule
Meaning
Source
invalid_template_id
404
2001
The template ID is malformed
TemplateError::InvalidTemplateId
unknown_template
404
2002
No such template
TemplateError::UnknownTemplate
unknown_template_version
404
2003
No such template version
TemplateError::UnknownVersion
missing_amount
422
2004
An amount the template needs is missing
TemplateError::MissingAmount
unexpected_amount
422
2005
The template does not use this amount
TemplateError::UnexpectedAmount
non_positive_amount
422
2006
An amount is not positive
TemplateError::AmountNotPositive
missing_account
422
2007
A role the template books has no account
TemplateError::MissingAccount
unexpected_account
422
2008
The template has no such role
TemplateError::UnexpectedAccount
bound_account_not_found
422
2009
The account bound to a role does not exist
TemplateError::AccountNotFound
account_not_allowed
422
2010
The account is not allowed for its role
TemplateError::AccountNotAllowed
same_account
422
2011
Two roles are bound to the same account
TemplateError::SameAccount
reserved_metadata
422
2012
The metadata sets a reserved key
TemplateError::ReservedMetadata
template_defect
500
2013
The template books a role it does not declare
TemplateError::UndeclaredRole
amount_not_whole_balance
422
2014
The amount is not the item’s whole balance
TemplateError::AmountNotBalance
account_not_new
422
2015
The item account has already been used
TemplateError::AccountNotNew
fee_exceeds_amount
422
2016
The fees are more than the amount
TemplateError::FeeExceedsAmount
amount_currency_mismatch
422
2017
The amounts are in different currencies
TemplateError::CurrencyMismatch
amount_too_large
422
2018
An amount is too large
TemplateError::AmountOverflow
missing_metadata
422
2019
A metadata key the template requires is missing
TemplateError::MissingMetadata
invalid_metadata
422
2020
A metadata value is not allowed
TemplateError::InvalidMetadata
missing_refunded_entry
422
2021
A refund must name the entry it refunds
TemplateError::MissingRefundedEntry
unexpected_refunded_entry
422
2022
Only a refund template names an entry to refund
TemplateError::UnexpectedRefundedEntry
Code
HTTP
Rule
Meaning
Source
invalid_reference
422
The chart reference is invalid or not open for accounts
LedgerError::Chart
duplicate_reference
409
An account already exists for this reference
LedgerError::DuplicateReference
invalid_status_change
409
The account cannot change to that status
LedgerError::Status
already_reversed
409
The entry is already reversed
LedgerError::AlreadyReversed
cannot_reverse_reversal
409
A reversal cannot be reversed
LedgerError::CannotReverseReversal
reason_not_allowed
422
The reason is unknown or not for this kind of entry
LedgerError::ReasonNotAllowed
maker_is_checker
403
The approver must be a different person
LedgerError::MakerIsChecker
hold_not_active
409
The hold has already ended
LedgerError::HoldNotActive
hold_expired
409
The hold has expired
LedgerError::HoldExpired
capture_exceeds_hold
422
The capture is larger than the hold
LedgerError::CaptureExceedsHold
invalid_held_account
422
The held account must be a different, unused account of the same type
LedgerError::InvalidHeldAccount
account_is_held
422
The account is a hold’s held account
LedgerError::AccountIsHeld
not_refundable
409
Only a standard entry can be refunded
LedgerError::NotRefundable
refund_of_reversed_entry
409
The entry has been reversed
LedgerError::RefundOfReversedEntry
refund_line_not_allowed
422
The refund moves an account the original did not move that way
LedgerError::RefundLineNotAllowed
refund_exceeds_original
422
The refunds would give back more than the original moved
LedgerError::RefundExceedsOriginal
refunded_entry_not_found
422
The entry to refund does not exist, or is another client’s: both are answered alike (TM-05)
The service, before posting
refunded_entry_cannot_be_reversed
409
The entry has refunds
LedgerError::RefundedEntryCannotBeReversed
cannot_reverse_refund
409
A refund cannot be reversed
LedgerError::CannotReverseRefund
period_not_closed
409
The period is not closed
LedgerError::PeriodNotClosed
period_label_taken
409
A period with this label exists
the periods_label_key constraint
period_close_findings
409
The period did not close: verification found problems
CloseReport with findings
adjustment_not_pending
409
The adjustment request is no longer pending
API: approval or rejection of a decided request
Devices and vouchers (step 2.11, ADR-0019, protocol ).
Code
HTTP
Rule
Meaning
Source
offline_unavailable
503
Offline payments are not configured
the service has no MEZGEB_OFFLINE_ISSUER_KEY_FILE
attestation_unsupported
422
This kind of attestation is not verified yet
card or android attestation, until a chip is chosen and Android Key Attestation is verified
public_key_registered
409
The public key is registered with other details
OfflineError::KeyRegistered
owner_not_a_wallet
422
The owner account is not an open customer wallet
OfflineError::NotAWallet
tier_disabled
422
The client has not enabled this tier
OfflineError::TierDisabled; tier C is off until enabled
device_not_active
409
The device is not active
OfflineError::DeviceNotActive: frozen, lost or revoked
certificate_expired
409
The device certificate has expired
OfflineError::CertificateExpired
voucher_open
409
The device already has an open voucher
OfflineError::VoucherOpen (one per device)
over_tier_limit
422
The amount is over the tier’s voucher limit
OfflineError::OverTierLimit
over_customer_cap
422
The customer’s open vouchers would exceed the cap
OfflineError::OverCustomerCap (5,000 ETB)
shortfall_unpaid
409
The owner has an unpaid offline shortfall
OfflineError::ShortfallUnpaid: no voucher until it is repaid (step 2.13)
dispute_resolved
409
The dispute is already resolved the other way
OfflineError::DisputeResolved
Code
HTTP
Rule
Meaning
Source
break_closed
409
The break is already closed
ReconError::Closed: cleared, resolved or explained
break_not_closable
409
The break cannot be closed this way
ReconError::Conflict: a money break explained, another resolved by an entry, or an entry that is not a suspense entry for exactly the break’s difference, or has resolved another break
busy, contention and no_open_period (503) and rate_limited (429)
are safe to retry after Retry-After, with the same Idempotency-Key.
Any other 4xx will fail the same way again: fix the request.
A 500 may or may not have posted: retry with the same Idempotency-Key,
or look the entry up by its key (GET /v1/entries/by-idempotency-key/{key}).