data-hub

Prosperous Data Hub API Documentation

Base URL: http://localhost:4000

Authentication header for protected endpoints:

Authorization: Bearer <jwt_token>

Idempotency header for funding and bundle purchase:

x-idempotency-key: <unique-key>

Auth Endpoints

POST /api/auth/register

Request:

{
  "fullName": "Kwame Mensah",
  "email": "kwame@example.com",
  "phone": "233501234567",
  "password": "StrongPass123"
}

POST /api/auth/login

Request:

{
  "email": "kwame@example.com",
  "password": "StrongPass123"
}

GET /api/auth/me

Returns active JWT identity.

Wallet Endpoints

GET /api/wallet/balance

Returns wallet available and locked balance.

Payment Endpoints (MoMo)

POST /api/payment/initiate

Headers:

Request:

{
  "amount": 50,
  "momoNumber": "233501234567",
  "provider": "MTN"
}

Response:

POST /api/payment/callback

Provider callback endpoint.

Callback auth:

Request:

{
  "externalReference": "PAY-xxxx",
  "status": "SUCCESS",
  "providerReference": "SIM-xxxx",
  "reason": "optional",
  "signature": "callback_secret_token"
}

Paystack webhook payload is also accepted:

{
  "event": "charge.success",
  "data": {
    "reference": "PAY-xxxx",
    "status": "success",
    "id": 123456
  }
}

Signature options:

On SUCCESS:

On FAILED:

Provider Signing Details

Outbound payment-initiation requests are signed.

Data Bundle Endpoints

GET /api/data/bundles

Returns available bundle catalog grouped by network.

POST /api/data/buy

Headers:

Request:

{
  "network": "MTN",
  "bundleCode": "MTN_1GB",
  "phoneNumber": "233501234567"
}

Flow:

  1. Wallet debit in DB transaction with row lock
  2. Data purchase request to VTU provider
  3. If provider success: mark delivered
  4. If provider fails: automatic wallet refund and mark failed_refunded

Transaction Endpoints

GET /api/transactions?limit=50

Returns user transaction history.

Admin Endpoints

All require admin role.

GET /api/admin/users?limit=100

List users.

GET /api/admin/transactions?limit=200

List all transactions.

GET /api/admin/transactions/failed?limit=200

View failed and refund-related transactions.

POST /api/admin/refund

Request:

{
  "transactionId": "uuid",
  "reason": "Customer escalation case"
}

Rules:

Health

GET /health

Service health check.