Mock User List API Response
Generate a mock JSON response for a user list endpoint with id, name, email, role, and timestamps. Perfect for frontend development and testing.
Detailed Explanation
User List Endpoint
A user list endpoint is one of the most common API patterns. It returns an array of user objects wrapped in a standard response envelope. This mock demonstrates the typical structure you would expect from a GET /api/users call.
Schema Structure
{
"data": [
{
"id": "uuid",
"name": "string",
"email": "email",
"role": "enum(admin,user,moderator)",
"isActive": "boolean",
"createdAt": "date"
}
]
}
Key Design Decisions
- UUID for IDs — Using UUIDs instead of sequential integers prevents information leakage about the total number of users and avoids collision issues in distributed systems.
- Role as enum — Restricting roles to a fixed set of values (admin, user, moderator) mirrors typical RBAC (Role-Based Access Control) implementations.
- ISO 8601 dates — The
createdAtfield uses the ISO 8601 format, which is the de facto standard for date serialization in JSON APIs. - Boolean isActive — A simple flag for soft-delete or account status, commonly used to filter active users without removing records.
Wrapper Choice
The { "data": [...] } wrapper is the recommended pattern for list endpoints because it leaves room for adding metadata (pagination, filters) at the top level without breaking existing clients.
Use Case
Frontend developers building a user management dashboard can load this mock response into their development environment to test table rendering, sorting, filtering, and role-based UI elements before the backend API is ready.