Overview
Customers Admin API provides tools for platform administrators to view customer statistics, list and search customers, inspect detailed customer profiles, manage account status, and perform bulk deletions. All functions require admin authorization. Location:convex/admins/customersAdmin.ts
Get Customer Statistics
Returns aggregate customer statistics for the admin dashboard. Includes total counts, activity breakdowns, growth metrics, and high-value customer count. No arguments required.High-value customers are defined as the top 10% by total spending. Verified customers are those with either a verified phone number or verified email. Growth metrics use rolling time windows (24h, 7d, 30d).
Get All Customers
Fetches a paginated list of customers with optional filtering. Returns enriched customer data including avatar URLs, order statistics, and verification status.Filter by account status:
active or inactiveText search across name, username, email, and phone number (case-insensitive)
When
true, filters to only the top 10% of customers by total spendingPagination options (numItems, cursor)
Get Customer Details
Fetches detailed information about a specific customer, including their profile, recent orders (last 10), and saved addresses with resolved city and area names.Customer ID to retrieve
The
orderNumber field uses the order’s _id. Customer stats (totalOrders, totalSpent, lastOrderDate) are flattened from the nested stats object for easier access. City and area names are resolved from their respective reference tables.Update Customer Status
Activates or deactivates a customer account. Sets theisActive flag on the customer record.
Customer ID to update
Set to
true to activate or false to deactivate the accountOptional reason for the status change (for audit purposes)
Bulk Delete Customers
Permanently deletes multiple customers and all their related data. Processes in batches of 10 using internal mutations. Related data deleted includes: addresses, store follows, customer follows, followers, product likes, carts, search history, and avatar storage files.Array of customer IDs to delete
This is a Convex action that delegates to internal mutations in batches of 10 (smaller than other bulk operations because each customer has many related records). The
relatedDeleted count includes all associated records: addresses, follows, likes, carts, search history, and avatar files. Returns zero counts if an empty array is passed.