OrderMart API
Buy data bundles for your customers from your OrderMart account: place single or bulk orders, get every status change sent to your server, and see your wallet, transactions and bills.
Base URL
Every request and response is JSON. Every response has the same shape:
{ "success": true, "data": { … }, "meta": { … } } ← meta only on lists
{ "success": false, "error": { "code": "INSUFFICIENT_BALANCE", "message": "…", "details": { … } } }
Amounts are strings in Ghana cedis with two decimals ("4.50"). Dates are ISO 8601 in Africa/Accra time. Phone numbers are accepted as 0241234567, 233241234567 or +233 24 123 4567 and always returned as 0241234567.
Authentication
Send your API key in the X-API-Key header on every request (Authorization: Bearer <key> also works).
omk_live_…keys place real orders and use real money.omk_test_…keys are for building your integration: no money moves and nothing reaches a network.- A key is shown once when it is created. We only keep a fingerprint of it, so we cannot show it again. Lost it? Revoke it and make a new one.
- A key can be locked to your server's IP addresses. Requests from any other IP get
403 IP_NOT_ALLOWED. - Never put a key in a website, app or anywhere your customers can see it. Call the API only from your server.
Test mode
With an omk_test_ key every endpoint works the same, but orders are simulated: they are delivered within a moment, except numbers ending in 0000, which always fail, so you can test both outcomes and your webhook handler. Test orders never touch your wallet and are kept separate from live orders.
Order lifecycle
| Status | Meaning |
|---|---|
pending | Paid for and waiting to be sent to the network. If it has to wait (for example the network is busy or being topped up), waiting_reason says why. It goes through on its own; you don't need to do anything. It never fails because of a wait. |
processing | Accepted and being delivered. |
delivered | The bundle was delivered. Final. |
failed | The network took the order but could not deliver it. Final. Wallet accounts get the money back at once (refunded: true); failed orders never appear on an end-of-day bill. failure_code says why. |
| failure_code | What happened / what to do |
|---|---|
NUMBER_NOT_VALIDATED | MTN refused the number while delivering (its approved list changed after the order was taken). You are refunded. Order again once it is approved. |
INVALID_NUMBER | The network refused the number. |
NOT_DELIVERED | The network could not deliver it. |
References & safe retries
Send your own transaction id as reference with each order (letters, digits and . _ - :, up to 100 characters). It protects you from paying twice:
- Same reference again with the same number and bundle: you get the original order back (
200, headerIdempotent-Replayed: true). Nothing is charged again. - Same reference with a different number or bundle:
409 REFERENCE_CONFLICT. A reference always belongs to one order. - Your request timed out? Send exactly the same request again with the same reference, or look it up with Find by reference. Never retry with a new reference: that is a new order.
Duplicate protection
The same phone number and bundle ordered again within 30 minutes is refused with 409 DUPLICATE_ORDER, in case your system sent it twice by mistake. If the customer really wants it twice, send "allow_duplicate": true (allow_duplicates for bulk).
Errors
| HTTP | code | When |
|---|---|---|
| 401 | UNAUTHORIZED | Missing, wrong or revoked API key |
| 403 | IP_NOT_ALLOWED | Key is locked to other IP addresses |
| 403 | ACCOUNT_SUSPENDED | Account suspended |
| 402 | INSUFFICIENT_BALANCE | Wallet doesn't cover the order. Nothing charged. |
| 402 | CREDIT_LIMIT_REACHED | End-of-day account: credit limit reached until a bill is paid |
| 409 | DUPLICATE_ORDER | Same number + bundle within 30 min (see above) |
| 409 | REFERENCE_CONFLICT | Reference already used for a different order |
| 422 | INVALID_NUMBER | Not a valid Ghana mobile number |
| 422 | NEW_NUMBER | First-time MTN number that MTN has not approved yet. Not accepted and nothing charged. Order it again once approved. |
| 422 | INVALID_PRODUCT | Unknown or unavailable bundle code |
| 422 | VALIDATION_ERROR | Missing or badly formed fields; details lists them |
| 404 | NOT_FOUND | No such order / bill (or not yours) |
| 429 | RATE_LIMITED | Too many requests; wait Retry-After seconds |
| 500 | INTERNAL_ERROR | Our fault. Retry with the same reference, which is always safe. |
Rate limits
600 requests per minute per key. A bulk request counts once and can carry up to 500 orders. Number checks: 30 requests per minute (up to 1,000 numbers each). Over the limit you get 429 with a Retry-After header.
Account
curl https://www.ordermartgh.com/api/v1/me \ -H "X-API-Key: $KEY"
{ "success": true, "data": {
"name": "Mensah Telecom", "email": "ops@mensah.com", "billing": "prepaid",
"balance": "1540.75", "credit_limit": null, "credit_used": null,
"available_to_spend": "1540.75", "currency": "GHS", "key_mode": "live" } }
billing is prepaid (pay from your wallet) or postpaid (end-of-day bill within a credit limit).
Balance
{ "success": true, "data": { "billing": "prepaid", "balance": "1540.75", "credit_limit": null,
"credit_used": null, "available_to_spend": "1540.75", "currency": "GHS" } }
Bundles & prices
The bundles you can order and your price for each. Use code as bundle when ordering. Networks: MTN, TELECEL, AIRTELTIGO (codes look like TELECEL-5GB); only bundles switched on for you are listed.
{ "success": true, "data": [
{ "code": "MTN-1GB", "name": "MTN 1GB", "network": "MTN", "size_gb": 1, "price": "4.50" },
{ "code": "MTN-2GB", "name": "MTN 2GB", "network": "MTN", "size_gb": 2, "price": "8.80" } ] }
Place an order
| Field | Type | Description | |
|---|---|---|---|
phone_number | string | required | Ghana mobile number |
bundle | string | required | Bundle code from /bundles, e.g. MTN-1GB |
reference | string | recommended | Your transaction id (see References) |
allow_duplicate | boolean | optional | Allow the same number + bundle again within 30 min |
The price is taken from your wallet (or added to today's bill) the moment the order is accepted. Answers 201 with the order; 200 if it is a replay of an earlier reference.
curl -X POST https://www.ordermartgh.com/api/v1/orders \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"phone_number":"0241234567","bundle":"MTN-1GB","reference":"INV-10023"}'<?php
$ch = curl_init('https://www.ordermartgh.com/api/v1/orders');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('ORDERMART_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'phone_number' => '0241234567',
'bundle' => 'MTN-1GB',
'reference' => 'INV-10023', // your own id: makes retries safe
]),
]);
$res = json_decode(curl_exec($ch), true);
if ($res['success'] ?? false) {
$orderId = $res['data']['id']; // save it with your sale
} else {
$code = $res['error']['code']; // e.g. INSUFFICIENT_BALANCE
}const res = await fetch('https://www.ordermartgh.com/api/v1/orders', {
method: 'POST',
headers: { 'X-API-Key': process.env.ORDERMART_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ phone_number: '0241234567', bundle: 'MTN-1GB', reference: 'INV-10023' }),
});
const body = await res.json();
if (body.success) console.log('order', body.data.id, body.data.status);
else console.error(body.error.code, body.error.message);import os, requests
r = requests.post('https://www.ordermartgh.com/api/v1/orders',
headers={'X-API-Key': os.environ['ORDERMART_KEY']},
json={'phone_number': '0241234567', 'bundle': 'MTN-1GB', 'reference': 'INV-10023'},
timeout=30)
body = r.json()
if body['success']:
print('order', body['data']['id'], body['data']['status'])
else:
print(body['error']['code'], body['error']['message'])Response
{ "success": true, "data": {
"id": "01jf3k2m9x8y7z6w5v4t3s2r1q", "reference": "INV-10023",
"phone_number": "0241234567", "network": "MTN", "bundle": "MTN-1GB", "size_gb": 1, "amount": "4.50",
"status": "pending", "waiting_reason": null, "failure_code": null, "failure_reason": null,
"refunded": false, "report": null, "billing": "prepaid", "mode": "live", "batch_id": null,
"created_at": "2026-12-04T09:15:02+00:00", "delivered_at": null, "failed_at": null } }
Bulk orders
Up to 500 orders in one request. Every line is checked on its own: good lines are placed and charged, bad lines are refused with a reason, and nothing else is affected (partial success). Results come back in the same order as you sent them (index). Answers 201 if at least one line was placed, 422 if none were.
| Field | Type | Description |
|---|---|---|
orders | array | Each: phone_number, bundle, optional reference |
allow_duplicates | boolean | Allow repeats of the same number + bundle (within the batch and the last 30 min) |
curl -X POST https://www.ordermartgh.com/api/v1/orders/bulk \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"orders":[
{"phone_number":"0241234567","bundle":"MTN-1GB","reference":"INV-1"},
{"phone_number":"0551234567","bundle":"MTN-5GB","reference":"INV-2"}
]}'<?php
$lines = [];
foreach ($sales as $sale) { // e.g. from your database
$lines[] = ['phone_number' => $sale['phone'], 'bundle' => $sale['bundle'], 'reference' => 'INV-' . $sale['id']];
}
$ch = curl_init('https://www.ordermartgh.com/api/v1/orders/bulk');
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('ORDERMART_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['orders' => $lines])]);
$res = json_decode(curl_exec($ch), true);
foreach ($res['data']['results'] as $r) {
$sale = $sales[$r['index']];
$r['ok'] ? markPlaced($sale, $r['order']['id']) : markRefused($sale, $r['error']['code']);
}const orders = sales.map(s => ({ phone_number: s.phone, bundle: s.bundle, reference: `INV-${s.id}` }));
const res = await fetch('https://www.ordermartgh.com/api/v1/orders/bulk', {
method: 'POST',
headers: { 'X-API-Key': process.env.ORDERMART_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ orders }),
});
const { data } = await res.json();
for (const r of data.results) {
if (r.ok) console.log(sales[r.index].id, '→', r.order.id);
else console.warn(sales[r.index].id, r.error.code);
}orders = [{'phone_number': s['phone'], 'bundle': s['bundle'], 'reference': f"INV-{s['id']}"} for s in sales]
r = requests.post('https://www.ordermartgh.com/api/v1/orders/bulk', headers={'X-API-Key': os.environ['ORDERMART_KEY']},
json={'orders': orders}, timeout=60)
for res in r.json()['data']['results']:
sale = sales[res['index']]
print(sale['id'], res['order']['id'] if res['ok'] else res['error']['code'])Response
{ "success": true, "data": {
"batch_id": "01jf3m…", "accepted": 1, "refused": 1, "amount_charged": "4.50",
"results": [
{ "index": 0, "ok": true, "replayed": false, "order": { "id": "01jf3m…", "status": "pending", … } },
{ "index": 1, "ok": false, "error": { "code": "INSUFFICIENT_BALANCE", "message": "…" } } ] } }
"replayed": true and are not charged again.Get an order
curl https://www.ordermartgh.com/api/v1/orders/01jf3k2m9x8y7z6w5v4t3s2r1q \ -H "X-API-Key: $KEY"
Find by reference
Find the order you placed with your own reference: the safe way to check after a timeout. 404 means no order was created with it, so you can send the order again with the same reference.
List orders
Newest first. status: pending, processing, delivered, failed. from/to: dates or date-times. per_page up to 100. The answer has meta: page, per_page, total, last_page.
Report "not received"
A delivered order never arrived. Optional body: {"note": "…"}. Reporting twice returns the same report. We check with the network; the order then shows "report": {"status": "refunded"} (money back: wallet credited, or taken off your next end-of-day bill, and refunded: true) or "resolved" (the network confirms it was delivered). Only delivered orders can be reported (422 NOT_REPORTABLE).
Check numbers first
First-time MTN numbers must be approved by MTN before they can receive bundles. Orders for them are not accepted (422 NEW_NUMBER, nothing charged; in a bulk order only those lines are refused). If you resell to your own customers, check numbers before you charge them. Up to 1,000 numbers per call. Nothing is charged.
curl -X POST https://www.ordermartgh.com/api/v1/numbers/precheck \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"phone_numbers":["0241234567","0559990000"]}'{ "success": true, "data": { "results": [
{ "phone_number": "0241234567", "valid": true, "ready": true },
{ "phone_number": "0559990000", "valid": true, "ready": false } ] } } ← false: first-time number, not yet approved
Transactions
Every movement on your wallet, newest first: topup, order_debit (negative), order_refund, adjustment, each with balance_after.
{ "id": 9182, "type": "order_debit", "amount": "-4.50", "balance_after": "1536.25",
"order_id": "01jf3k…", "reference": null, "note": null, "created_at": "2026-12-04T09:15:02+00:00" }
End-of-day bills
For end-of-day accounts. Shortly after midnight you get a bill for the previous day covering delivered orders only. Failed orders are never billed; an order still processing at midnight goes on the bill of the day it is delivered. A bill's detail lists every line with phone number and GB.
{ "id": 52, "date": "2026-12-03", "orders": 1840, "total_gb": 4210, "amount": "18524.00", "status": "unpaid", "paid_at": null,
"lines": [ { "order_id": "01jf…", "phone_number": "0241234567", "size_gb": 2, "amount": "8.80", "reference": "INV-1", "delivered_at": "…" } ] }
Webhooks: set up
Give us an HTTPS URL on your server and we POST every status change of your orders to it, signed with your secret.
whsec_…) is returned only once, the first time you set a URL (and on rotate). Store it right away. Rotating stops the old secret at once.Events & payload
| Event | When |
|---|---|
order.processing | The order was accepted for delivery |
order.delivered | Delivered. Final. |
order.failed | Could not be delivered; refunded (wallet) or not billed (end-of-day). Final. |
Headers: X-OrderMart-Event, X-OrderMart-Delivery (delivery id), X-OrderMart-Signature. Body: the full order, as in Place an order.
{ "id": "evt_01jf…", "type": "order.delivered", "created_at": "2026-12-04T09:16:40+00:00",
"data": { "order_id": "01jf3k…", "id": "01jf3k…", "reference": "INV-10023", "phone_number": "0241234567",
"bundle": "MTN-1GB", "size_gb": 1, "amount": "4.50", "status": "delivered", … } }
- Answer with any
2xxwithin 10 seconds. Do slow work after answering. - No 2xx: we retry after 30s, 1m, 5m, 30m, 2h, 6h, 12h and 24h, then stop.
- Events can arrive more than once or out of order: use
X-OrderMart-Deliveryto skip repeats, and trust thestatusin the body (delivered/failedare final).
Verify the signature
Header format: t=<unix time>,v1=<hex>. Compute HMAC-SHA256 of "<t>.<raw body>" with your secret, compare in constant time, and reject anything older than 5 minutes. Always use the raw request body, not re-encoded JSON.
<?php
$raw = file_get_contents('php://input');
$header = $_SERVER['HTTP_X_ORDERMART_SIGNATURE'] ?? '';
parse_str(str_replace(',', '&', $header), $sig); // ['t' => …, 'v1' => …]
$expected = hash_hmac('sha256', ($sig['t'] ?? '') . '.' . $raw, getenv('ORDERMART_WEBHOOK_SECRET'));
if (!hash_equals($expected, $sig['v1'] ?? '') || abs(time() - (int) ($sig['t'] ?? 0)) > 300) {
http_response_code(401); exit;
}
$event = json_decode($raw, true);
http_response_code(200); // answer first, then update your records
updateOrder($event['data']['reference'], $event['data']['status']);import crypto from 'node:crypto';
// Express: app.post('/hooks/ordermart', express.raw({ type: 'application/json' }), handler)
function handler(req, res) {
const raw = req.body.toString('utf8');
const parts = Object.fromEntries(req.get('X-OrderMart-Signature').split(',').map(p => p.split('=')));
const expected = crypto.createHmac('sha256', process.env.ORDERMART_WEBHOOK_SECRET)
.update(`${parts.t}.${raw}`).digest('hex');
const ok = expected.length === (parts.v1 || '').length &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1)) &&
Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
if (!ok) return res.sendStatus(401);
res.sendStatus(200);
const event = JSON.parse(raw);
updateOrder(event.data.reference, event.data.status);
}import hmac, hashlib, time, json, os
# Flask
@app.post('/hooks/ordermart')
def ordermart_hook():
raw = request.get_data()
parts = dict(p.split('=', 1) for p in request.headers.get('X-OrderMart-Signature', '').split(','))
expected = hmac.new(os.environ['ORDERMART_WEBHOOK_SECRET'].encode(),
f"{parts.get('t')}.".encode() + raw, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, parts.get('v1', '')) or abs(time.time() - int(parts.get('t', 0))) > 300:
return '', 401
event = json.loads(raw)
update_order(event['data']['reference'], event['data']['status'])
return '', 200Delivery log
The last 100 deliveries with their status (pending, delivered, failed), number of attempts and your server's response code. Resend any of them.