Issue an offline voucher
const url = 'http://localhost:8080/v1/offline/vouchers';const options = { method: 'POST', headers: { 'Idempotency-Key': 'pay-2026-11-14-0001', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"device":"0192f3c4-0000-7000-8000-000000000d01","amount":{"amount":"100.00","currency":"ETB"},"last_counter":0}'};
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/offline/vouchers \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: pay-2026-11-14-0001' \ --data '{ "device": "0192f3c4-0000-7000-8000-000000000d01", "amount": { "amount": "100.00", "currency": "ETB" }, "last_counter": 0 }'Reserves an offline allowance for an active device: posts E16 (issue_voucher.v1), moving the amount from the owner’s wallet into the voucher’s own escrow 2050:vch-<id>, and signs the voucher with the issuer key (protocol §7). One open voucher per device; the amount is at most the tier’s limit, and the owner’s open vouchers at most 5,000 ETB. The voucher’s counter_start is after the device’s reported last_counter and after every counter the ledger has recorded for it, so a receipt of an earlier voucher still in transit never collides with it. A repeat with the same Idempotency-Key returns the same voucher.
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
An offline device 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.
The device’s last counter, as the device reports it: 0 if it has never signed a receipt. The voucher starts after it (protocol §7).
Example
{ "device": "0192f3c4-0000-7000-8000-000000000d01", "amount": { "amount": "100.00", "currency": "ETB" }, "last_counter": 0}Responses
Section titled “Responses”The voucher, issued earlier for this Idempotency-Key.
object
An offline voucher ID.
An offline device ID.
An account ID.
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.
The voucher’s first counter: after the device’s reported last counter and every counter recorded for it. A device refuses a voucher that does not start above its own counter.
An entry ID.
The exact bytes signed, in lower-case hex (protocol §3).
An ECDSA P-256 signature, r || s with low s, in lower-case hex.
Example
{ "amount": { "amount": "39.20", "currency": "ETB" }, "status": "active"}The signed voucher.
object
An offline voucher ID.
An offline device ID.
An account ID.
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.
The voucher’s first counter: after the device’s reported last counter and every counter recorded for it. A device refuses a voucher that does not start above its own counter.
An entry ID.
The exact bytes signed, in lower-case hex (protocol §3).
An ECDSA P-256 signature, r || s with low s, in lower-case hex.
Example
{ "id": "0192f3c4-0000-7000-8000-000000000e01", "device": "0192f3c4-0000-7000-8000-000000000d01", "owner_account": "0192f3c4-0000-7000-8000-000000000002", "escrow_account": "0192f3c4-0000-7000-8000-000000000e02", "amount": { "amount": "100.00", "currency": "ETB" }, "counter_start": 1, "issued_at": "2026-11-16T00:00:00Z", "expires_at": "2026-11-17T00:00:00Z", "status": "active", "entry": "0192f3c4-0000-7000-8000-000000000e03", "issuer_key_id": "8356ab979cb1fbd8", "body": "6d657a6765622e6f66666c696e652e766f75636865722e763100", "signature": "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"}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 device cannot get a voucher now
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
device_not_active
{ "type": "urn:mezgeb:problem:device_not_active", "title": "The device is not active", "status": 409, "code": "device_not_active", "detail": "the device is frozen, not active", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}certificate_expired
{ "type": "urn:mezgeb:problem:certificate_expired", "title": "The device certificate has expired", "status": 409, "code": "certificate_expired", "detail": "the device certificate has expired", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}voucher_open
{ "type": "urn:mezgeb:problem:voucher_open", "title": "The device already has an open voucher", "status": 409, "code": "voucher_open", "detail": "the device already has an open voucher", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}shortfall_unpaid
{ "type": "urn:mezgeb:problem:shortfall_unpaid", "title": "The owner has an unpaid offline shortfall", "status": 409, "code": "shortfall_unpaid", "detail": "the owner has 6500 minor units of unpaid shortfall", "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"}The voucher was 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
over_tier_limit
{ "type": "urn:mezgeb:problem:over_tier_limit", "title": "The amount is over the tier's voucher limit", "status": 422, "code": "over_tier_limit", "detail": "over the tier's voucher limit of 20000 minor units", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}over_customer_cap
{ "type": "urn:mezgeb:problem:over_customer_cap", "title": "The customer's open vouchers would exceed the cap", "status": 422, "code": "over_customer_cap", "detail": "the customer has 400000 minor units in open vouchers; the cap is 500000", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}tier_disabled
{ "type": "urn:mezgeb:problem:tier_disabled", "title": "The client has not enabled this tier", "status": 422, "code": "tier_disabled", "detail": "tier C is not enabled", "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"}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, or offline payments are not configured
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
offline_unavailable
{ "type": "urn:mezgeb:problem:offline_unavailable", "title": "Offline payments are not configured", "status": 503, "code": "offline_unavailable", "detail": "This ledger has no offline issuer key, so offline payments are off.", "instance": "urn:uuid:0192f3c4-0000-7000-8000-00000000abcd"}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.