Appearance
Buy airtime vouchers
Buys one or more recharge PINs of one value for one network.
POST /api/v1/airtime/voucher/{carrier}/buy
POST /api/v1/airtime/direct/voucher/{carrier} is the same endpoint under an older path.
carrier is the network id from the network list. The network must have has_voucher: true.
Body
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | The value of one voucher. Must be one of the network's voucher values, unless the network allows custom amounts. |
quantity | integer | Yes | How many vouchers. At least 1. |
currency | string | Yes | The wallet to pay from, for example USD. |
is_vendor_voucher | boolean | Yes | true to ask for the network's own voucher, false for a Xash voucher. See below. |
reference | string | No, but send it | Your own id for this purchase. Up to 120 characters: letters, digits, :, ., _ and -. Makes the request safe to repeat. |
You are charged amount × quantity.
Already integrated without a reference?
Nothing changes for you. A request without reference is answered exactly as it always was: see Without a reference. The answers on this page apply only when you send one.
Two kinds of voucher
| Xash voucher | Network (vendor) voucher | |
|---|---|---|
| What it is | A PIN issued by Xash. | The network's own PIN, from stock held by Xash. |
| How the customer loads it | Dials the ussd_code of the network. | Dials the vendor_ussd_code with the PIN. |
| Available | Econet. | Only the values listed in vendor_voucher_values. |
What you ask for is not always what you get:
- Econet: if you ask for a network voucher and that value is out of stock, you get a Xash voucher instead.
- NetOne:
is_vendor_voucheris ignored. You get vouchers from stock when there are enough, otherwise they are bought from NetOne at that moment.
Always show the customer the recharge_instructions from the response. It is correct for what was actually issued.
Example
bash
curl -X POST https://app.xash.co.zw/api/v1/airtime/voucher/1/buy \
-H "Authorization: Bearer YOUR_SERVER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"amount":1,"quantity":2,"currency":"USD","is_vendor_voucher":false,"reference":"order-1101"}'If your request times out, or you receive a 502 or 504, repeat it with the same reference, or check its status. You get the same PINs, not new ones.
Response 200: delivered
json
{
"success": true,
"message": "Econet xash voucher purchase was successful",
"data": {
"status": "processed",
"type": "voucher",
"id": "00000000-0000-4000-8000-00000000b101",
"reference": "order-1101",
"name": "Econet xash voucher",
"amount": "2.00",
"voucher_value": "1.00",
"currency": "USD",
"balance": {
"currency": "USD",
"name": "US Dollar",
"profit_on_hold": "0.120",
"balance": "46.00"
},
"vouchers": ["000 111 222", "333 444 555"],
"commission": "USD0.12",
"receipt_footer": "Get airtime/bundle on your change from as little as 10 cents.",
"created_at": "2026-11-19T10:15:00+02:00",
"recharge_instructions": "*440*112#",
"provider_reference": null,
"product": "airtime_voucher",
"recipient": null,
"transaction_id": "00000000-0000-4000-8000-00000000b101",
"fulfilment": {
"pin": "000111222",
"pins": ["000111222", "333444555"],
"recharge_instructions": "*440*112#"
},
"error_code": null
}
}| Field | Description |
|---|---|
fulfilment.pins | Every PIN, one per voucher, as digits only. |
fulfilment.pin | The first PIN. |
fulfilment.recharge_instructions, recharge_instructions | What the customer dials. Where it contains PIN, replace that with the voucher PIN. |
vouchers | The same PINs with spaces added for reading. |
reference | Your reference, as you sent it. |
status | processed. |
transaction_id, id | The Xash transaction id. |
amount | The total charged. |
voucher_value | The value of one voucher. |
product | airtime_voucher. |
recipient, provider_reference | Always null: voucher PINs are not sent to a phone. |
balance, commission | Your wallet after the purchase, and what you earned. |
A repeat of the same request returns this same answer with the same PINs. Nothing is charged, no new PIN is created and none is taken from stock. Only balance shows your balance at the time of the repeat.
Two requests are the same purchase when the reference and all of these match: the network, currency, amount, quantity and is_vendor_voucher. Send is_vendor_voucher exactly as you sent it the first time, even for NetOne, and even when Econet gave you a Xash voucher instead of the network voucher you asked for. A different value answers 409 REFERENCE_CONFLICT.
Both paths of this endpoint share references: a reference used on one path is replayed on the other.
Response 202: not known yet
json
{
"success": false,
"error_code": "OUTCOME_UNKNOWN",
"message": "This purchase is still being confirmed. Do not buy again; check its status with this reference.",
"data": {
"reference": "order-1101",
"status": "unknown",
"provider_reference": null,
"amount": "2.00",
"currency": "USD",
"product": "airtime_voucher",
"recipient": null,
"transaction_id": "00000000-0000-4000-8000-00000000b101",
"fulfilment": null,
"error_code": null,
"created_at": "2026-11-19T10:15:00+02:00"
}
}This happens when the vouchers are bought from NetOne at that moment and NetOne did not give a clear answer. The money is held and is not refunded automatically. Do not buy again, with this or any other reference: the vouchers may already have been issued. Check the status with the same reference until it is processed or failed. When it becomes processed, the status answer carries the PINs in fulfilment.
data.status is processing instead of unknown when an earlier request with this reference is still running.
Failures
A failure means no voucher was issued and your wallet was not charged, or was refunded. The body has the same shape as the 202 above, with "status": "failed" and the code repeated in data.error_code.
| Status | error_code | Meaning |
|---|---|---|
422 | INSUFFICIENT_FUNDS | Your balance is lower than amount × quantity. |
422 | LIMIT_PER_TRANSACTION, LIMIT_DAILY | A spending limit on your server tokens refused the purchase. Nothing was charged. data also carries the limit figures. |
422 | OUT_OF_STOCK | Not enough network vouchers of this value in stock for this quantity. Nothing was charged. |
422 | PROVIDER_REJECTED | NetOne refused the purchase. message carries its reason. Refunded. |
503 | SERVICE_UNAVAILABLE | Xash vouchers for Econet are switched off, or vouchers are not available for this network. Nothing was charged. |
503 | NOT_SENT | The purchase could not be started. Nothing was charged or sent to the network. |
409 | REFERENCE_CONFLICT | This reference belongs to an earlier purchase with a different network, value, quantity, currency or is_vendor_voucher, or for another product. That purchase may have been delivered: look it up before buying again. |
404 | none | Unknown carrier. No purchase was recorded, so the reference is still free. |
422 | none | A field is invalid, amount is not one of the network's values, or reference is malformed. Validation error. No purchase was recorded, so the reference is still free. |
A failed reference stays failed. Repeating it returns the same failure. To try the purchase again, for example with a lower quantity after OUT_OF_STOCK, send a new reference. REFERENCE_CONFLICT is not such a failure: see codes that point at an earlier purchase.
A reference that is an empty string, null, not a string, longer than 120 characters, or that has any character other than letters, digits, :, ., _ and -, is a validation error. It is never treated as "no reference".
Without a reference
The endpoint also works without reference, as it always has. Nothing about these answers has changed. Then a repeat is a new purchase: sending the request twice buys twice, with new PINs each time.
Response 200
json
{
"success": true,
"message": "Econet xash voucher purchase was successful",
"data": {
"status": "success",
"type": "voucher",
"id": "00000000-0000-7000-8000-00000000b001",
"reference": "00000000B001",
"name": "Econet xash voucher",
"amount": "2.00",
"voucher_value": "1.00",
"currency": "USD",
"balance": {
"currency": "USD",
"name": "US Dollar",
"profit_on_hold": "0.120",
"balance": "46.00"
},
"vouchers": ["000 111 222", "333 444 555"],
"commission": "USD0.12",
"receipt_footer": "Get airtime/bundle on your change from as little as 10 cents.",
"created_at": "2026-11-19T08:15:00.000000Z",
"recharge_instructions": "*440*112#"
}
}| Field | Description |
|---|---|
vouchers | The PINs, one per voucher, with spaces added for reading. Remove the spaces before dialling. |
amount | The total charged. |
voucher_value | The value of one voucher. |
recharge_instructions | What the customer dials. Where it contains PIN, replace that with the voucher PIN. |
id | The Xash transaction id. |
reference | A short receipt code. |
There is no fulfilment, product or transaction_id, and status is success.
Errors
| Status | message or error_code | Meaning |
|---|---|---|
400 | You do not have enough balance to make this transaction. | Not enough balance. |
400 | Econet custom voucher purchase is currently disabled. | Xash vouchers for Econet are switched off. |
400 | Failed to purchase voucher. Try lower quantity. | Not enough network vouchers in stock. Nothing was charged. |
400 | Unable to process your request. Please try again later. | Vouchers are not available for this network. Nothing was charged. |
400 | Any other message, with data.reference. | NetOne refused the purchase. Refunded. |
422 | error_code is LIMIT_PER_TRANSACTION or LIMIT_DAILY. | A spending limit on your server tokens refused the purchase. Nothing was charged. |
202 | error_code is OUTCOME_UNKNOWN, data.reference is the transaction id, data.status is on_hold. | NetOne did not give a clear answer. The money is held. Do not buy again. Find the transaction in history with include_pending, or contact support with the reference. |
404 | Unknown carrier. | |
422 | A field is invalid, or amount is not one of the network's values. |
If you cannot send a reference, treat a timeout as "not known" and check transaction history before trying again.