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

# Abandon challenge

> Mark a user challenge as abandoned.

<Badge color="orange">PUT</Badge> `/api/user-challenges/:id/abandon`

Requires authentication.

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

<Warning>
  Abandoning a challenge **cannot be undone**. The challenge status is permanently set to
  `ABANDONED`. After abandoning, you can accept a new challenge.
</Warning>

## Path parameters

<ParamField path="id" type="number" required>
  The numeric ID of the user challenge to abandon.
</ParamField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl --request PUT \
    --url http://localhost:3000/api/user-challenges/14/abandon \
    --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
  ```
</CodeGroup>

## Response

**200 OK**

Returns the updated user challenge object with `status` set to `ABANDONED`.

<ResponseField name="id" type="number" required>
  Unique numeric identifier for this user challenge.
</ResponseField>

<ResponseField name="user_id" type="string" required>
  UUID of the authenticated user.
</ResponseField>

<ResponseField name="template_id" type="number" required>
  ID of the challenge template this challenge is based on.
</ResponseField>

<ResponseField name="status" type="string" required>
  Updated status. Always `ABANDONED` after this operation.
</ResponseField>

<ResponseField name="start_date" type="string" required>
  ISO 8601 timestamp of when the challenge was started.
</ResponseField>

<ResponseField name="completed_at" type="string">
  Always `null` for abandoned challenges.
</ResponseField>

<ResponseField name="notes" type="string">
  Progress notes for the challenge. `null` if none were added.
</ResponseField>

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

<ResponseField name="updated_at" type="string" required>
  ISO 8601 timestamp of this update.
</ResponseField>

```json Example response theme={null}
{
  "id": 14,
  "user_id": "a3f2c1d0-89b4-4e7a-b6f5-1234567890ab",
  "template_id": 3,
  "status": "ABANDONED",
  "start_date": "2026-03-17T09:00:00.000Z",
  "completed_at": null,
  "notes": null,
  "created_at": "2026-03-17T09:00:00.000Z",
  "updated_at": "2026-03-17T18:30:00.000Z"
}
```

## Errors

| Status | Description                                  |
| ------ | -------------------------------------------- |
| `401`  | Missing, invalid, or expired token.          |
| `404`  | No user challenge found with the given `id`. |
