> ## 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.

# Register User

> Create a new user account

## Endpoint

```
POST /auth/register.php
```

Register a new user account in the Viax platform. Supports registration for passengers, drivers, and other user types.

## Headers

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`
</ParamField>

<ParamField header="Accept" type="string" required>
  Must be `application/json`
</ParamField>

## Request Body

<ParamField body="name" type="string" required>
  User's first name
</ParamField>

<ParamField body="lastName" type="string" required>
  User's last name
</ParamField>

<ParamField body="email" type="string" required>
  Valid email address. Must be unique in the system.
</ParamField>

<ParamField body="phone" type="string" required>
  Phone number with country code (e.g., +573001234567)
</ParamField>

<ParamField body="password" type="string" required>
  User password. Should be at least 8 characters.
</ParamField>

<ParamField body="address" type="string">
  Street address
</ParamField>

<ParamField body="latitude" type="number">
  Location latitude in decimal degrees
</ParamField>

<ParamField body="longitude" type="number">
  Location longitude in decimal degrees
</ParamField>

<ParamField body="lat" type="number">
  Alternative field for latitude (backend accepts both)
</ParamField>

<ParamField body="lng" type="number">
  Alternative field for longitude (backend accepts both)
</ParamField>

<ParamField body="city" type="string">
  City name
</ParamField>

<ParamField body="state" type="string">
  Department/state name
</ParamField>

<ParamField body="country" type="string" default="Colombia">
  Country name
</ParamField>

## Response

<ResponseField name="success" type="boolean" required>
  Indicates if registration was successful
</ResponseField>

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

<ResponseField name="user" type="object">
  Created user object

  <Expandable title="user object">
    <ResponseField name="id" type="integer">
      Unique user identifier
    </ResponseField>

    <ResponseField name="uuid" type="string">
      Universally unique identifier
    </ResponseField>

    <ResponseField name="nombre" type="string">
      User's first name
    </ResponseField>

    <ResponseField name="apellido" type="string">
      User's last name
    </ResponseField>

    <ResponseField name="email" type="string">
      User's email address
    </ResponseField>

    <ResponseField name="telefono" type="string">
      User's phone number
    </ResponseField>

    <ResponseField name="tipo_usuario" type="string">
      User type: `pasajero`, `conductor`, `admin`, or `empresa`
    </ResponseField>

    <ResponseField name="creado_en" type="string">
      Account creation timestamp (ISO 8601)
    </ResponseField>

    <ResponseField name="actualizado_en" type="string">
      Last update timestamp (ISO 8601)
    </ResponseField>

    <ResponseField name="location" type="object">
      User's primary location

      <Expandable title="location object">
        <ResponseField name="id" type="integer">
          Location record ID
        </ResponseField>

        <ResponseField name="usuario_id" type="integer">
          Associated user ID
        </ResponseField>

        <ResponseField name="direccion" type="string">
          Street address
        </ResponseField>

        <ResponseField name="latitud" type="number">
          Latitude
        </ResponseField>

        <ResponseField name="longitud" type="number">
          Longitude
        </ResponseField>

        <ResponseField name="ciudad" type="string">
          City
        </ResponseField>

        <ResponseField name="departamento" type="string">
          Department/state
        </ResponseField>

        <ResponseField name="pais" type="string">
          Country
        </ResponseField>

        <ResponseField name="es_principal" type="boolean">
          Whether this is the primary location
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://76.13.114.194/auth/register.php \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{
      "name": "Carlos",
      "lastName": "Rodríguez",
      "email": "carlos.rodriguez@example.com",
      "phone": "+573001234567",
      "password": "SecurePass123!",
      "address": "Carrera 15 #85-30",
      "latitude": 4.6814,
      "longitude": -74.0479,
      "city": "Bogotá",
      "state": "Cundinamarca",
      "country": "Colombia"
    }'
  ```

  ```dart Dart theme={null}
  import 'package:http/http.dart' as http;
  import 'dart:convert';

  final response = await http.post(
    Uri.parse('https://76.13.114.194/auth/register.php'),
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    },
    body: jsonEncode({
      'name': 'Carlos',
      'lastName': 'Rodríguez',
      'email': 'carlos.rodriguez@example.com',
      'phone': '+573001234567',
      'password': 'SecurePass123!',
      'address': 'Carrera 15 #85-30',
      'latitude': 4.6814,
      'longitude': -74.0479,
      'city': 'Bogotá',
      'state': 'Cundinamarca',
      'country': 'Colombia',
    }),
  );
  ```

  ```javascript JavaScript theme={null}
  fetch('https://76.13.114.194/auth/register.php', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    },
    body: JSON.stringify({
      name: 'Carlos',
      lastName: 'Rodríguez',
      email: 'carlos.rodriguez@example.com',
      phone: '+573001234567',
      password: 'SecurePass123!',
      address: 'Carrera 15 #85-30',
      latitude: 4.6814,
      longitude: -74.0479,
      city: 'Bogotá',
      state: 'Cundinamarca',
      country: 'Colombia',
    }),
  })
  .then(response => response.json())
  .then(data => console.log(data));
  ```
</CodeGroup>

## Response Example

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

  ```json Email Already Exists (400) theme={null}
  {
    "success": false,
    "message": "Email ya está registrado"
  }
  ```

  ```json Missing Required Field (400) theme={null}
  {
    "success": false,
    "message": "Campo 'email' es requerido"
  }
  ```

  ```json Invalid Email Format (400) theme={null}
  {
    "success": false,
    "message": "Formato de email inválido"
  }
  ```
</CodeGroup>

## Error Responses

<ResponseField name="400" type="Bad Request">
  Invalid input data or email already registered
</ResponseField>

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

## Notes

<Note>
  After successful registration, the user can immediately login using the `/auth/login.php` endpoint.
</Note>

<Warning>
  Passwords are hashed on the server. Never store plain-text passwords on the client.
</Warning>

## See Also

* [Login](/api/auth/login) - Authenticate an existing user
* [User Profile](/api/users/profile) - Get user profile information
* [Email Verification](/api/auth/verify-email) - Verify user email address
