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

Install

Get the MpesaFlow Typescript SDK.
npm install @mpesaflow/sdk
2

Add Authentcation

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

const mpesaFlow = new MpesaFlow({
  token: "MPESAFLOW_API_KEY",
});
3

Send your first payment

Send your first payment with the MpesaFlow SDK.
server.ts
import { MpesaFlow } from "@mpesaflow/sdk";

const mpesaFlow = new MpesaFlow({
  token: "MPESAFLOW_API_KEY",
});

async function run() {
  const result = await mpesaFlow.express.pay({
    phoneNumber: "254712345678",
    amount: "100.00",
    transactionDesc: "mpesaflow",
    customerName: "John Doe",
    accountReference: "mpesaflow",
  });

  console.log(result);
}

run();

Examples

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