Skip to main content

Get Customers

GET /api/admin/customers?search=john&limit=10&page=1
Retrieves a paginated list of customers with their statistics, including total spent and order information. Authentication: Admin access required

Query Parameters

Search customers by username or email (case-insensitive)
limit
number
default:"10"
Number of customers to return per page
page
number
default:"1"
Page number for pagination

Response

success
boolean
Indicates if the request was successful
users
array
Array of user objects with spending statistics
stats
object
pagination
object

Response Example

{
  "success": true,
  "users": [
    {
      "_id": "user123",
      "username": "john_doe",
      "email": "[email protected]",
      "wallet": {
        "address": "TXYZabc123..."
      },
      "isActive": true,
      "createdAt": "2025-12-01T10:00:00.000Z",
      "lastLogin": "2026-03-04T08:30:00.000Z",
      "totalSpent": 1250.50
    }
  ],
  "stats": {
    "total": 180,
    "totalVolume": 50000,
    "totalChange": "+12.5%",
    "volumeChange": "+8.3%"
  },
  "pagination": {
    "total": 180,
    "page": 1,
    "pages": 18,
    "limit": 10
  }
}

Block/Unblock Customer

PATCH /api/admin/customers/:id/block
Blocks or unblocks a customer account by updating their isActive status. Authentication: Admin access required

Path Parameters

id
string
required
Customer user ID

Body Parameters

isActive
boolean
required
Set to false to block the user, true to unblock

Request Example

{
  "isActive": false
}

Response

success
boolean
Indicates if the request was successful
message
string
Confirmation message (“User blocked” or “User unblocked”)
user
object

Response Example

{
  "success": true,
  "message": "User blocked",
  "user": {
    "_id": "user123",
    "username": "john_doe",
    "email": "[email protected]",
    "isActive": false
  }
}

Error Responses

{
  "error": "User not found"
}

Export Customers

POST /api/admin/customers/export
Exports all customer data as a CSV file including username, email, wallet address, total spent, active status, and timestamps. Authentication: Admin access required

Response

Returns a CSV file with the following columns:
  • id - User ID
  • username - Username
  • email - Email address
  • walletAddress - Wallet address
  • totalSpent - Total amount spent (completed - refunded orders)
  • isActive - Active status (true/false)
  • createdAt - Account creation date (ISO 8601)
  • lastLogin - Last login date (ISO 8601)
Content-Type: text/csv Content-Disposition: attachment; filename="customers.csv"

CSV Example

"id","username","email","walletAddress","totalSpent","isActive","createdAt","lastLogin"
"user123","john_doe","[email protected]","TXYZabc123...","1250.50","true","2025-12-01T10:00:00.000Z","2026-03-04T08:30:00.000Z"

Error Response

{
  "error": "Error message"
}

Build docs developers (and LLMs) love