Reseller Developer API
Connect your system to CityPay: order virtual Mastercards, load balances, track orders and receive signed status webhooks.
1. Getting started
- Create a CityPay account and open Developer API in your dashboard.
- Apply to become a reseller. You'll be notified once approved.
- Top up your prepaid balance. Every order is paid from it at reseller prices.
- Create an API key. It's shown once — store it on your server, never in a browser or app.
- Optionally set a webhook URL to receive status updates.
2. Authentication
Base URL: https://pay.kobicity.com/api/public/v1. Send your key on every request:
Authorization: Bearer cp_live_xxxxxxxxxxxxxxxxxxxx
Paid POST requests (order, load) need a unique Idempotency-Key header (8–100 characters: letters, numbers, . _ : -), e.g. your order ID. Retrying with the same key never charges twice.
Fallback: if you leave out the header but send an external_ref in the body, that reference is used as the key instead. Each reference then counts as one order, so reuse it only for retries. If neither is sent you get 400 idempotency_key_required.
3. Endpoints
/balanceYour prepaid balance and currency/cardsOrder a new virtual card/cardsList your cards (last 200)/cards/{id}Card details incl. full number and CVV/cards/{id}/balanceCard balance (last confirmed)/cards/{id}/checkRequest a live balance check (free)/cards/{id}/loadLoad money onto a card/ordersList your orders (last 200)/orders/{id}Order status4. Order a card
curl -X POST https://pay.kobicity.com/api/public/v1/cards \
-H "Authorization: Bearer cp_live_..." \
-H "Idempotency-Key: order-1001" \
-H "Content-Type: application/json" \
-d '{
"initial_load": 50,
"external_ref": "order-1001"
}'All fields are optional. Every card is issued in your reseller (company) name — CityPay never deals with your buyers. Use external_ref to link the card to your own customer. Response 201:
{ "order": { "id": "…", "type": "create", "status": "Awaiting", "amount": 50,
"charged": 95.5, "currency": "GHS", "external_ref": "order-1001", "created_at": "…" } }5. Load a card
curl -X POST https://pay.kobicity.com/api/public/v1/cards/{card_id}/load \
-H "Authorization: Bearer cp_live_..." \
-H "Idempotency-Key: load-2001" \
-H "Content-Type: application/json" \
-d '{"amount": 100, "external_ref": "load-2001"}'Use the card_id from the order (or from GET /cards) once the card has been issued.
Amount formats: amount (and initial_load when ordering) can be a number (100, 25.5) or a numeric string ("100", "25.50"). It must be greater than 0 and at most 100000, in your account currency, without currency symbols or commas. Your prepaid balance must cover the amount plus the load fee, or you get 402 insufficient_balance.
6. Check a card balance
Read the last confirmed balance instantly:
curl https://pay.kobicity.com/api/public/v1/cards/{card_id}/balance -H "Authorization: Bearer cp_live_..."
{ "card_id": "…", "balance": 42.5, "status": "active", "pending_update": false, "last_updated": "…" }For a fresh balance straight from the card network, request a live check. It's free and needs no body and no Idempotency-Key. Only one check per card is open at a time; asking again while one is open returns that same check (200). You'll get an order.done webhook when it's finished, then call /balance again.
curl -X POST https://pay.kobicity.com/api/public/v1/cards/{card_id}/check \
-H "Authorization: Bearer cp_live_..."
# or, same thing:
curl "https://pay.kobicity.com/api/public/v1/cards/{card_id}/balance?refresh=true" -H "Authorization: Bearer cp_live_..."Every balance read also queues a live check in CityPay's normal Requests queue when none is open for that card — so when your customer taps "Check Balance" in your system, it reaches CityPay just like a regular customer check. Checks are free and never duplicated. pending_update: true means a check or load is still being processed; call /balance again after the order.done webhook for the fresh figure.
7. Status webhooks
When an order changes status, CityPay POSTs JSON to your webhook URL with headers X-CityPay-Event, X-CityPay-Timestamp and X-CityPay-Signature. Reply with any 2xx. Failed deliveries are retried with backoff.
{ "event": "order.done", "order_id": "…", "external_ref": "order-1001", "type": "create",
"status": "Done", "card_id": "…", "amount": 50, "refunded": false, "occurred_at": "…" }Verify the signature = HMAC-SHA256 of {timestamp}.{raw body} with your webhook secret:
// Node.js
const crypto = require("crypto");
const expected = crypto.createHmac("sha256", WEBHOOK_SECRET)
.update(req.headers["x-citypay-timestamp"] + "." + rawBody).digest("hex");
const valid = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(req.headers["x-citypay-signature"]));Canceled orders are refunded to your prepaid balance automatically (refunded: true).
8. Errors
Errors return {"error":{"code","message"}}.
401 unauthorizedMissing or invalid API key403 reseller_inactiveAccount paused or not approved400 idempotency_key_requiredNo Idempotency-Key header and no external_ref402 insufficient_balanceTop up your prepaid balance404 not_foundCard or order isn't yours / doesn't exist409 in_progressSame Idempotency-Key still processing422 invalid_requestBody failed validation429 rate_limitedToo many requests — slow downNeed help? Contact support.
