Skip to main content

GET /api/auth/user

Retrieves the current authenticated user’s information based on the provided access token.

Authentication

Required. Include the access token in the Authorization header.

Request Headers

Authorization
string
required
Bearer token for authenticationExample: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Request Body

No request body required.

Response Fields

user
object
User information object
user.id
string
Unique user identifier
user.email
string
User’s email address
user.nombre
string
User’s full name
user.rol
string
User’s role in the system
user.creado_en
string
Timestamp when the user account was created

Example Request

curl -X GET https://api.example.com/api/auth/user \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

{
  "user": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "[email protected]",
    "nombre": "Juan Pérez",
    "rol": "admin",
    "creado_en": "2024-01-15T10:30:00Z"
  }
}

Error Responses

401 Unauthorized

Missing or invalid authentication token:
{
  "error": "No autorizado"
}
Expired access token:
{
  "error": "Token expirado"
}

500 Internal Server Error

{
  "error": "Error en el servidor"
}
This endpoint is useful for verifying that an access token is still valid and for retrieving the current user’s profile information.
If you receive a 401 error with “Token expirado”, use the refresh token endpoint to obtain a new access token.

Build docs developers (and LLMs) love