Skip to main content
GET
/
api
/
auth
/
profile
User Profile
curl --request GET \
  --url https://api.example.com/api/auth/profile
{
  "success": true,
  "message": "<string>",
  "data": {
    "user": {
      "user_id": 123,
      "name": "<string>",
      "email": "<string>",
      "role_id": 123,
      "status": "<string>",
      "registration_date": "<string>",
      "last_session": "<string>"
    }
  }
}

Get Profile

This endpoint requires authentication. Include the JWT token in the Authorization header.

GET /api/auth/profile

Returns the complete profile data of the authenticated user (without password).

Authentication

Required: Bearer token in Authorization header
Authorization: Bearer {your_jwt_token}

Response

success
boolean
Indicates if the request was successful
message
string
Human-readable response message
data
object
Response data containing user profile

Example Request

cURL
curl -X GET https://api.maqagr.com/api/auth/profile \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."
JavaScript
const response = await fetch('https://api.maqagr.com/api/auth/profile', {
  headers: {
    'Authorization': `Bearer ${token}`
  }
});

const data = await response.json();
Python
import requests

response = requests.get(
    'https://api.maqagr.com/api/auth/profile',
    headers={'Authorization': f'Bearer {token}'}
)

data = response.json()

Success Response (200)

{
  "success": true,
  "message": "Perfil obtenido exitosamente",
  "data": {
    "user": {
      "user_id": 1,
      "name": "Juan Pérez",
      "email": "[email protected]",
      "role_id": 2,
      "role_name": "user",
      "status": "active",
      "registration_date": "2026-02-13T10:00:00.000Z",
      "last_session": "2026-03-11T08:30:00.000Z"
    }
  }
}

Error Responses

401 - Unauthorized (No Token)
{
  "success": false,
  "message": "Token no proporcionado o inválido"
}
404 - User Not Found
{
  "success": false,
  "message": "Usuario no encontrado"
}

Update Profile

This endpoint requires authentication. Include the JWT token in the Authorization header.

PUT /api/auth/profile

Allows updating the name and/or email of the authenticated user. Does not allow changing role or status. At least one field must be provided. If updating email, it verifies that it’s not in use by another user.

Authentication

Required: Bearer token in Authorization header
Authorization: Bearer {your_jwt_token}

Request Body

name
string
User’s new full name (optional if email is provided)
email
string
User’s new email address (optional if name is provided, must be valid format)
At least one field (name or email) must be provided

Response

success
boolean
Indicates if the request was successful
message
string
Human-readable response message
data
object
Response data containing updated user profile

Example Request

cURL
curl -X PUT https://api.maqagr.com/api/auth/profile \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Juan Pérez Actualizado",
    "email": "[email protected]"
  }'
JavaScript
const response = await fetch('https://api.maqagr.com/api/auth/profile', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Juan Pérez Actualizado',
    email: '[email protected]'
  })
});

const data = await response.json();
Python
import requests

response = requests.put(
    'https://api.maqagr.com/api/auth/profile',
    headers={'Authorization': f'Bearer {token}'},
    json={
        'name': 'Juan Pérez Actualizado',
        'email': '[email protected]'
    }
)

data = response.json()

Success Response (200)

{
  "success": true,
  "message": "Perfil actualizado exitosamente",
  "data": {
    "user": {
      "user_id": 1,
      "name": "Juan Pérez Actualizado",
      "email": "[email protected]",
      "role_id": 2,
      "status": "active",
      "registration_date": "2026-02-13T10:00:00.000Z",
      "last_session": "2026-03-11T08:30:00.000Z"
    }
  }
}

Error Responses

400 - No Fields Provided
{
  "success": false,
  "message": "Debe proporcionar al menos nombre o email para actualizar"
}
400 - Invalid Email Format
{
  "success": false,
  "message": "Formato de email inválido"
}
401 - Unauthorized
{
  "success": false,
  "message": "Token no proporcionado o inválido"
}
409 - Email Already in Use
{
  "success": false,
  "message": "El email ya está en uso por otro usuario"
}
500 - Internal Server Error
{
  "success": false,
  "message": "Error interno del servidor"
}

Build docs developers (and LLMs) love