Customers
Manage customer profiles and track their payment history.
The Customers API allows you to create, retrieve, update, and manage customer profiles associated with your merchant account.
Create a customer
API reference (full request schema): Create customer
Essentials: name is required. Pass email, phone_number, whatsapp_number, address fields, is_business, and metadata as needed for checkout prefill and your CRM.
import { LomiSDK } from '@lomi./sdk';
const lomi = new LomiSDK({
apiKey: process.env.LOMI_SECRET_KEY!,
environment: 'live',
});
const customer = await lomi.customers.create({
name: 'Amadou Ba',
email: 'amadou.ba@example.com',
phone_number: '+221771234567',
country: 'Senegal',
city: 'Dakar',
is_business: false,
metadata: {
internal_id: 'USER_123',
},
});
console.log(`Customer created: ${customer.id}`);from lomi import LomiClient
import os
client = LomiClient(
api_key=os.environ["LOMI_SECRET_KEY"],
environment="test"
)
customer = client.customers.create({
"name": "Amadou Ba",
"email": "amadou.ba@example.com",
"phone_number": "+221771234567",
"country": "Senegal",
"city": "Dakar",
"is_business": False,
"metadata": {"internal_id": "USER_123"}
})
print(f"Customer created: {customer['id']}")curl -X POST "https://api.lomi.africa/customers" \
-H "X-API-KEY: $LOMI_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Amadou Ba",
"email": "amadou.ba@example.com",
"phone_number": "+221771234567",
"country": "Senegal",
"city": "Dakar",
"is_business": false,
"metadata": {"internal_id": "USER_123"}
}'List customers
API reference: List customers, search, type, status, page, and pageSize.
const customers = await lomi.customers.list({
search: 'amadou',
type: 'individual',
status: 'active',
page: 1,
pageSize: 20,
});customers = client.customers.list(
search="amadou",
type="individual",
status="active",
page=1,
pageSize=20
)curl -X GET "https://api.lomi.africa/customers?search=amadou&type=individual&page=1&pageSize=20" \
-H "X-API-KEY: $LOMI_SECRET_KEY"Response
{
"customers": [...],
"pagination": {
"page": 1,
"pageSize": 20,
"totalCount": 150,
"totalPages": 8
}
}Get a customer
API reference: Get customer
const customer = await lomi.customers.get('cus_abc123...');customer = client.customers.get('cus_abc123...')curl -X GET "https://api.lomi.africa/customers/cus_abc123..." \
-H "X-API-KEY: $LOMI_SECRET_KEY"Update a customer
API reference: Update customer, all body fields are optional.
const updated = await lomi.customers.update('cus_abc123...', {
email: 'new.email@example.com',
metadata: { vip: true },
});updated = client.customers.update('cus_abc123...', {
"email": "new.email@example.com",
"metadata": {"vip": True}
})curl -X PATCH "https://api.lomi.africa/customers/cus_abc123..." \
-H "X-API-KEY: $LOMI_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "new.email@example.com"}'Delete a customer
API reference: Delete customer
await lomi.customers.delete('cus_abc123...');client.customers.delete('cus_abc123...')curl -X DELETE "https://api.lomi.africa/customers/cus_abc123..." \
-H "X-API-KEY: $LOMI_SECRET_KEY"Get customer transactions
API reference: Customer transactions
const transactions = await lomi.customers.getTransactions('cus_abc123...');
transactions.forEach(tx => {
console.log(`${tx.description}: ${tx.gross_amount} ${tx.currency_code}`);
});transactions = client.customers.get_transactions('cus_abc123...')
for tx in transactions:
print(f"{tx['description']}: {tx['gross_amount']} {tx['currency_code']}")curl -X GET "https://api.lomi.africa/customers/cus_abc123.../transactions" \
-H "X-API-KEY: $LOMI_SECRET_KEY"Response
[
{
"transaction_id": "tx_def456...",
"description": "Payment for Product A",
"gross_amount": 10000,
"currency_code": "XOF",
"status": "completed",
"created_at": "2024-01-15T10:30:00Z"
}
]Create customer portal launch session
API reference: Portal launch session
Generate a one-time hosted customer portal URL from your backend. Returns launch_url for redirect. See Customer portal for flows, security, and production checklist.
import axios from 'axios';
const { data: launch } = await axios.post(
'https://api.lomi.africa/customers/cus_abc123.../portal-launch-session',
{
return_url: 'https://merchant.example.com/account',
flow_type: 'subscription_cancel',
flow_subscription_id: 'sub_abc123...',
flow_after_completion_url:
'https://merchant.example.com/account/subscription-cancelled',
},
{
headers: {
'X-API-KEY': process.env.LOMI_SECRET_KEY!,
'Content-Type': 'application/json',
},
},
);
window.location.href = launch.launch_url;curl -X POST "https://api.lomi.africa/customers/cus_abc123.../portal-launch-session" \
-H "X-API-KEY: $LOMI_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"return_url": "https://merchant.example.com/account",
"flow_type": "subscription_cancel",
"flow_subscription_id": "sub_abc123...",
"flow_after_completion_url": "https://merchant.example.com/account/subscription-cancelled"
}'