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

# Log In

> Authenticate with email and password and receive a JWT token.

<Badge color="green">POST</Badge> `/api/auth/login`

No authentication required.

## Request body

<ParamField body="email" type="string" required>
  The email address associated with the account.
</ParamField>

<ParamField body="password" type="string" required>
  The account password.
</ParamField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url http://localhost:3000/api/auth/login \
    --header 'Content-Type: application/json' \
    --data '{
      "email": "maria@example.com",
      "password": "s3cr3tpass"
    }'
  ```
</CodeGroup>

## Response

**200 OK**

<ResponseField name="token" type="string" required>
  A signed JWT valid for 30 days. Include this token in the `Authorization` header for authenticated requests.
</ResponseField>

<ResponseField name="user" type="object" required>
  <Expandable title="properties" defaultOpen>
    <ResponseField name="id" type="string">
      Unique identifier for the user.
    </ResponseField>

    <ResponseField name="name" type="string">
      The user's display name.
    </ResponseField>

    <ResponseField name="email" type="string">
      The user's email address.
    </ResponseField>

    <ResponseField name="points" type="number">
      Total habit points accumulated.
    </ResponseField>

    <ResponseField name="current_streak" type="number">
      Current consecutive days with at least one completed habit.
    </ResponseField>

    <ResponseField name="max_streak" type="number">
      All-time highest streak.
    </ResponseField>
  </Expandable>
</ResponseField>

```json Example response theme={null}
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "a3f2c1d0-89b4-4e7a-b6f5-1234567890ab",
    "name": "Maria Silva",
    "email": "maria@example.com",
    "points": 120,
    "current_streak": 5,
    "max_streak": 14
  }
}
```

## Errors

| Status | Description                                                                                                |
| ------ | ---------------------------------------------------------------------------------------------------------- |
| `401`  | Email or password is incorrect, or no account found for that email. Message: `"Email ou senha inválidos"`. |
| `500`  | Internal server error.                                                                                     |
