Skip to main content
The @moflay/sdk is a type-safe Typescript SDK that allows you to access the resources and methods of the Moflay REST API.
1

Install

Get the Moflay Typescript SDK.
npm install @moflay/sdk
2

Add Authentication

Add your Moflay API Key into the SDK. You can get or create an API Key through the Moflay Dashboard.
server.ts
import { Moflay } from "@moflay/sdk";

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

Send your first payment

Send your first payment with the Moflay SDK. Here’s a basic example of how to send a payment.
server.ts
import { Moflay } from "@moflay/sdk";

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

async function run() {
  const result = await moflay.express.pay({
    phoneNumber: "254712345678",
    customerName: "John Doe",
    customerEmail: "[email protected]",
    amount: 100,
    description: "Payment for services",
    accountReference: "moflay",
  });

  console.log(result);
}

run();

Examples

Learn how to use Moflay SDK through the following categories of examples: