Overview
Orders Admin API provides comprehensive order management tools for platform administrators. Includes order listing with filtering, status management, revenue analytics, store performance rankings, and bulk delete operations. All functions require admin authorization. Location:convex/admins/ordersAdmin.ts
Get All Orders
Fetches all orders with filtering and cursor-based pagination. Orders are returned newest first, enriched with customer name, store name, and item count. Supports filtering by status, store, customer, date range, and text search (searches customer name, store name, and order ID).Filter by order status:
pending, preparing, ready, out_for_delivery, delivered, cancelledFilter orders by store. Uses the
by_store index for efficient lookup.Filter orders by customer
Text search across customer name, store name, and order ID (case-insensitive)
Filter orders created on or after this timestamp (milliseconds)
Filter orders created on or before this timestamp (milliseconds)
Pagination options (numItems, cursor)
Get Store Orders
Fetches orders for a specific store with pagination. Returns enriched orders with customer name, phone number, and item count, plus the store name and total order count.Store ID to fetch orders for
Filter by order status:
pending, preparing, ready, out_for_delivery, delivered, cancelledPagination options (numItems, cursor)
Get Order Status Counts
Returns live order counts grouped by status. Used for dashboard cards showing per-status totals. No arguments required.Get Order Statistics
Returns order statistics from the pre-computedadminOrderStats aggregate table. Supports daily or all-time views.
Date in
YYYY-MM-DD format for daily stats. Omit for all-time statistics.When no stats exist for the requested date, all values return as zero. The
averageOrderValue is calculated as totalRevenue / completedOrders.Get Order Details
Fetches full details for a single order, including enriched customer info, store info, order items, and status history timeline.Order ID to retrieve
Status history is sorted chronologically (oldest first). Order items already contain
productName and productImage from the original order.Update Order Status
Admin override to update an order’s status. Records the change in theorderStatusHistory table with the admin marked as a system user type.
Order ID to update
New status:
pending, preparing, ready, out_for_delivery, delivered, cancelledOptional notes explaining the status change. Defaults to a generated message.
Get Revenue Analytics
Returns revenue analytics grouped by time period. Only counts delivered (completed) orders.Start of date range (timestamp in milliseconds)
End of date range (timestamp in milliseconds)
Grouping period:
day, week, or month. Defaults to day.For
week grouping, the period key is the Sunday (start of week) date. For month grouping, the format is YYYY-MM. Results are sorted chronologically.Get Top Stores By Orders
Returns the top performing stores ranked by number of completed (delivered) orders, with revenue metrics.Maximum number of stores to return. Defaults to 10.
Filter orders created on or after this timestamp (milliseconds)
Filter orders created on or before this timestamp (milliseconds)
Bulk Delete Orders
Permanently deletes multiple orders and their associated status history records. Processes in batches of 50 using internal mutations.Array of order IDs to delete
This is a Convex action that delegates to internal mutations in batches of 50. Each order’s status history entries from
orderStatusHistory are deleted before the order itself. Returns zero counts if an empty array is passed.