Skip to main content
POST
/
auth
/
login.php
Login
curl --request POST \
  --url https://api.example.com/auth/login.php \
  --header 'Accept: <accept>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "email": "<string>",
  "password": "<string>"
}
'
{
  "400": {},
  "401": {},
  "403": {},
  "404": {},
  "500": {},
  "success": true,
  "message": "<string>",
  "user": {
    "id": 123,
    "uuid": "<string>",
    "nombre": "<string>",
    "apellido": "<string>",
    "email": "<string>",
    "telefono": "<string>",
    "tipo_usuario": "<string>",
    "calificacion": 123,
    "creado_en": "<string>",
    "location": {}
  },
  "token": "<string>",
  "token_expires_at": "<string>"
}

Endpoint

POST /auth/login.php
Authenticate a user with email and password credentials.

Headers

Content-Type
string
required
Must be application/json
Accept
string
required
Must be application/json

Request Body

email
string
required
User’s email address
password
string
required
User’s password

Response

success
boolean
required
Indicates if login was successful
message
string
Success or error message
user
object
Authenticated user object with complete profile
token
string
Authentication token (currently null, reserved for future use)
token_expires_at
string
Token expiration timestamp (currently null)

Request Example

curl -X POST https://76.13.114.194/auth/login.php \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "email": "carlos.rodriguez@example.com",
    "password": "SecurePass123!"
  }'

Response Example

{
  "success": true,
  "message": "Login exitoso",
  "user": {
    "id": 456,
    "uuid": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "nombre": "Carlos",
    "apellido": "Rodríguez",
    "email": "carlos.rodriguez@example.com",
    "telefono": "+573001234567",
    "tipo_usuario": "pasajero",
    "calificacion": 4.8,
    "creado_en": "2024-01-15T10:30:00.000Z",
    "actualizado_en": "2024-03-15T14:30:00.000Z",
    "location": {
      "id": 89,
      "usuario_id": 456,
      "direccion": "Carrera 15 #85-30",
      "latitud": 4.6814,
      "longitud": -74.0479,
      "ciudad": "Bogotá",
      "departamento": "Cundinamarca",
      "pais": "Colombia",
      "es_principal": true
    }
  },
  "token": null,
  "token_expires_at": null
}

Error Responses

400
Bad Request
Missing required fields or invalid request format
401
Unauthorized
Invalid email or password combination
403
Forbidden
User account is inactive or suspended
404
Not Found
User with provided email does not exist
500
Internal Server Error
Server error during authentication

Session Management

After successful login, store the user data securely:
import 'package:shared_preferences/shared_preferences.dart';

// Store user session
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('user_id', userData['id']);
await prefs.setString('user_email', userData['email']);
await prefs.setString('user_type', userData['tipo_usuario']);

// Retrieve user session
final userId = prefs.getInt('user_id');
final userEmail = prefs.getString('user_email');
Never store passwords locally. Only store the user ID and non-sensitive information.

User Types

The tipo_usuario field indicates the user’s role:
  • pasajero - Regular passenger who can book rides
  • conductor - Driver who can accept and complete trips
  • admin - Administrator with access to admin endpoints
  • empresa - Company/fleet manager
Use this field to determine which features to show in your application.

See Also

Build docs developers (and LLMs) love