Skip to main content

GET /api/user-data

Retrieves the profile information for the currently authenticated user. This endpoint requires authentication and returns user-specific settings and preferences.

Authentication

This endpoint requires a valid session token. If the user is not authenticated, the API returns a 401 Unauthorized error.

Response

localidad
string
User’s location or city
nivel
string
User’s English proficiency level. Possible values:
  • inicial - Beginner level
  • basico - Basic level
  • intermedio - Intermediate level
  • avanzado - Advanced level
telefono
number
User’s phone number
newsletter
string
Newsletter subscription preference. Possible values:
  • si - Subscribed to newsletter
  • no - Not subscribed to newsletter

Response Example

{
  "localidad": "Buenos Aires",
  "nivel": "intermedio",
  "telefono": 1234567890,
  "newsletter": "si"
}

cURL Example

curl -X GET https://your-domain.com/api/user-data \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json"

Error Responses

error
string
Error message describing what went wrong

401 Unauthorized

{
  "error": "Unauthorized"
}

500 Internal Server Error

{
  "error": "Failed to fetch user data"
}

POST /api/user-data

Updates the profile information for the currently authenticated user.

Authentication

This endpoint requires a valid session token. The user ID is automatically extracted from the session.

Request Body

localidad
string
required
User’s location or city
nivel
string
required
User’s English proficiency level. Must be one of:
  • inicial
  • basico
  • intermedio
  • avanzado
telefono
number
required
User’s phone number
newsletter
string
required
Newsletter subscription preference. Must be either si or no

Request Example

{
  "localidad": "Buenos Aires",
  "nivel": "avanzado",
  "telefono": 1198765432,
  "newsletter": "si"
}

Response

message
string
Success message confirming the data was received
data
object
The complete updated user object from the database

Response Example

{
  "message": "User data received",
  "data": {
    "id": "507f1f77bcf86cd799439011",
    "email": "[email protected]",
    "name": "John Doe",
    "localidad": "Buenos Aires",
    "nivel": "avanzado",
    "telefono": 1198765432,
    "newsletter": "si",
    "status": true,
    "totalClasses": 5,
    "createdAt": "2025-01-15T10:30:00.000Z",
    "updatedAt": "2025-03-02T14:20:00.000Z"
  }
}

cURL Example

curl -X POST https://your-domain.com/api/user-data \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "localidad": "Buenos Aires",
    "nivel": "avanzado",
    "telefono": 1198765432,
    "newsletter": "si"
  }'

Error Responses

401 Unauthorized

{
  "error": "Unauthorized"
}
This endpoint interacts with the User model from the database schema. The User model includes additional fields such as:
  • totalClasses - Total number of completed classes (incremented automatically)
  • status - User account status
  • UserActivity[] - Related user activity records
  • createdAt / updatedAt - Timestamps

Build docs developers (and LLMs) love