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>"
}
'
{
  "message": "<string>",
  "accessToken": "<string>",
  "refreshToken": "<string>",
  "user": {
    "id": "<string>",
    "email": "<string>",
    "nombre": {},
    "apellido": {},
    "telefono": {},
    "email_verified": true,
    "tour_version": {},
    "tour_completed_at": {}
  },
  "error": "<string>"
}
Authenticates a user with email and password credentials. Returns access and refresh tokens for subsequent authenticated requests.

Authentication

No authentication required.

Request Body

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

Response

message
string
Success message confirming authentication.
accessToken
string
JWT access token for authenticating API requests. Include this in the Authorization header as Bearer {accessToken}.
refreshToken
string
JWT refresh token for obtaining new access tokens when they expire.
user
object
The authenticated user’s information.
id
string
Unique user identifier.
email
string
User’s email address.
nombre
string | null
User’s first name.
apellido
string | null
User’s last name.
telefono
string | null
User’s phone number.
email_verified
boolean
Email verification status.
tour_version
string | null
Version of the product tour completed by the user.
tour_completed_at
string | null
Timestamp when the tour was completed.

Example Request

curl -X POST https://api.contafy.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "usuario@ejemplo.com",
    "password": "SecurePass123!"
  }'

Example Response

{
  "message": "Inicio de sesión exitoso",
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "usr_1a2b3c4d5e6f7g8h",
    "email": "usuario@ejemplo.com",
    "nombre": "Juan",
    "apellido": "Pérez",
    "telefono": "+52 55 1234 5678",
    "email_verified": true,
    "tour_version": "v1.0",
    "tour_completed_at": "2024-01-15T10:30:00Z"
  }
}

Error Responses

error
string
Error type identifier.
message
string
Human-readable error message.

Common Errors

401 Unauthorized
{
  "error": "INVALID_CREDENTIALS",
  "message": "Email o contraseña incorrectos"
}
400 Bad Request
{
  "error": "VALIDATION_ERROR",
  "message": "Email y contraseña son requeridos"
}