> For the complete documentation index, see [llms.txt](https://requestmechanic.gitbook.io/request-mechanic-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://requestmechanic.gitbook.io/request-mechanic-api-documentation/user/user-login.md).

# User Login

Use the `POST /user/login/` endpoint to log in to the system by providing their email and password.

***

#### Parameters

**Request Body**

| **Field**                | **Type**          | **Description**                                   | **Constraints**                |
| ------------------------ | ----------------- | ------------------------------------------------- | ------------------------------ |
| `id`                     | String            | Unique identifier for the user.                   | Max length: 255, Min length: 1 |
| `first_name`             | String            | First name of the user.                           | Max length: 150                |
| `last_name`              | String            | Last name of the user.                            | Max length: 150                |
| `email`                  | String (required) | Email address of the user.                        | Max length: 255, Min length: 5 |
| `phone_number`           | String            | Phone number of the user.                         | Max length: 128, Nullable      |
| `password`               | String (required) | Password of the user.                             | Max length: 68, Min length: 5  |
| `account_type`           | String            | Type of user account.                             | Enum: `[Admin, Mechanic]`      |
| `car_brand`              | Object            | Information about the user's car brand.           |                                |
| **`name`**               | String            | Name of the car brand.                            | Max length: 255, Min length: 1 |
| `completed_registration` | Boolean           | Indicates if the user has completed registration. |                                |
| `is_active`              | Boolean           | Indicates if the user's account is active.        |                                |

***

#### Responses

| **HTTP Code** | **Description**              |
| ------------- | ---------------------------- |
| `201`         | User successfully logged in. |

**Response Example**

```json
{
  "id": "12345",
  "username": "johndoe",
  "first_name": "John",
  "last_name": "Doe",
  "email": "johndoe@example.com",
  "phone_number": "+1234567890",
  "has_pin": "true",
  "profile_pic": "https://example.com/profile.jpg",
  "account_type": "Admin",
  "car_brand": {
    "id": 1,
    "name": "Toyota"
  },
  "car_model": "Corolla",
  "education_level": "Bachelor's Degree",
  "completed_registration": true,
  "tokens": "xyz123",
  "is_active": true
}
```

***

#### Example cURL Request

```bash
curl -X POST "https://api.example.com/user/login/" \
-H "Content-Type: application/json" \
-d '{
  "email": "johndoe@example.com",
  "password": "password123"
}'
```
