Skip to main content
GET
/
api
/
users
List Users
curl --request GET \
  --url https://api.example.com/api/users
{
  "users": [
    {
      "user_id": "<string>",
      "email": "<string>",
      "name": "<string>",
      "surname": "<string>",
      "phone": "<string>",
      "address": "<string>",
      "city": "<string>",
      "country": "<string>",
      "postal_code": "<string>",
      "gender": "<string>",
      "birth_date": "<string>",
      "role": {},
      "status": {},
      "avatar": "<string>",
      "document_type": {},
      "document_number": "<string>",
      "refresh_token": {},
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RobertHernandezArenas/beils-belleza-honesta-dashboard/llms.txt

Use this file to discover all available pages before exploring further.

Retrieves all users from the database, ordered by creation date (newest first). This endpoint is protected and requires authentication.

Authentication

This endpoint requires a valid JWT token. Include the token in one of the following ways:
  • Authorization header: Authorization: Bearer <token>
  • Cookie: auth_token=<token>
The token payload must contain:
  • userId: The authenticated user’s ID
  • email: The authenticated user’s email
  • role: The user’s role (ADMIN or USER)

Authorization

No specific role requirements. All authenticated users can list users.

Request

No request body or query parameters required.

Example Request

curl -X GET https://your-domain.com/api/users \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Response

Returns an array of user objects. The password field is excluded from all responses for security.
users
array
Array of user objects

Success Response (200)

[
  {
    "user_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "email": "maria.garcia@example.com",
    "name": "María",
    "surname": "García",
    "phone": "+34612345678",
    "address": "Calle Mayor 123",
    "city": "Madrid",
    "country": "España",
    "postal_code": "28013",
    "gender": "Femenino",
    "birth_date": "1990-05-15T00:00:00.000Z",
    "role": "USER",
    "status": "ON",
    "avatar": "https://ui-avatars.com/api/?name=María&background=random",
    "document_type": "DNI",
    "document_number": "12345678A",
    "refresh_token": null,
    "created_at": "2024-01-15T10:30:00.000Z",
    "updated_at": "2024-01-15T10:30:00.000Z"
  },
  {
    "user_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    "email": "admin@beils.com",
    "name": "Admin",
    "surname": "Beils",
    "phone": "+34622334455",
    "address": "Avenida Principal 45",
    "city": "Barcelona",
    "country": "España",
    "postal_code": "08001",
    "gender": "Otro",
    "birth_date": "1985-03-20T00:00:00.000Z",
    "role": "ADMIN",
    "status": "ON",
    "avatar": "https://ui-avatars.com/api/?name=Admin&background=random",
    "document_type": "DNI",
    "document_number": "87654321B",
    "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "created_at": "2024-01-01T08:00:00.000Z",
    "updated_at": "2024-01-10T14:20:00.000Z"
  }
]

Error Responses

401 Unauthorized
Token is missing, invalid, or expired
{
  "statusCode": 401,
  "statusMessage": "Unauthorized: Token is missing or invalid"
}
500 Internal Server Error
Database error or server issue
{
  "statusCode": 500,
  "statusMessage": "Error al obtener usuarios"
}

Implementation Details

  • Password Security: The password field is always excluded from responses using destructuring
  • Ordering: Results are sorted by created_at in descending order (newest first)
  • Database: Uses Prisma ORM with MySQL database
  • Middleware: Protected by server/middleware/auth.ts

Build docs developers (and LLMs) love