MojoPay Omni Docs

OpenAPI 3.0 specification for the MojoPay Omni API. Import the raw YAML file into Postman, Insomnia, or your codegen tool.

openapi: 3.0.3
info:
  title: MojoPay Omni API
  version: "1.0"
  description: |
    HTTPS JSON API for collections (including dynamic bank virtual accounts), hosted checkout, customers and static virtual accounts, payouts, bank and mobile verification, mandates, reference metadata, and wallet balance.

    **Direct debit flow:** POST `/v1/mandates`, then GET `/v1/mandates` until succeeded, then POST `/v1/mandates/{mandate_id}/debits`. Create returns `processing`; poll GET (or wait for `mandate.succeeded`) before debiting.

    Errors return an `ApiError` object: `error.code`, `error.message`, `error.request_id`, and optional `error.doc_url` for more detail.
    `request_id` values look like `REQ_` + 12 uppercase alphanumeric characters.
    On POST requests that create or move money (or create checkout sessions or mandates), send an `Idempotency-Key` header. Reuse the same key only when safely retrying the **same** JSON body.

    **Integration quick start:** See `/doc` for credentials setup, hosted checkout curl examples, webhook signature verification (PHP/Node), and an integration checklist. Sample JSON bodies: `/doc/samples.json`. Portal Mojo Ai can help debug Omni API payloads against the same guide.

    **Testing mode:** New merchants start in Testing mode on live rails. Money-in (`POST /v1/collections` and fixed-amount `POST /v1/checkout/sessions`, plus amounts entered on `/pay/{id}`) is capped to a per-country max until Go Live. `amount_mode: open` is not allowed while Testing. Details: `/doc#testing-mode`.

    **Required headers on authenticated requests:** `Authorization: Bearer {token}`, `Content-Type: application/json`, `Accept: application/json`.
    **Sub-accounts (when enabled for your merchant):** also send `X-Mojo-Account-Ref` with the target account ref on every request except `GET /v1/metadata/*` and `GET /v1/balance`. Use `GET /v1/account` to verify the resolved account.
    **Money-moving POSTs also require:** `Idempotency-Key` (UUID recommended; reuse only when retrying the same body).

    **Webhooks** (configured per API client in the merchant portal): at-least-once delivery with `MojoPay-Signature` to the client that created the resource. Event types (v1.0): `collection.processing|succeeded|failed`, `checkout_session.processing|succeeded|failed`, `payout.processing|succeeded|failed`, `mandate.processing|succeeded|cancelled`, `mandate_debit.processing|succeeded|failed`, and subscription lifecycle events (`subscription.created`, `subscription.active`, `subscription.cancelled`, `subscription.failed`, `subscription.charge_failed`) when linked to plans. Event `id` values look like `EVT_` + 24 uppercase alphanumeric characters. Verify HMAC on `{timestamp}.{raw_body}`; reject timestamps outside ±300 seconds. Portal-created pay links do not emit outbound webhooks.

    **Security:** Bearer tokens are merchant-scoped; resource lookups never expose another tenant’s data (404). Optional API IP allowlist is configured in the portal. Portal **Team member** users can view activity but cannot change API clients, webhooks, or financial settings.

    **Wallet balance (`GET /v1/balance`):** `collection_wallet` is the **available** (T+1-released) collection balance; `collection_wallet_actual` is total succeeded credits; `collection_wallet_held` is still within the T+1 hold. Payouts draw from `payout_wallet` and must cover the requested amount plus any configured payout fee. Merchants move funds via the portal settlement page or approved auto-settlement.

    **Collection fees:** Staff configure percentage/cap (plus optional per-channel overrides) and a per-merchant fee mode (`on_top` or `absorb`). Responses include `fee_amount`, `fee_mode`, `amount_payable`, and `merchant_settlement_amount`. The **Bank Transfer** channel covers dynamic bank VA and static VA inflows. Dynamic VA follows merchant fee mode (`on_top` opens the temporary account for `amount_payable`). Static VA inflows always absorb (`fee_mode=absorb`, wallet = received − fee) even when merchant mode is `on_top`. See `/doc/payments` collection fees section.

    Rate limits apply to keep the API reliable. When exceeded, responses use HTTP 429 and error code `rate_limited`. OAuth token requests are limited per client; authenticated calls are limited per merchant account.

servers:
  - url: https://omni.mojo-pay.com
    description: Current application (APP_URL)
  - url: https://api.mojopay.com
    description: Production

