Skip to main content

Get Profile

GET /api/auth/profile
endpoint
Retrieve the authenticated user’s complete profile information

Authentication

Authorization
string
required
Bearer token obtained from login or registrationFormat: Bearer <token>

Response

success
boolean
Indicates if the request was successful
user
object
Complete user profile

Code Examples

curl -X GET https://api.fitaiid.com/api/auth/profile \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Example Response

{
  "success": true,
  "user": {
    "id": "65e4a321b4f78901234567890",
    "firstName": "John",
    "lastName": "Doe",
    "fullName": "John Doe",
    "email": "[email protected]",
    "role": "customer",
    "phone": "5551234567",
    "isActive": true,
    "isEmailVerified": true,
    "fitnessProfile": {
      "questionnaireCompleted": true,
      "gender": "hombre",
      "age": 28,
      "height": 175,
      "weight": 75,
      "fitnessLevel": "intermedio",
      "mainGoal": "ganar masa muscular",
      "medicalConditions": "",
      "trainingLocation": "gym",
      "trainingDaysPerWeek": 5,
      "sessionDuration": "1 hr"
    },
    "bmi": 24.5,
    "bmiCategory": "Peso normal",
    "fitnessStats": {
      "totalWorkouts": 42,
      "totalExercises": 315,
      "totalMinutes": 2520,
      "totalHours": "42.0",
      "totalCalories": 21000,
      "currentStreak": 7,
      "maxStreak": 14,
      "lastWorkoutDate": "2024-03-06T09:00:00.000Z",
      "achievements": [
        {
          "achievementId": "first_workout",
          "nombre": "Primera Rutina",
          "unlockedAt": "2024-01-15T10:00:00.000Z"
        }
      ],
      "workoutHistory": []
    },
    "customerLevel": "silver",
    "totalOrders": 5,
    "totalSpent": 750000,
    "formattedTotalSpent": "$750.000",
    "loyaltyPoints": 750,
    "createdAt": "2024-01-10T15:30:00.000Z"
  }
}

Update Profile

PUT /api/auth/profile
endpoint
Update the authenticated user’s profile information

Authentication

Authorization
string
required
Bearer token obtained from login or registrationFormat: Bearer <token>

Request Body

All fields are optional. Only include the fields you want to update.
firstName
string
User’s first name
  • Length: 2-50 characters
  • Pattern: Letters and spaces only (including áéíóúñ)
  • HTML characters are sanitized
lastName
string
User’s last name
  • Length: 2-50 characters
  • Pattern: Letters and spaces only (including áéíóúñ)
  • HTML characters are sanitized
phone
string
User’s phone number
  • Exactly 10 digits
  • Example: “5559876543”
dateOfBirth
string
User’s date of birth
  • ISO 8601 date format
  • Example: “1995-05-15”
gender
string
User’s gender
  • For general profile (not fitness-specific)
avatar
string
Avatar URL or base64 image
  • Must start with http, https, or data:image/
address
object
User’s address information
  • Maximum 200 characters when stringified
  • HTML characters are sanitized
You cannot update the following fields through this endpoint:
  • email
  • password
  • role
  • isActive
  • isEmailVerified
  • fitnessProfile (use dedicated fitness endpoints)

Response

success
boolean
Indicates if the update was successful
message
string
Success message: “Perfil actualizado exitosamente”
user
object
Updated user profile (same structure as GET profile response)

Error Responses

Status CodeError MessageDescription
400”ID de usuario requerido”Missing authentication token
400”No hay campos para actualizar”Request body is empty or contains no allowed fields
400Validation errorsInvalid field formats
404”Usuario no encontrado”User no longer exists
401”Token inválido”Invalid or expired authentication token

Code Examples

curl -X PUT https://api.fitaiid.com/api/auth/profile \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "Jonathan",
    "phone": "5559876543",
    "address": {
      "street": "123 Main St",
      "city": "Bogotá",
      "country": "Colombia"
    }
  }'

Example Response

{
  "success": true,
  "message": "Perfil actualizado exitosamente",
  "user": {
    "id": "65e4a321b4f78901234567890",
    "firstName": "Jonathan",
    "lastName": "Doe",
    "fullName": "Jonathan Doe",
    "email": "[email protected]",
    "phone": "5559876543",
    "address": {
      "street": "123 Main St",
      "city": "Bogotá",
      "country": "Colombia"
    },
    "role": "customer",
    "isActive": true,
    "isEmailVerified": true,
    "customerLevel": "silver",
    "createdAt": "2024-01-10T15:30:00.000Z"
  }
}

Validation Rules

Name Fields

  • Length: 2-50 characters
  • Letters and spaces only
  • Supports Spanish characters
  • HTML entities sanitized

Phone Number

  • Exactly 10 digits
  • Numbers only
  • No spaces or formatting

Address

  • Maximum 200 characters
  • Can be object or string
  • HTML entities sanitized

Avatar

  • Valid URL or base64 image
  • Must start with http, https, or data:image/

Next Steps

Login

Authenticate to get access token

Google OAuth

Authenticate with Google

Build docs developers (and LLMs) love