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

# Update Profile

> Update the authenticated user's name, profile picture, email, or password.

<Badge color="yellow">PUT</Badge> `/api/user/profile`

Requires authentication.

<ParamField header="Authorization" type="string" required>
  Bearer token obtained from `/api/auth/login` or `/api/auth/signup`. Format: `Bearer <token>`.
</ParamField>

## Request body

All fields are optional. Only the fields you include will be updated.

<ParamField body="name" type="string">
  New display name for the user.
</ParamField>

<ParamField body="profile_picture" type="string">
  URL of the new profile picture.
</ParamField>

<ParamField body="email" type="string">
  New email address. Must not be in use by another account.
</ParamField>

<ParamField body="newPassword" type="string">
  New password to set for the account.
</ParamField>

<Note>
  To change the password, provide `newPassword`. The authenticated JWT is used as the primary
  authorization check — no `currentPassword` field is required by the current implementation.
</Note>

<Warning>
  If you supply a new `email`, the API will reject the request with `400` if that address is
  already registered to another account.
</Warning>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request PUT \
    --url http://localhost:3000/api/user/profile \
    --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "Maria S.",
      "email": "maria.new@example.com",
      "newPassword": "newS3cr3t"
    }'
  ```
</CodeGroup>

## Response

**200 OK**

Returns the full updated user profile, including the current email.

<ResponseField name="id" type="string" required>
  Unique identifier for the user.
</ResponseField>

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

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

<ResponseField name="profile_picture" type="string">
  URL of the user's profile picture. `null` if not set.
</ResponseField>

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

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

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

<ResponseField name="created_at" type="string" required>
  ISO 8601 timestamp of when the account was created.
</ResponseField>

<ResponseField name="updated_at" type="string" required>
  ISO 8601 timestamp of the most recent profile update.
</ResponseField>

```json Example response theme={null}
{
  "id": "a3f2c1d0-89b4-4e7a-b6f5-1234567890ab",
  "name": "Maria S.",
  "email": "maria.new@example.com",
  "profile_picture": "https://example.com/avatars/maria.jpg",
  "points": 120,
  "current_streak": 5,
  "max_streak": 14,
  "created_at": "2026-01-10T08:30:00.000Z",
  "updated_at": "2026-03-17T10:05:00.000Z"
}
```

## Errors

| Status | Description                                                                              |
| ------ | ---------------------------------------------------------------------------------------- |
| `400`  | Supplied `email` is already in use by another account, or request body fails validation. |
| `401`  | Missing, invalid, or expired token.                                                      |