tags:
  - name: Connect
    description: |
      Get an access token and confirm which merchant or sub-account you are calling as.
  - name: Get paid
    description: |
      Inbound money — charge a mobile money wallet, create a browser pay link, issue a **dynamic**
      (one-order) bank virtual account, or look up payment status.

      **Dynamic vs static bank accounts**

      | | Dynamic (this group) | Static ([Bank accounts](#ref-bank-accounts)) |
      |---|---|---|
      | Purpose | One payment / one order | Reusable standing account |
      | How to issue | `POST /v1/collections` or checkout with `payment_rail=bank_transfer` | `POST /v1/virtual-accounts/merchant` or `/v1/customers/{id}/virtual-account` |
      | Lifetime | Temporary (`expires_at` set) | Permanent until you deactivate |
      | Amount | Fixed to that collection/session | Any amount per transfer |
      | Enablement | Bank transfer on your merchant | **Static VA** on your merchant |
      | Fees | Merchant fee mode (Bank Transfer channel; `on_top` opens VA for `amount_payable`) | Always absorb Bank Transfer fee from received amount |

      Show payers `account_number`, `account_name`, and `bank_name`. Do not reuse a dynamic account after it expires.
  - name: Bank accounts
    description: |
      **Static** virtual bank accounts — reusable standing details for your business or each customer.
      Requires MojoPay to enable **Static VA** on your merchant.

      **Static vs dynamic bank accounts**

      | | Static (this group) | Dynamic ([Get paid](#ref-get-paid)) |
      |---|---|---|
      | Purpose | Reusable standing account | One payment / one order |
      | How to issue | Merchant: `POST /v1/virtual-accounts/merchant`. Customer: create customer → `POST /v1/customers/{id}/virtual-account` | `POST /v1/collections` (or checkout) with `payment_rail=bank_transfer` |
      | Lifetime | Permanent until you deactivate | Temporary (`expires_at` set) |
      | Amount | Any amount per transfer | Fixed to that collection/session |
      | Enablement | **Static VA** | Bank transfer on your merchant |
      | Fees | Always absorb Bank Transfer fee from received amount | Merchant fee mode (shared Bank Transfer channel) |

      **Endpoints in this group**

      - Merchant standing account — `POST/GET /v1/virtual-accounts/merchant` (same as portal overview)
      - Customer dedicated accounts — `/v1/customers` then `/virtual-account`; list inflows; deactivate

      Show payers `account_number`, `account_name`, and `bank_name` together. Do not confuse these with the expiring account returned on dynamic bank-transfer collections.
  - name: Pay out
    description: Send money to mobile money wallets or bank accounts from your payout wallet.
  - name: Direct debit
    description: |
      Recurring charges: POST `/v1/mandates`, then GET `/v1/mandates` until succeeded, then POST `/v1/mandates/{mandate_id}/debits`.

      Create returns `processing`. Poll GET (or wait for `mandate.succeeded`) before debiting. Debit while pending returns HTTP 409.
      After cancel, create starts a fresh mandate. Cancelling one mandate also cancels other local rows that share the same upstream MandateId.
  - name: Subscriptions
    description: Enrol customers on plans you manage in the portal; Omni handles the first charge.
  - name: Name checks
    description: Confirm mobile money or bank account holder names before you pay someone out.
  - name: Wallet & lookups
    description: Check wallet balances and load bank codes / mobile network codes at runtime.

paths:
  /v1/oauth/token:
    post:
      tags: [Connect]
      summary: Get an access token
      operationId: oauthToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OAuthTokenRequest"
      responses:
        "200":
          description: Bearer token issued
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OAuthTokenResponse"
        "400":
          description: invalid_parameter
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "401":
          description: invalid_client
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "403":
          description: Forbidden (e.g. invalid credentials or product not enabled for your account)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "429":
          description: rate_limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/collections:
    post:
      tags: [Get paid]
      summary: Charge a wallet or issue a dynamic bank account
      description: |
        Charge a mobile money wallet, or issue a **dynamic** (temporary) bank virtual account for one order.

        - Omit `payment_rail` (or send `mobile_money`): require `mobile` and `provider`.
        - Send `payment_rail=bank_transfer` for a dynamic VA: bank transfer must be enabled; optional `account_name`;
          do not send `mobile` / `provider`. Response includes `virtual_account` (account number, bank name, `expires_at`).
          Poll or wait for `collection.succeeded`.

        For **static** (reusable) accounts, see [Bank accounts](#ref-bank-accounts) — not this endpoint.
      operationId: createCollection
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCollectionRequest"
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Collection"
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "409":
          description: idempotency_key_mismatch
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "429":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
    get:
      tags: [Get paid]
      summary: Find a payment by your reference
      operationId: getCollectionByMerchantReference
      security: [{ bearerAuth: [] }]
      parameters:
        - name: merchant_reference
          in: query
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Collection"
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/collections/{id}:
    get:
      tags: [Get paid]
      summary: Find a payment by id
      operationId: getCollectionById
      security: [{ bearerAuth: [] }]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Collection"
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/customers:
    post:
      tags: [Bank accounts]
      summary: Create customer
      description: |
        Create a customer record for dedicated static virtual accounts.
        `merchant_reference` is assigned by MojoPay (`CUST-…`); do not send it.
        Requires Static VA on your merchant.
      operationId: createCustomer
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCustomerRequest"
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Customer"
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
    get:
      tags: [Bank accounts]
      summary: List customers
      operationId: listCustomers
      security: [{ bearerAuth: [] }]
      parameters:
        - name: per_page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
      responses:
        "200":
          description: Paginated customer list
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerList"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/customers/{id}:
    get:
      tags: [Bank accounts]
      summary: Get customer
      operationId: getCustomer
      security: [{ bearerAuth: [] }]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Customer public id (`MC_…`)
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Customer"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/customers/{id}/virtual-account:
    post:
      tags: [Bank accounts]
      summary: Issue customer bank account
      description: |
        Issues (or returns) one ACTIVE dedicated static bank account for the customer.
        Cap applies per merchant (default 1000 active customer accounts). Requires Static VA.
      operationId: issueCustomerVirtualAccount
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "201":
          description: Issued or existing active account returned
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerVirtualAccountResponse"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "422":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
    get:
      tags: [Bank accounts]
      summary: Get customer bank account
      operationId: getCustomerVirtualAccount
      security: [{ bearerAuth: [] }]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerVirtualAccountResponse"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/customers/{id}/virtual-account/deactivate:
    post:
      tags: [Bank accounts]
      summary: Deactivate customer bank account
      description: Sets the customer's active dedicated VA to INACTIVE so further Omni credits are rejected.
      operationId: deactivateCustomerVirtualAccount
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerVirtualAccountResponse"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/customers/{id}/collections:
    get:
      tags: [Bank accounts]
      summary: List payments into customer bank account
      operationId: listCustomerCollections
      security: [{ bearerAuth: [] }]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: per_page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
      responses:
        "200":
          description: Paginated collections credited to this customer VA
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/virtual-accounts/merchant:
    post:
      tags: [Bank accounts]
      summary: Issue merchant standing bank account
      description: |
        Creates or returns your merchant standing (static) bank account — the same account shown on the portal overview.
        Requires Static VA. Idempotent: repeat calls return the existing ACTIVE account.
      operationId: issueMerchantVirtualAccount
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      responses:
        "201":
          description: Issued or existing active account returned
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MerchantVirtualAccountResponse"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "422":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
    get:
      tags: [Bank accounts]
      summary: Get merchant standing bank account
      operationId: getMerchantVirtualAccount
      security: [{ bearerAuth: [] }]
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MerchantVirtualAccountResponse"
        "403":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          description: No active merchant virtual account (call POST to issue)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/checkout/sessions:
    post:
      tags: [Get paid]
      summary: Create a browser pay link
      operationId: createCheckoutSession
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCheckoutSessionRequest"
      responses:
        "201":
          description: Created (slim create payload)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CheckoutSessionCreate"
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "409":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/checkout/sessions/{id}:
    get:
      tags: [Get paid]
      summary: Get a pay link
      operationId: getCheckoutSession
      security: [{ bearerAuth: [] }]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CheckoutSession"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/transactions/verify/{merchant_reference}:
    get:
      tags: [Get paid]
      summary: Verify any payment by your reference
      operationId: verifyTransaction
      security: [{ bearerAuth: [] }]
      parameters:
        - name: merchant_reference
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Collection, payout, or checkout snapshot
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/payouts:
    post:
      tags: [Pay out]
      summary: Send money
      operationId: createPayout
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePayoutRequest"
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Payout"
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "409":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/payouts/{merchant_reference}:
    get:
      tags: [Pay out]
      summary: Find a payout by your reference
      operationId: getPayout
      security: [{ bearerAuth: [] }]
      parameters:
        - name: merchant_reference
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Payout"
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/verifications/msisdn:
    post:
      tags: [Name checks]
      summary: Check mobile money name
      operationId: verifyMsisdn
      security: [{ bearerAuth: [] }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [mobile]
              properties:
                mobile:
                  type: string
                  pattern: "^\\d{10,15}$"
                provider:
                  type: string
                  maxLength: 64
      responses:
        "200":
          description: Verification outcome
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VerificationResult"
        "502":
          description: gateway_error (upstream KYC provider failure)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/verifications/bank_accounts:
    post:
      tags: [Name checks]
      summary: Check bank account name
      operationId: verifyBankAccount
      security: [{ bearerAuth: [] }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [bank_code, account_number]
              properties:
                bank_code:
                  type: string
                  maxLength: 32
                  description: Bank code from metadata banks.
                account_number:
                  type: string
                  maxLength: 64
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VerificationResult"
        "502":
          description: gateway_error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/mandates:
    post:
      tags: [Direct debit]
      summary: Set up recurring
      description: >
        Step 1 of the direct debit flow: POST /v1/mandates, then GET /v1/mandates until succeeded, then POST /v1/mandates/{mandate_id}/debits.
        Returns `processing` (HTTP 201). The customer may receive a MoMo approval prompt; poll GET or wait for `mandate.succeeded` before debiting.
        If the MSISDN already has an approved mandate, create may return `succeeded` (reuse) so you can debit immediately.
        A second create while approval is still pending returns HTTP 409 — poll the first merchant_reference.
        Without plan_id this does not auto-debit. Ghana direct debit is MTN only. Requires Idempotency-Key.
      operationId: createMandate
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateMandateRequest"
      responses:
        "201":
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
    get:
      tags: [Direct debit]
      summary: Check recurring status
      description: >
        Step 2 of the direct debit flow: POST /v1/mandates, then GET /v1/mandates until succeeded, then POST /v1/mandates/{mandate_id}/debits.
        Look up by your mandate merchant_reference (not the MD_ id). While `processing`, Omni refreshes from the processor (throttled).
        Debit only after `status` is `succeeded`.
      operationId: listMandates
      security: [{ bearerAuth: [] }]
      parameters:
        - name: merchant_reference
          in: query
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true

  /v1/mandates/{mandate_id}/cancel:
    post:
      tags: [Direct debit]
      summary: Cancel recurring
      description: >
        Stop an approved or pending mandate. Requires Idempotency-Key. Body: mobile, reason.
        The cancel HTTP response may show `status: processing` (request accepted); the mandate row is `cancelled`.
        All local mandates for this merchant that share the same upstream MandateId are cancelled too.
        After cancel, create a new mandate (step 1) — it returns `processing` until the customer approves again.
      operationId: cancelMandate
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
        - name: mandate_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [mobile, reason]
              properties:
                mobile:
                  type: string
                reason:
                  type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true

  /v1/mandates/{mandate_id}/debits:
    post:
      tags: [Direct debit]
      summary: Charge recurring now
      description: >
        Step 3 of the direct debit flow: POST /v1/mandates, then GET /v1/mandates until succeeded, then POST /v1/mandates/{mandate_id}/debits.
        Collect only after the mandate `status` is `succeeded`. Debit while pending returns HTTP 409.
        Required for every charge when you enroll via POST /v1/mandates or POST /v1/subscriptions (later cycles are not automatic).
        Hosted /subscribe enrollments are charged by Omni on the plan frequency. Collection fees apply using the merchant fee mode (on_top or absorb);
        responses include fee_amount, fee_mode, amount_payable, and merchant_settlement_amount.
      operationId: createMandateDebit
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
        - name: mandate_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [amount, currency, merchant_reference, provider]
              properties:
                amount:
                  type: string
                currency:
                  type: string
                  minLength: 3
                  maxLength: 3
                merchant_reference:
                  type: string
                  maxLength: 255
                provider:
                  type: string
                  maxLength: 64
      responses:
        "201":
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true

  /v1/mandate_debits/status:
    get:
      tags: [Direct debit]
      summary: Check recurring charge status
      description: >
        Optional follow-up after step 3. Poll a debit by mandate_id (MD_) and the debit merchant_reference until succeeded or failed.
        You can also wait for mandate_debit.succeeded / mandate_debit.failed webhooks.
      operationId: mandateDebitStatus
      security: [{ bearerAuth: [] }]
      parameters:
        - name: mandate_id
          in: query
          required: true
          schema:
            type: string
        - name: merchant_reference
          in: query
          required: true
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true

  /v1/subscription_plans:
    get:
      tags: [Subscriptions]
      summary: List active subscription plans
      description: Requires the subscriptions product to be enabled for your merchant.
      operationId: listSubscriptionPlans
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/MerchantAccountRef"
      responses:
        "200":
          content:
            application/json:
              schema:
                type: object
                required: [object, data]
                properties:
                  object:
                    type: string
                    example: list
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/SubscriptionPlan"
        "403":
          description: forbidden (subscriptions not enabled)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/subscriptions:
    post:
      tags: [Subscriptions]
      summary: Enroll a subscription
      description: Creates a subscriber and starts mandate enrollment for a subscription plan. Omni charges the plan amount once on approval (or immediately if the MSISDN already has an approved mandate). Later cycles are not automatic — call POST /v1/mandates/{mandate_id}/debits on your schedule. Hosted /subscribe pages are billed by Omni instead.
      operationId: createSubscription
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
        - $ref: "#/components/parameters/MerchantAccountRef"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSubscriptionRequest"
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Subscription"
        "403":
          description: forbidden (subscriptions not enabled)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "422":
          description: validation_error (e.g. invalid or inactive plan_id)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
    get:
      tags: [Subscriptions]
      summary: Get subscription by merchant_reference
      operationId: getSubscription
      security: [{ bearerAuth: [] }]
      parameters:
        - name: merchant_reference
          in: query
          required: true
          schema:
            type: string
        - $ref: "#/components/parameters/MerchantAccountRef"
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Subscription"
        "404":
          description: not_found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

  /v1/metadata/banks:
    get:
      tags: [Wallet & lookups]
      summary: List bank codes
      operationId: metadataBanks
      security: [{ bearerAuth: [] }]
      responses:
        "200":
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true

  /v1/metadata/mobile_providers:
    get:
      tags: [Wallet & lookups]
      summary: List mobile networks
      operationId: metadataMobileProviders
      security: [{ bearerAuth: [] }]
      responses:
        "200":
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true

  /v1/balance:
    get:
      tags: [Wallet & lookups]
      summary: Check wallet balance
      operationId: getBalance
      security: [{ bearerAuth: [] }]
      parameters:
        - name: currency
          in: query
          required: false
          schema:
            type: string
            minLength: 3
            maxLength: 3
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BalanceSnapshot"

  /v1/account:
    get:
      tags: [Connect]
      summary: Check sub-account context
      description: Returns the authenticated merchant and the sub-account resolved from `X-Mojo-Account-Ref` when sub-accounts are enabled.
      operationId: getAccountContext
      security: [{ bearerAuth: [] }]
      parameters:
        - $ref: "#/components/parameters/MerchantAccountRef"
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccountContext"
        "400":
          description: invalid_parameter (missing account header when required)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"
        "404":
          description: not_found (unknown account ref)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiError"

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: opaque
      description: Short-lived access token from POST /v1/oauth/token

  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        maxLength: 255
        example: 7c9e6679-7425-40de-944b-e07fc1f90ae7
      description: Required for money-moving and session/mandate creates; replays must use the same body.

    MerchantAccountRef:
      name: X-Mojo-Account-Ref
      in: header
      required: false
      schema:
        type: string
        pattern: '^[a-z0-9][a-z0-9_-]{2,63}$'
        example: accra-branch
      description: Required when sub-accounts are enabled for the merchant (except metadata and balance routes). Targets the sub-account for this request.

  schemas:
    AccountContext:
      type: object
      required: [object, merchant]
      properties:
        object:
          type: string
          example: account_context
        merchant:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
            sub_accounts_enabled:
              type: boolean
        account:
          type: object
          nullable: true
          properties:
            id:
              type: string
              example: MAC_ABCDEF123456
            object:
              type: string
              example: merchant_account
            account_ref:
              type: string
              example: accra-branch
            name:
              type: string
            status:
              type: string
              example: active

    ApiError:
      type: object
      required: [error]
      properties:
        error:
          type: object
          required: [code, message, request_id]
          properties:
            code:
              type: string
              description: Stable machine-readable error code.
            message:
              type: string
            doc_url:
              type: string
              format: uri
              description: Optional URL with more detail for this error.
            request_id:
              type: string
              description: Correlation id, e.g. REQ_8F3A2C1B9D0E
              example: REQ_8F3A2C1B9D0E

    OAuthTokenRequest:
      type: object
      required: [client_id, client_secret]
      properties:
        grant_type:
          type: string
          enum: [client_credentials]
        client_id:
          type: string
        client_secret:
          type: string

    OAuthTokenResponse:
      type: object
      required: [access_token, token_type, expires_in]
      properties:
        access_token:
          type: string
          description: Opaque 64-character bearer token (not a JWT).
          example: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2
        token_type:
          type: string
          example: Bearer
        expires_in:
          type: integer
          example: 1200
      example:
        access_token: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2
        token_type: Bearer
        expires_in: 1200

    CreateCollectionRequest:
      type: object
      required: [amount, currency, merchant_reference]
      properties:
        amount:
          type: string
          description: >
            Merchant principal to receive. While the merchant is in Testing mode, must be at or below the
            country testing max amount (see `/doc#testing-mode`).
        currency:
          type: string
          minLength: 3
          maxLength: 3
        merchant_reference:
          type: string
        payment_rail:
          type: string
          enum: [mobile_money, bank_transfer]
          default: mobile_money
          description: >
            Optional — omit for mobile money (default). Send `bank_transfer` when you want a **dynamic**
            virtual account for this order (requires bank transfer enabled).
            `mobile_money` requires `mobile` and `provider`. `bank_transfer` must not send those fields;
            response includes `virtual_account` with `expires_at`.
        mobile:
          type: string
          description: Required for mobile money (`payment_rail` omitted or `mobile_money`). Omit for `bank_transfer`.
        provider:
          type: string
          description: >
            Required for mobile money (`payment_rail` omitted or `mobile_money`). Use metadata mobile_providers codes.
            Omit for `bank_transfer`.
        account_name:
          type: string
          description: Optional display name for dynamic bank-transfer virtual accounts (`payment_rail=bank_transfer`).
        description:
          type: string

    Collection:
      type: object
      description: >
        Includes id, status, amounts, and references; fields may vary by payment rail and lifecycle.
        Fee mode is configured per merchant by MojoPay staff (snapshotted on the payment).
        `on_top` (default): `amount` is credited to the merchant; when fees apply, `fee_amount` is charged to the payer
        and `amount_payable` is `amount` + `fee_amount` (`merchant_settlement_amount` equals `amount`).
        `absorb`: `amount` is what the payer pays (`amount_payable` equals `amount`); the merchant settles
        `merchant_settlement_amount` (`amount` − `fee_amount`).
        Dynamic bank transfer creates include a nested `virtual_account` object while awaiting transfer.
        Static VA inflows always snapshot `fee_mode=absorb` via the Bank Transfer channel even when the merchant
        fee mode is `on_top`.
      additionalProperties: true
      properties:
        payment_rail:
          type: string
          enum: [mobile_money, bank_transfer]
        fee_amount:
          type: string
          description: Platform collection fee in the same currency as `amount`.
        fee_mode:
          type: string
          enum: [on_top, absorb]
          description: How the fee is applied for this merchant (snapshotted on the payment).
        amount_payable:
          type: string
          description: Amount charged to the payer / upstream.
        merchant_settlement_amount:
          type: string
          description: Amount credited to the merchant wallet on success.
        virtual_account:
          $ref: "#/components/schemas/VirtualAccount"

    CreateCustomerRequest:
      type: object
      required: [name]
      properties:
        name:
          type: string
          minLength: 2
          maxLength: 255
        email:
          type: string
          format: email
        mobile:
          type: string
          description: Digits only, 10–15 characters.
        merchant_reference:
          type: string
          description: Prohibited — MojoPay assigns `CUST-…`. Do not send.

    Customer:
      type: object
      required: [id, object, merchant_reference, name]
      properties:
        id:
          type: string
          example: MC_PAYMENTS01
        object:
          type: string
          enum: [customer]
        merchant_reference:
          type: string
          example: CUST-A1B2C3D4E5
        name:
          type: string
        email:
          type: string
          nullable: true
        mobile:
          type: string
          nullable: true
        created_at:
          type: string
          format: date-time

    CustomerList:
      type: object
      required: [object, data]
      properties:
        object:
          type: string
          enum: [list]
        data:
          type: array
          items:
            $ref: "#/components/schemas/Customer"
        has_more:
          type: boolean
        total:
          type: integer

    VirtualAccount:
      type: object
      properties:
        account_number:
          type: string
        account_name:
          type: string
        account_type:
          type: string
          enum: [STATIC, DYNAMIC]
        bank_code:
          type: string
        bank_name:
          type: string
        transfer_note:
          type: string
          description: Show this with the account number. Payers must send the transfer with GhIPSS Instant Pay (GIP) only.
          example: Transfers to this account must use GhIPSS Instant Pay (GIP) only. In your bank app, choose Instant Pay, Instant transfer, or GIP — not ACH, RTGS, or another transfer type.
        status:
          type: string
          example: ACTIVE
        expires_at:
          type: string
          format: date-time
          nullable: true
          description: Set for dynamic (per-order) accounts; null for static.
        single_deposit_limit:
          type: string
          nullable: true

    CustomerVirtualAccountResponse:
      type: object
      required: [object, customer_id, virtual_account]
      properties:
        object:
          type: string
          enum: [virtual_account]
        customer_id:
          type: string
        virtual_account:
          $ref: "#/components/schemas/VirtualAccount"

    MerchantVirtualAccountResponse:
      type: object
      required: [object, owner, virtual_account]
      properties:
        object:
          type: string
          enum: [virtual_account]
        owner:
          type: string
          enum: [merchant]
        virtual_account:
          $ref: "#/components/schemas/VirtualAccount"

    CreateCheckoutSessionRequest:
      type: object
      required: [currency, merchant_reference, success_url, cancel_url]
      properties:
        amount_mode:
          type: string
          enum: [fixed, open]
          default: fixed
          description: >
            `fixed` (default) requires `amount` at create time. `open` lets the customer enter the amount on the hosted pay page.
            `open` is not available while the merchant is in Testing mode (use `fixed` at or below the country testing max, or Go Live).
            See `/doc#testing-mode`.
        amount:
          type: string
          description: >
            Required when `amount_mode` is `fixed` (or omitted). Omit for `open`.
            In Testing mode, fixed amounts must be at or below the country testing max.
        currency:
          type: string
        merchant_reference:
          type: string
        payment_rail:
          type: string
          nullable: true
          enum: [mobile_money, card, bank_transfer]
          description: >
            Optional — omit (or send `null`) so the customer chooses the rail on `/pay/{id}` (portal pay links do this).
            `mobile_money` locks the session to mobile money; `mobile` is then required at create unless pre-filled later on the hosted page.
            `card` is accepted only when MojoPay has enabled card checkout for your merchant; otherwise it is rejected with `400` `invalid_parameter`.
            `bank_transfer` locks the session to a **dynamic** virtual account on the pay page (requires bank transfer enabled).
            This omit-means-customer-chooses behavior is different from collections, where omit defaults to mobile money.
        mobile:
          type: string
          description: >
            Required when `payment_rail` is `mobile_money` at create time.
            Omit when the customer will enter wallet details on the hosted page.
        provider:
          type: string
          description: Mobile money provider code when required for the chosen rail (metadata mobile_providers).
        success_url:
          type: string
          format: uri
        cancel_url:
          type: string
          format: uri
        description:
          type: string

    CheckoutSessionCreate:
      type: object
      required: [id, object, status, url, expires_at]
      description: >
        Fixed-amount creates include `currency`, `amount_mode`, `amount`, `fee_amount`, `fee_mode`, `amount_payable`,
        and `merchant_settlement_amount` when fees are computed at create time.
        Open-amount creates omit amount fields until the customer submits an amount on the hosted pay page.
        `expires_at` is typically one hour after create.
      properties:
        id:
          type: string
          example: CS_4NQP81ABCDEF
        object:
          type: string
          enum: [checkout_session]
        status:
          type: string
          enum: [processing]
        currency:
          type: string
          example: GHS
        amount_mode:
          type: string
          enum: [fixed, open]
        amount:
          type: string
          description: >
            Submitted amount. In `on_top` fee mode this is merchant settlement; in `absorb` this is the customer charge.
        fee_amount:
          type: string
          description: Platform fee when fees apply.
        fee_mode:
          type: string
          enum: [on_top, absorb]
        amount_payable:
          type: string
          description: Amount charged to the payer / upstream.
        merchant_settlement_amount:
          type: string
          description: Amount credited to the merchant wallet on success.
        url:
          type: string
          format: uri
        expires_at:
          type: string
          format: date-time
      example:
        id: CS_4NQP81ABCDEF
        object: checkout_session
        status: processing
        currency: GHS
        amount_mode: fixed
        amount: "1.00"
        fee_amount: "0.02"
        fee_mode: on_top
        amount_payable: "1.02"
        merchant_settlement_amount: "1.00"
        url: https://checkout.example.com/pay/CS_4NQP81ABCDEF
        expires_at: "2026-04-15T11:00:00Z"

    CheckoutSession:
      type: object
      additionalProperties: true
      properties:
        id:
          type: string
        object:
          type: string
          enum: [checkout_session]
        status:
          type: string
        currency:
          type: string
        amount_mode:
          type: string
          enum: [fixed, open]
        amount:
          type: string
          nullable: true
        fee_amount:
          type: string
        fee_mode:
          type: string
          enum: [on_top, absorb]
        amount_payable:
          type: string
          nullable: true
        merchant_settlement_amount:
          type: string
          nullable: true
        merchant_reference:
          type: string
        mobile:
          type: string
          nullable: true
        payment_rail:
          type: string
          nullable: true
        provider:
          type: string
          nullable: true
        card_scheme:
          type: string
          nullable: true

    VerificationResult:
      type: object
      required: [status]
      properties:
        status:
          type: string
          enum: [verified, invalid]
        profile:
          type: object
          nullable: true
          properties:
            first_name:
              type: string
            last_name:
              type: string

    BalanceSnapshot:
      type: object
      required: [currency, available, collection_wallet, collection_wallet_actual, collection_wallet_held, payout_wallet, pending]
      properties:
        currency:
          type: string
        available:
          type: string
          description: Total across available collection_wallet and payout_wallet.
        collection_wallet:
          type: string
          description: Available collection balance (released after T+1; movable without instant settlement fee).
        collection_wallet_actual:
          type: string
          description: Total succeeded collection credits on record (actual collection wallet).
        collection_wallet_held:
          type: string
          description: Collection funds still held until the next T+1 release window.
        payout_wallet:
          type: string
        pending:
          type: string
        provider_float:
          type: string
          description: Present when upstream float query succeeds.

    CreatePayoutRequest:
      type: object
      required: [type, currency, amount, merchant_reference]
      properties:
        type:
          type: string
          enum: [mobile_money, bank]
          description: "`mobile_money` requires `mobile` and `provider`. `bank` requires `account_number` and `bank_code`."
        currency:
          type: string
        amount:
          type: string
        merchant_reference:
          type: string
        mobile:
          type: string
          description: Required when `type` is `mobile_money`.
          x-required-when: type is mobile_money
        provider:
          type: string
          description: Required when `type` is `mobile_money`. Use a network code from metadata.
          x-required-when: type is mobile_money
        account_number:
          type: string
          maxLength: 64
          description: Required when `type` is `bank`.
          x-required-when: type is bank
        bank_code:
          type: string
          maxLength: 32
          description: Required when `type` is `bank`. Bank code from `GET /v1/metadata/banks`. Do not send a bank name.
          x-required-when: type is bank
        narration:
          type: string
        transaction_type:
          type: string
        transaction_date:
          type: string
        expires_at:
          type: string

    Payout:
      type: object
      description: >
        `amount` is what the recipient receives. When a per-merchant payout fee applies, `fee_amount` is charged
        on top from the merchant payout wallet and `amount_debited` is `amount` + `fee_amount`.
      additionalProperties: true
      properties:
        amount:
          type: string
          description: Amount sent to the recipient.
        fee_amount:
          type: string
          description: Payout fee debited from the merchant payout wallet (may be "0.00").
        amount_debited:
          type: string
          description: Total debit from the payout wallet (`amount` + `fee_amount`).
        merchant_reference:
          type: string
        status:
          type: string
        currency:
          type: string

    CreateMandateRequest:
      type: object
      required: [mobile, provider, currency, amount, frequency, starts_at, merchant_reference]
      properties:
        mobile:
          type: string
        provider:
          type: string
        currency:
          type: string
        amount:
          type: string
        frequency:
          type: string
          enum: [DAILY, WEEKLY, MONTHLY]
        starts_at:
          type: string
          format: date-time
        merchant_reference:
          type: string
        description:
          type: string
        plan_id:
          type: string
          description: When set, links the mandate to a subscription plan and creates a subscriber.
        customer_name:
          type: string
          description: Required when plan_id is set.
        customer_email:
          type: string
          format: email
          description: Required when plan_id is set.
        notes:
          type: string

    SubscriptionPlan:
      type: object
      required: [object, plan_id, name, currency, amount, frequency, status]
      properties:
        object:
          type: string
          example: subscription_plan
        plan_id:
          type: string
          example: PLN_ABCDEF123456
        name:
          type: string
        description:
          type: string
        currency:
          type: string
          minLength: 3
          maxLength: 3
        amount:
          type: string
        frequency:
          type: string
          enum: [DAILY, WEEKLY, MONTHLY]
        duration_type:
          type: string
        duration_months:
          type: integer
          nullable: true
        status:
          type: string
          example: active

    CreateSubscriptionRequest:
      type: object
      required: [plan_id, merchant_reference, customer_name, customer_email, mobile, provider]
      properties:
        plan_id:
          type: string
          example: PLN_ABCDEF123456
        merchant_reference:
          type: string
        customer_name:
          type: string
        customer_email:
          type: string
          format: email
        mobile:
          type: string
          pattern: "^\\d{10,15}$"
        provider:
          type: string
        notes:
          type: string

    Subscription:
      type: object
      additionalProperties: true
      properties:
        object:
          type: string
          example: subscription
        subscription_id:
          type: string
          example: SUB_ABCDEF123456
        status:
          type: string
        merchant_reference:
          type: string
        plan_id:
          type: string
        mandate_id:
          type: string