API reference · Meter charges

Charge a meter

POST/v1/wallets/{walletId}/meter-charges

Buy a meter charge with an operation id you save before sending. A 202 means the charge is accepted or its outcome is still being checked.

Permissionmeter_charges:create
AuthenticationSigned purchase
Anis’s answerSigned
Staff-set limits it counts towardAll requests, Purchases (orders limit)
.NET SDKanis.MeterCharges.CreateAsync(walletId, operationId, request)
  • Every processing 202 contains exactly operationId, operationType and status: "processing"; operationType is meterCharge. Full operation reads use 200.
  • A missing operation read never proves absence. Retry the exact saved body with the same operation id and a fresh signature. A duplicate remains 202 during projection lag. Only a duplicate command on this retry, at or after 60 seconds since original admission, followed by an application-scoped read still not found, closes the operation with idempotency_conflict (409). A read miss or timeout alone never proves a conflict. That code does not prove nothing was charged: the first request may already have been accepted, so read the operation before any new attempt.
  • This purchase counts toward the existing orders limit and the same daily application spending cap as card orders and other purchases.

Parameters

NameInTypeNotes
walletIdrequiredpathUUIDA UUID, lower-case with hyphens.

Request

Signed with your key, with a one-time nonce, a digest of the body and your operation id as Idempotency-Key.

Headers: Signature-Input, Signature, Content-Digest, Nonce, Idempotency-Key, X-Anis-Date, Accept-Language (optional). The SDKs set all of them for you.

Body: CreateMeterChargeRequest, as JSON.

FieldTypeNotes
packageIdrequiredUUIDThe selected package's id from the package list.
meterNumberrequiredstringThe meter number as text; preserve leading zeros.
expectedTotalrequiredanyThe total you confirmed from the package or quote, as LYD Money.
externalReferencestringYour reference, included when supplied.

Responses

StatusMeaningBody
200Success.MeterCharge
202Accepted — no outcome yet.MeterChargeAccepted
400Refused: the signed request is badly built.Problem
401Refused: not authenticated.Problem
403Refused: not allowed.Problem
404Refused: not found, or not yours.Problem
409Refused: conflicts with the current state.Problem
422Refused: the request breaks a rule.Problem
429Refused: a limit was reached.Problem
503No decision: a dependency was unavailable.Problem

Every answer of this call is signed by Anis — success and every refusal. Require the signature and verify it before you act on the answer; an answer without one is a failure, never an answer (how).

Refusals

Every refusal of this call is a signed problem. Branch on its code; each links to what it means and what to do.

ErrorCodeStatus
Invalid credentialsinvalid_credentials401
Malformed signed requestmalformed_signed_request400
Insufficient scopeinsufficient_scope403
Source address not allowedsource_ip_not_allowed403
Rate limitedrate_limited429
Validation failedvalidation_failed422
Service unavailabledependency_unavailable503
Request timeoutrequest_timeout504
Internal errorinternal_error500
Account not authorisedbinding_not_authorized403
Account inactiveaccount_inactive403
Wallet not grantedwallet_not_granted404
Not foundresource_not_found404
Currency not supportedcurrency_not_supported422
Wallet disabledwallet_disabled409
Wallet expiredwallet_expired409
Business subscription requiredbusiness_subscription_required409
Replay detectedreplay_detected409
Operation id already usedidempotency_conflict409
Price changedprice_changed409
Insufficient balanceinsufficient_balance409
Spending cap reachedspending_limit_exceeded429
Meter refusedmeter_rejected422
Package unavailablepackage_unavailable409

Types

CreateMeterChargeRequest

FieldTypeNotes
packageIdrequiredUUIDThe selected package's id from the package list.
meterNumberrequiredstringThe meter number as text; preserve leading zeros.
expectedTotalrequiredanyThe total you confirmed from the package or quote, as LYD Money.
externalReferencestringYour reference, included when supplied.

MeterCharge

FieldTypeNotes
operationIdalways presentUUIDThe same UUID sent as Idempotency-Key for this purchase.
statusalways presentMeterChargeStatusprocessing, succeeded or failed. A failed read still needs refund.status to explain the money outcome.
walletIdalways presentstringThe wallet used for this purchase.
meterNumberalways presentstringThe meter number as text; preserve leading zeros.
packagealways presentMeterChargePackageThe package recorded for this charge.
totalalways presentMoneyThe frozen total wallet cost in every state, as LYD Money.
personalPricealways presentMoneyThe frozen retail display price in every state; do not substitute it for the payable total.
externalReferencestringYour reference, included when supplied.
createdAtalways presentstring (date-time)When the charge was recorded, in UTC.
completedAtstring (date-time)When the charge succeeded; omitted in processing and failed states.
receiptMeterReceiptPresent after successful charging; includes the full token list.
failureMeterFailureThe charge failure and localized display message; present for a failed charge.
refundMeterRefundFor a failed charge, whether money returned, was not taken or is still pending.

MeterChargeStatus

MeterChargePackage

FieldTypeNotes
idalways presentUUIDThe meter package identifier.
namealways presentstringOne stored package name, not a bilingual text object.
gecolPackageNamealways presentstringThe electricity supplier's package name.

Money

FieldTypeNotes
amountalways presentstringA decimal string, never a JSON number. Wallet balances may be negative while allowed debt is used. Prices and totals follow each route's amount rules.
currencyalways presentstringAn uppercase three-letter currency code, such as LYD. Read a wallet’s currency from balance.currency.
asOfstring (date-time)When this price or balance was read.

MeterReceipt

FieldTypeNotes
receiptNumberstringThe receipt number supplied by the electricity supplier.
creditedAmountstringThe supplier's credited amount string, passed through unchanged; not the wallet total.
tokensalways presentlist of MeterTokenEvery supplier token in sequence order, including key changes before credit.
taxesalways presentlist of MeterTaxThe supplier receipt's tax lines.

MeterToken

FieldTypeNotes
sequencealways presentintegerSupplier token order; preserve gaps rather than renumbering.
labelalways presentstringThe supplier's token label.
codealways presentstringThe complete token string, including spaces and leading zeros.
descriptionstringThe token's display description when supplied.

MeterTax

FieldTypeNotes
descriptionalways presentstringThe electricity company's original Arabic tax description, unchanged.
amountalways presentstringThe original supplier amount string; no Money-scale conversion.

MeterFailure

FieldTypeNotes
codealways presentstringA charge-read failure value, not an HTTP problem code. Values: meter_number_invalid, meter_not_whitelisted, meter_not_linked, meter_removed, meter_inactive, meter_account_blocked, meter_data_incomplete, meter_debt_exceeds_package, package_unavailable, package_limit_reached, token_not_written, insufficient_balance, gecol_unavailable, charge_failed
messageLocalizedTextArabic and English messages matching the charging result.

LocalizedText

FieldTypeNotes
arstringThe Arabic text; omitted when empty.
enstringThe English text; omitted when empty.

MeterRefund

FieldTypeNotes
statusalways presentMeterRefundStatusrefunded means returned; notCharged means nothing taken; pending means money has not returned yet.
amountanyThe refund Money value when present; never infer settlement from this amount alone.

MeterRefundStatus

MeterChargeAccepted

FieldTypeNotes
operationIdalways presentUUIDThe same UUID sent as Idempotency-Key for this purchase.
operationTypealways presentstringAlways meterCharge. Values: meterCharge
statusalways presentstringAlways processing; the outcome is not final. Values: processing