OrderMart API v1

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

https://www.ordermartgh.com/api/v1

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).

X-API-Key: omk_live_Ab12Cd34_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  • 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

pending→processing→deliveredorfailed
StatusMeaning
pendingPaid 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.
processingAccepted and being delivered.
deliveredThe bundle was delivered. Final.
failedThe 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_codeWhat happened / what to do
NUMBER_NOT_VALIDATEDMTN refused the number while delivering (its approved list changed after the order was taken). You are refunded. Order again once it is approved.
INVALID_NUMBERThe network refused the number.
NOT_DELIVEREDThe network could not deliver it.
Get status changes pushed to you with webhooks instead of asking again and again. If you do poll, once every minute or two per order is plenty.

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, header Idempotent-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

HTTPcodeWhen
401UNAUTHORIZEDMissing, wrong or revoked API key
403IP_NOT_ALLOWEDKey is locked to other IP addresses
403ACCOUNT_SUSPENDEDAccount suspended
402INSUFFICIENT_BALANCEWallet doesn't cover the order. Nothing charged.
402CREDIT_LIMIT_REACHEDEnd-of-day account: credit limit reached until a bill is paid
409DUPLICATE_ORDERSame number + bundle within 30 min (see above)
409REFERENCE_CONFLICTReference already used for a different order
422INVALID_NUMBERNot a valid Ghana mobile number
422NEW_NUMBERFirst-time MTN number that MTN has not approved yet. Not accepted and nothing charged. Order it again once approved.
422INVALID_PRODUCTUnknown or unavailable bundle code
422VALIDATION_ERRORMissing or badly formed fields; details lists them
404NOT_FOUNDNo such order / bill (or not yours)
429RATE_LIMITEDToo many requests; wait Retry-After seconds
500INTERNAL_ERROROur 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

GET/me
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

GET/balance
{ "success": true, "data": { "billing": "prepaid", "balance": "1540.75", "credit_limit": null,
  "credit_used": null, "available_to_spend": "1540.75", "currency": "GHS" } }

Bundles & prices

GET/bundles?network=MTN

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

POST/orders
FieldTypeDescription
phone_numberstringrequiredGhana mobile number
bundlestringrequiredBundle code from /bundles, e.g. MTN-1GB
referencestringrecommendedYour transaction id (see References)
allow_duplicatebooleanoptionalAllow 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

POST/orders/bulk

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.

FieldTypeDescription
ordersarrayEach: phone_number, bundle, optional reference
allow_duplicatesbooleanAllow 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": "…" } } ] } }
Sending the same batch again is safe when each line has a reference: lines already placed come back with "replayed": true and are not charged again.

Get an order

GET/orders/{id}
curl https://www.ordermartgh.com/api/v1/orders/01jf3k2m9x8y7z6w5v4t3s2r1q \
  -H "X-API-Key: $KEY"

Find by reference

GET/orders/reference/{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

GET/orders?status=&phone_number=&reference=&batch_id=&from=&to=&page=&per_page=

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"

POST/orders/{id}/report

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

POST/numbers/precheck

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

GET/transactions?page=&per_page=

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

GET/bills?status=unpaid
GET/bills/{id}

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.

PUT/webhook { "url": "https://your-site.com/hooks/ordermart" }
GET/webhook
POST/webhook/rotate-secret
DELETE/webhook
The signing 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

EventWhen
order.processingThe order was accepted for delivery
order.deliveredDelivered. Final.
order.failedCould 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 2xx within 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-Delivery to skip repeats, and trust the status in the body (delivered/failed are 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 '', 200

Delivery log

GET/webhook/deliveries
POST/webhook/deliveries/{id}/resend

The last 100 deliveries with their status (pending, delivered, failed), number of attempts and your server's response code. Resend any of them.