Skip to main content

Get All Users

Retrieve all registered users (customers) with their profile information. Users are sorted by registration date (newest first).

Authentication

Requires Clerk authentication with admin role. All admin routes are protected by protectRoute and adminOnly middleware.

Response

customers
array
Array of customer user objects
customers[]._id
string
MongoDB ObjectId
customers[].name
string
User’s full name
customers[].email
string
User’s email address (unique)
customers[].imageUrl
string
User’s profile image URL
customers[].addresses
array
Array of saved addresses
addresses[].label
string
Address label (e.g., “Home”, “Work”)
addresses[].fullName
string
Recipient name for this address
addresses[].streetAddress
string
Street address
addresses[].city
string
City
addresses[].phoneNumber
string
Contact phone number
addresses[].isDefault
boolean
Whether this is the default address
customers[].isActive
boolean
Whether the user account is active (default: true)
customers[].documentType
string
Document type: “cedula_ciudadania”, “cedula_extranjeria”, or “pasaporte”
customers[].documentNumber
string
Document number
customers[].gender
string
Gender: “masculino”, “femenino”, or “otro”
customers[].dateOfBirth
string
ISO 8601 date of birth
customers[].createdAt
string
ISO 8601 timestamp of registration
curl -X GET https://api.example.com/api/admin/customers \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "customers": [
    {
      "_id": "507f191e810c19729de860ea",
      "name": "Juan Pérez",
      "email": "[email protected]",
      "imageUrl": "https://img.clerk.com/abc123",
      "addresses": [
        {
          "_id": "507f1f77bcf86cd799439013",
          "label": "Casa",
          "fullName": "Juan Pérez",
          "streetAddress": "Calle 123 #45-67",
          "city": "Bogotá",
          "phoneNumber": "+57 300 1234567",
          "isDefault": true
        }
      ],
      "isActive": true,
      "documentType": "cedula_ciudadania",
      "documentNumber": "1234567890",
      "gender": "masculino",
      "dateOfBirth": "1990-05-15T00:00:00.000Z",
      "createdAt": "2026-01-15T08:30:00.000Z"
    }
  ]
}

Update Customer Status

Activate or deactivate a customer account. Inactive accounts may have restricted access.

Authentication

Requires Clerk authentication with admin role.

Path Parameters

customerId
string
required
MongoDB ObjectId of the customer to update

Request

isActive
boolean
required
New account status. true to activate, false to deactivate.

Response

message
string
Success message indicating activation or deactivation
customer
object
Updated customer object with limited fields
customer._id
string
Customer ID
customer.name
string
Customer name
customer.email
string
Customer email
customer.isActive
boolean
Updated active status
curl -X PATCH https://api.example.com/api/admin/customers/507f191e810c19729de860ea/status \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "isActive": false
  }'
{
  "message": "Customer deactivated successfully",
  "customer": {
    "_id": "507f191e810c19729de860ea",
    "name": "Juan Pérez",
    "email": "[email protected]",
    "isActive": false
  }
}

Error Responses

{
  "message": "isActive must be a boolean"
}

User Model Fields

For reference, the complete User model includes the following fields:
  • email (string, required, unique) - User’s email address
  • name (string, required) - User’s full name
  • imageUrl (string) - Profile image URL from Clerk
  • clerkId (string, required, unique) - Clerk authentication ID
  • stripeCustomerId (string) - Stripe customer ID for payments
  • addresses (array) - Saved shipping addresses
  • wishlist (array of ObjectIds) - References to Product documents
  • isActive (boolean, default: true) - Account active status
  • emailNotifications (boolean, default: true) - Email notification preference
  • marketingEmails (boolean, default: false) - Marketing email opt-in
  • documentType (string) - Document type enum
  • documentNumber (string) - Government ID number
  • gender (string) - Gender enum
  • dateOfBirth (Date) - Date of birth
  • phone (string) - Phone number
  • createdAt (Date) - Auto-generated timestamp
  • updatedAt (Date) - Auto-generated timestamp

Build docs developers (and LLMs) love