REST API
Customers

Customers

All routes under /api/v1/customers require authentication.

Customer Segments

SegmentCriteria
NewFirst purchase within last 30 days
Regular3+ purchases in last 90 days
VIPTop 10% by spend
Occasional< 3 purchases in 90 days

GET /customers

List customers with filtering and pagination.

Auth: Required

Query Parameters:

ParameterTypeDescription
searchstringSearch by name/phone
segmentstringFilter by segment
has_creditbooleanOnly customers with open credit
pageintPage number
page_sizeintItems 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.