Skip to main content

Login

Request Body

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

Response

success
boolean
Indicates if the login was successful
token
string
JWT authentication token
user
object
User information object
message
string
Success or error message

Example Request

curl -X POST https://cemac-api.vercel.app/auth/login \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "yourpassword"
  }'

Example Response

{
  "success": true,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "user_123",
    "email": "[email protected]",
    "firstName": "John",
    "lastName": "Doe",
    "role": "vendedor"
  },
  "message": "Login exitoso"
}

Error Codes

  • 400 - Invalid credentials or missing parameters
  • 401 - Authentication failed
  • 500 - Internal server error

Logout

Headers

Authorization
string
required
Bearer token for authentication

Response

success
boolean
Indicates if logout was successful
message
string
Confirmation message

Example Request

curl -X POST https://cemac-api.vercel.app/auth/logout \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

{
  "success": true,
  "message": "Logout exitoso"
}

Verify Authentication

Headers

Authorization
string
required
Bearer token for authentication

Response

success
boolean
Indicates if the token is valid
user
object
Authenticated user information

Example Request

curl -X GET https://cemac-api.vercel.app/auth/verify \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Example Response

{
  "success": true,
  "user": {
    "id": "user_123",
    "email": "[email protected]",
    "role": "vendedor"
  }
}

Error Codes

  • 401 - Invalid or expired token
  • 500 - Internal server error

Password Recovery

Request Body

email
string
required
Email address of the account to recover
isAdmin
boolean
default:"false"
Indicates if this is an admin account recovery request

Response

success
boolean
Indicates if the request was processed
message
string
Confirmation or error message

Example Request

curl -X POST https://cemac-api.vercel.app/auth/recover \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "email": "[email protected]",
    "isAdmin": false
  }'

Example Response

{
  "success": true,
  "message": "Se ha enviado un correo con instrucciones para restablecer la contraseña"
}

Error Codes

  • 400 - Missing email parameter
  • 404 - Email not found
  • 500 - Internal server error

Register

Request Body

email
string
required
User’s email address
password
string
required
User’s password
firstName
string
required
User’s first name
lastName
string
required
User’s last name

Response

success
boolean
Indicates if registration was successful
user
object
Created user information
message
string
Success or error message

Example Request

curl -X POST https://cemac-api.vercel.app/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword",
    "firstName": "Jane",
    "lastName": "Smith"
  }'

Example Response

{
  "success": true,
  "user": {
    "id": "user_456",
    "email": "[email protected]",
    "firstName": "Jane",
    "lastName": "Smith"
  },
  "message": "Usuario registrado exitosamente"
}

Error Codes

  • 400 - Invalid input or missing required fields
  • 409 - Email already exists
  • 500 - Internal server error

Build docs developers (and LLMs) love