Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.moflay.com/llms.txt

Use this file to discover all available pages before exploring further.

Use @moflay/sdk when you want the fastest path to a working Moflay integration in Node.js or TypeScript.

Prerequisites

Install the SDK

npm install @moflay/sdk

Authenticate the client

import { Moflay } from "@moflay/sdk";

const moflay = new Moflay({
  token: process.env.MOFLAY_API_KEY!,
});

Send an express payment

const payment = await moflay.express.pay({
  phoneNumber: "254712345678",
  amount: 1000,
  description: "Order 1001",
  accountReference: "ORDER1001",
});

console.log(payment.paymentId, payment.status);

Add customer details

const payment = await moflay.express.pay({
  phoneNumber: "254712345678",
  customerName: "Jane Doe",
  amount: 250000,
  description: "Plan",
  accountReference: "SUB202604",
  metadata: {
    orderId: "SUB-2026-04",
  },
});

Read customers and transactions

const transactions = await moflay.transactions.list({ limit: 10 });

for await (const page of transactions) {
  console.log(page.data);
}
const customers = await moflay.customers.list({ limit: 10 });

for await (const page of customers) {
  console.log(page.data);
}

Amounts

Send payment amounts as integer minor currency units. For example, amount: 1000 means KES 10.00.

SDK vs raw HTTP

Use the SDK whenUse raw HTTP when
Your backend uses Node.js or TypeScriptYour backend uses another language
You want typed request and response helpersYou want direct control over HTTP behavior
You prefer SDK pagination helpersYou already have an HTTP client abstraction