Skip to main content
POST
/
api
/
auth
/
login
Login
curl --request POST \
  --url https://api.example.com/api/auth/login \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "password": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "user": {
      "_id": "<string>",
      "name": "<string>",
      "email": "<string>",
      "role": "<string>",
      "isActive": true,
      "lastLogin": "<string>",
      "createdAt": "<string>",
      "updatedAt": "<string>"
    },
    "token": "<string>"
  }
}
Authenticates a user with email and password and returns an authentication token.

Authentication

No authentication required. This is a public endpoint.
This endpoint is rate-limited to 5 requests per 15 minutes per IP address.

Request Body

email
string
required
User’s email address. Must be a valid email format. Will be converted to lowercase.
password
string
required
User’s password.

Response

success
boolean
Indicates if the request was successful
message
string
Success message: “Inicio de sesión exitoso”
data
object
user
object
_id
string
Unique user identifier
name
string
User’s full name
email
string
User’s email address (lowercase)
role
string
User’s role. Possible values: “user”, “admin”, “system”
isActive
boolean
Whether the user account is active
lastLogin
string
ISO 8601 timestamp of last login (updated on each successful login)
createdAt
string
ISO 8601 timestamp of account creation
updatedAt
string
ISO 8601 timestamp of last update
token
string
JWT authentication token (expires in 7 days)

Error Responses

401 - Invalid Credentials
{
  "success": false,
  "message": "Credenciales inválidas"
}
Returned when the email doesn’t exist, the password is incorrect, or the account is inactive.
400 - Validation Error
{
  "success": false,
  "message": "Validation failed",
  "errors": [
    {
      "field": "email",
      "message": "Email inválido"
    }
  ]
}
429 - Rate Limit Exceeded
{
  "success": false,
  "message": "Demasiados intentos de autenticación. Intenta en 15 minutos.",
  "retryAfter": 900
}

Examples

curl -X POST https://api.cuido.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecurePass123"
  }'

Response Example

{
  "success": true,
  "message": "Inicio de sesión exitoso",
  "data": {
    "user": {
      "_id": "507f1f77bcf86cd799439011",
      "name": "Juan Pérez",
      "email": "[email protected]",
      "role": "user",
      "isActive": true,
      "lastLogin": "2026-03-05T10:35:00.000Z",
      "createdAt": "2026-03-05T10:30:00.000Z",
      "updatedAt": "2026-03-05T10:35:00.000Z"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1MDdmMWY3N2JjZjg2Y2Q3OTk0MzkwMTEiLCJ0aW1lc3RhbXAiOjE3MDk2MzYxMDAwMDAsImlhdCI6MTcwOTYzNjEwMCwiZXhwIjoxNzEwMjQwOTAwLCJpc3MiOiJjbGF1ZGUtcHJvbXB0LWFwaSIsInN1YiI6IjUwN2YxZjc3YmNmODZjZDc5OTQzOTAxMSJ9.xyz789abc"
  }
}

Notes

  • The lastLogin field is automatically updated on each successful login
  • Only active users (isActive: true) can log in
  • Store the returned token securely and include it in the Authorization header for protected endpoints
  • Tokens expire after 7 days by default

Build docs developers (and LLMs) love