Appearance
Outcomes and error codes
Read the answer in this order
- The HTTP status.
error_code, when there is one. It is stable; build your logic on it.messageis for people. Its wording can change. Never match on it.
The three outcomes of a purchase
| Outcome | How you recognise it | Money | What to do |
|---|---|---|---|
| Delivered | 200, "success": true | Charged. | Record the sale. |
| Failed | 4xx or 503, "success": false, an error_code other than OUTCOME_UNKNOWN | Not charged, or refunded. | Show the failure. A retry needs a new reference, except after a code that points at an earlier purchase. |
| Not known yet | 202, error_code is OUTCOME_UNKNOWN | Held. | Do not buy again. Check the status. |
A fourth case is no answer at all: a timeout, a dropped connection, or a 502/504 page that is not JSON. Treat it exactly like "not known yet". See References and safe retries.
Send a reference
The table above is exact for purchases sent with a reference. Without one, some endpoints use other status codes for the same outcomes (for example a 500 for a definite failure, or a 400 for an unknown one). Each product page has a "Without a reference" section that lists them.
Purchase codes
Returned by direct airtime, airtime vouchers, bundles, bundle vouchers, ZESA and DStv when you send a reference, and by the status lookup.
error_code | Status | Products | Meaning | Retry? |
|---|---|---|---|---|
OUTCOME_UNKNOWN | 202 | All | The provider did not give a clear answer. The money is held. | No. Check the status. |
INSUFFICIENT_FUNDS | 422 (DStv: 400) | All | Your wallet balance is too low. | After adding funds, with a new reference. |
LIMIT_PER_TRANSACTION | 422 | All, with or without a reference. Also WiFi vouchers and transfers. | The amount is above the per-transaction limit on your server tokens. Nothing was charged or sent. | With an amount of data.limit or less, or after Xash raises the limit. New reference. |
LIMIT_DAILY | 422 | All, with or without a reference. Also WiFi vouchers and transfers. | The amount would take today's spending above the daily limit on your server tokens. Nothing was charged or sent. | With an amount of data.remaining_today or less, or after data.resets_at. New reference. |
PROVIDER_REJECTED | 422 | Airtime, airtime vouchers (NetOne), bundles, ZESA | The network or utility refused the sale. Refunded. | Only if message shows something you can fix. New reference. |
OUT_OF_STOCK | 422 | Airtime vouchers | Not enough network vouchers of this value in stock for the quantity. Nothing was charged. | With a lower quantity or another value. New reference. |
RECIPIENT_INVALID | 422 | ZESA | The meter could not be verified. | After correcting the meter number. New reference. |
RECIPIENT_INVALID | 422 | Bundles | The phone number could not be read. Nothing was recorded: data holds only your reference. | After correcting the number. The same reference is still free. |
METER_BUSY | 422 | ZESA | Another purchase for this meter is running. | Not until that purchase has finished and you have checked it. If it was this same order and it did not fail, do not buy again. |
DUPLICATE_PURCHASE | 422 | ZESA | The meter has an unresolved purchase, or was sold the same amount in the last 10 minutes. | Not until you have checked the earlier purchase. It may have been delivered or be held. |
DUPLICATE_TRANSACTION | 400 | DStv | An earlier payment of the same amount to this smartcard, in the last 10 minutes, was paid, is held or is still running. | Not until you have checked the earlier payment. It may have been delivered or be held. |
PURCHASE_IN_PROGRESS | 429 | DStv | Another payment for this smartcard is running. | Not until that payment has finished and you have checked it. If it was this same order and it did not fail, do not pay again. |
DSTV_RATE_UNVERIFIED | 400 | DStv | DStv payments are temporarily unavailable. | Later. New reference. |
DSTV_LOOKUP_FAILED | 422 | DStv | The smartcard could not be verified. | After correcting the number. New reference. |
DSTV_AMOUNT_CONFIRMATION_FAILED | 422 | DStv | DStv would not accept this amount for the account. | With another package. New reference. |
DSTV_ACCOUNT_OWES_MORE | 422 | DStv | The account owes exactly one package that costs more than the one chosen, so the payment would leave it short. Nothing was charged. | With the account's package. If that is the package you chose, DStv still bills its earlier price: contact support. New reference. |
DSTV_PAYMENT_FAILED | 422 | DStv | DStv refused the payment. Refunded. | Later. New reference. |
SERVICE_UNAVAILABLE | 503 (DStv: 400) | All | The product is paused, the network is not available, or vouchers are not issued for that network. Nothing was charged. | Later. New reference. |
NOT_SENT | 503 | All | The purchase could not be started. Nothing was charged or sent. | Yes. New reference. |
VEND_FAILED | 422 on a repeat; in lookups | All | A held purchase was reconciled as failed and refunded. | Yes. New reference. |
REFERENCE_CONFLICT | 409 | All | The reference belongs to an earlier purchase with different details. That purchase may have been delivered or be held; this answer does not say it failed. | Not until you have looked up the reference. A new reference is only for a different purchase. |
REFERENCE_NOT_FOUND | 404 | Lookup | Your account has no purchase with this reference. | The purchase never arrived; it is safe to send. |
A reference that ended in a failure keeps returning that failure, with the same status code. "New reference" above means exactly that. It applies only when the earlier attempt definitely failed: see codes that point at an earlier purchase. Never use a new reference after OUTCOME_UNKNOWN or when you got no answer.
LIMIT_PER_TRANSACTION and LIMIT_DAILY apply only to requests made with a server token, and only on accounts where Xash has set a limit. GET /api/v1/limits shows yours. Both are definite failures, and their data carries the limit figures. Do not confuse LIMIT_DAILY with the 429 rate limit, which counts requests, not money.
Codes without a reference
error_code | Status | Where | Meaning |
|---|---|---|---|
OUTCOME_UNKNOWN | 202 | Direct airtime, airtime vouchers (NetOne), bundles | Not known yet. The money is held. data.reference is the Xash transaction id and data.status is on_hold. Do not buy again. |
LIMIT_PER_TRANSACTION, LIMIT_DAILY | 422 | Every purchase, and transfers | A spending limit on your server tokens refused it. Nothing was charged. The code is at the top level of the body on every product, DStv included. |
RECENT_DUPLICATE | 409 | Direct airtime (NetOne) | The same number and amount were topped up successfully in the last 10 minutes. |
DStv without a reference puts its code in data.error_code. Besides the codes above it can return DSTV_PAYMENT_REVIEW_REQUIRED, DSTV_PAYMENT_RECEIPT_REVIEW_REQUIRED or DSTV_CONFIRMATION_MISSING with a 503. All three mean not known: the money is held for review.
WiFi voucher codes
Returned by WiFi vouchers. These answers also carry a refunded flag.
error_code | Status | Meaning | Retry? |
|---|---|---|---|
OUT_OF_STOCK | 409 | Not enough vouchers of this kind. Not charged. | With a lower quantity or another kind. |
LIMIT_PER_TRANSACTION, LIMIT_DAILY | 422 | A spending limit on your server tokens refused the purchase. Not charged. These two answers have no refunded flag. | When the amount fits the limit. The same client_reference can be sent again. |
VEND_FAILED | 422 | The purchase failed. refunded says whether the money was returned (true) or is held for review (false). | If refunded is true, yes. |
PURCHASE_IN_PROGRESS | 409 | A purchase with this client_reference is still running. | Check its status first. |
IDEMPOTENCY_CONFLICT | 409 | This client_reference belongs to an earlier purchase with different details. | Not until you have checked that purchase. A new reference is only for a different purchase. |
PURCHASE_NOT_FOUND | 404 | No WiFi purchase matches this reference. |
Deposit codes
Returned by the deposit endpoints.
error_code | Status | Meaning | Retry? |
|---|---|---|---|
PAYMENT_START_UNCONFIRMED | 500 | It is not known whether the payment was started. The payer may still get a prompt. | Repeat with the same request_id where it is honoured. Anywhere else a repeat is a second deposit: find out what happened to the first before starting another. |
IDEMPOTENCY_CONFLICT | 409 | This request_id was used with different details. | This request_id already belongs to a deposit, which may have started. Repeat the original request with this key to get that deposit back, and check it. Use a new request_id only for a different payment. |
PAYMENT_NOT_FOUND | 404 | No deposit of yours matches. |
A deposit that the provider refused answers 422 with a message and no code. A method that is switched off answers 400 with a message and no code.
Failures without a code
Many simple failures have only a message:
json
{
"message": "You do not have enough balance to make this transaction.",
"success": false
}This is the shape of most 400 answers from transfers, and from voucher and bundle purchases sent without a reference. The product pages list each one. Where you have to tell them apart, compare the HTTP status and what you sent, not the text.
Standard HTTP answers
| Status | Body | Meaning | What to do |
|---|---|---|---|
401 | {"message": "Unauthenticated."} | The token is missing, wrong or revoked. | Fix the token. Do not retry as is. |
404 | {"message": "..."} | Unknown path, or the id in the path does not exist or is not yours. | Fix the request. |
405 | {"errors": "Method not allowed."} | Wrong HTTP method. | Fix the request. |
422 | {"message": "...", "errors": {...}} | Validation error: a field is missing or invalid. Nothing happened. | Fix the request. |
429 | {"message": "Too Many Attempts."} | Rate limit. Nothing happened. | Wait for Retry-After seconds. |
500 | {"message": "..."} | An error on Xash's side. For a purchase, treat the outcome as not known. | Check the status before retrying. |
502, 504 | Often an HTML page, not JSON | The request did not get an answer in time. For a purchase, treat the outcome as not known. | Check the status before retrying. |
Sign-up codes
The registration and PIN endpoints in the Xash app section use a different key, code, with the values otp_required and otp_invalid. See Set password.
Getting help
When you contact [email protected] about a purchase, send the transaction_id (or the id from the response), your reference, and the time of the request.