> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Braian551/viax/llms.txt
> Use this file to discover all available pages before exploring further.

# User Profile

> Get and update user profile information

## Get User Profile

```
GET /auth/profile.php
```

Retrieve user profile information by user ID or email.

### Query Parameters

<ParamField query="userId" type="integer">
  User ID to retrieve
</ParamField>

<ParamField query="email" type="string">
  Email address to retrieve
</ParamField>

<Note>
  Provide either `userId` or `email`, not both.
</Note>

### Response

<ResponseField name="success" type="boolean">
  Operation success status
</ResponseField>

<ResponseField name="user" type="object">
  User profile object with location
</ResponseField>

### Request Example

<CodeGroup>
  ```bash By User ID theme={null}
  curl -X GET "https://76.13.114.194/auth/profile.php?userId=456" \
    -H "Accept: application/json"
  ```

  ```bash By Email theme={null}
  curl -X GET "https://76.13.114.194/auth/profile.php?email=carlos.rodriguez@example.com" \
    -H "Accept: application/json"
  ```

  ```dart Dart theme={null}
  final userId = 456;
  final response = await http.get(
    Uri.parse('https://76.13.114.194/auth/profile.php?userId=$userId'),
    headers: {'Accept': 'application/json'},
  );
  ```
</CodeGroup>

### Response Example

```json Success theme={null}
{
  "success": true,
  "user": {
    "id": 456,
    "uuid": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "nombre": "Carlos",
    "apellido": "Rodríguez",
    "email": "carlos.rodriguez@example.com",
    "telefono": "+573001234567",
    "tipo_usuario": "pasajero",
    "calificacion": 4.8,
    "creado_en": "2024-01-15T10:30:00.000Z",
    "actualizado_en": "2024-03-15T14:30:00.000Z",
    "location": {
      "id": 89,
      "usuario_id": 456,
      "direccion": "Carrera 15 #85-30",
      "latitud": 4.6814,
      "longitud": -74.0479,
      "ciudad": "Bogotá",
      "departamento": "Cundinamarca",
      "pais": "Colombia",
      "codigo_postal": null,
      "es_principal": true
    }
  }
}
```

***

## Update User Profile

```
POST /auth/profile_update.php
```

Update user profile information.

### Request Body

<ParamField body="userId" type="integer" required>
  User ID to update
</ParamField>

<ParamField body="name" type="string">
  Updated first name
</ParamField>

<ParamField body="lastName" type="string">
  Updated last name
</ParamField>

<ParamField body="phone" type="string">
  Updated phone number
</ParamField>

<ParamField body="address" type="string">
  Updated street address
</ParamField>

<ParamField body="latitude" type="number">
  Updated location latitude
</ParamField>

<ParamField body="longitude" type="number">
  Updated location longitude
</ParamField>

<ParamField body="lat" type="number">
  Alternative latitude field
</ParamField>

<ParamField body="lng" type="number">
  Alternative longitude field
</ParamField>

<ParamField body="city" type="string">
  Updated city
</ParamField>

<ParamField body="state" type="string">
  Updated department/state
</ParamField>

<ParamField body="country" type="string">
  Updated country
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Update success status
</ResponseField>

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="user" type="object">
  Updated user profile
</ResponseField>

### Request Example

<CodeGroup>
  ```bash Update Profile theme={null}
  curl -X POST https://76.13.114.194/auth/profile_update.php \
    -H "Content-Type: application/json" \
    -d '{
      "userId": 456,
      "name": "Carlos Alberto",
      "phone": "+573009876543"
    }'
  ```

  ```bash Update Location theme={null}
  curl -X POST https://76.13.114.194/auth/profile_update.php \
    -H "Content-Type: application/json" \
    -d '{
      "userId": 456,
      "address": "Calle 50 #20-15",
      "latitude": 4.6486,
      "longitude": -74.0571,
      "city": "Bogotá",
      "state": "Cundinamarca"
    }'
  ```

  ```dart Dart theme={null}
  // Update profile
  await http.post(
    Uri.parse('https://76.13.114.194/auth/profile_update.php'),
    headers: {'Content-Type': 'application/json'},
    body: jsonEncode({
      'userId': 456,
      'name': 'Carlos Alberto',
      'lastName': 'Rodríguez Gómez',
      'phone': '+573009876543',
    }),
  );
  ```
</CodeGroup>

### Response Example

```json Success theme={null}
{
  "success": true,
  "message": "Perfil actualizado exitosamente",
  "user": {
    "id": 456,
    "uuid": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "nombre": "Carlos Alberto",
    "apellido": "Rodríguez Gómez",
    "email": "carlos.rodriguez@example.com",
    "telefono": "+573009876543",
    "tipo_usuario": "pasajero",
    "actualizado_en": "2024-03-15T16:45:00.000Z"
  }
}
```

***

## Error Responses

<ResponseField name="404" type="Not Found">
  User not found
</ResponseField>

<ResponseField name="400" type="Bad Request">
  Invalid request parameters
</ResponseField>

<ResponseField name="500" type="Internal Server Error">
  Server error
</ResponseField>

## Notes

<Note>
  Location updates (address, coordinates, city, etc.) will update the user's primary location record.
</Note>

<Warning>
  The email address cannot be changed through this endpoint for security reasons.
</Warning>

## See Also

* [Login](/api/auth/login) - Authenticate user
* [Register](/api/auth/register) - Create account
