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 customer APIs when your backend needs to store reusable customer records for payments and reporting.

Create a customer

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

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

const customer = await moflay.customers.create({
  phoneNumber: "254712345678",
  name: "Jane Doe",
  description: "VIP customer",
  metadata: {
    externalUserId: "user_123",
  },
});

console.log(customer.id);

Get a customer

const customer = await moflay.customers.getOne({
  id: "cus_GqfKXLmg61LURZhB",
});

console.log(customer);

Update a customer

const customer = await moflay.customers.update({
  id: "cus_GqfKXLmg61LURZhB",
  name: "Jane Wanjiku",
  metadata: {
    externalUserId: "user_123",
    segment: "premium",
  },
});

List customers

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

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

Delete a customer

await moflay.customers.delete({
  id: "cus_GqfKXLmg61LURZhB",
});

Required permissions

OperationPermission
List or get customerscustomers.read
Create, update, or delete customerscustomers.write