Customers
All routes under /api/v1/customers require authentication.
Customer Segments
| Segment | Criteria |
|---|---|
New | First purchase within last 30 days |
Regular | 3+ purchases in last 90 days |
VIP | Top 10% by spend |
Occasional | < 3 purchases in 90 days |
GET /customers
List customers with filtering and pagination.
Auth: Required
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
search | string | Search by name/phone |
segment | string | Filter by segment |
has_credit | boolean | Only customers with open credit |
page | int | Page number |
page_size | int | Items per page |
Response: Paginated list:
{
"success": true,
"data": {
"items": [
{
"id": "uuid",
"name": "John Doe",
"phone": "+255712345678",
"email": "john@example.com",
"segment": "Regular",
"credit_limit": 50000,
"total_spend": 250000,
"visit_count": 15,
"is_active": true,
"created_at": "2024-01-01T00:00:00Z"
}
],
"total": 150
}
}POST /customers
Create a new customer.
Auth: Required
Request Body:
{
"name": "John Doe",
"phone": "+255712345678",
"email": "john@example.com",
"segment": "Regular",
"credit_limit": 50000,
"notes": "Prefers cash payments",
"is_active": true
}Response: Customer object.
GET /customers/credits
List customers with outstanding credit balances.
Auth: Required
Query: overdue (boolean, filter by overdue status)
Response: Array of customers with credit info.
GET /customers/:id
Get a single customer.
Auth: Required
Response: Customer object.
PATCH /customers/:id
Update a customer. All fields optional.
Auth: Required
Request Body: Same as POST /customers but all fields optional.
Response: Customer object.