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

# Create Task

> Create a new task for the authenticated user

<Note>
  This endpoint requires implementation in the backend. Documentation reflects the expected API design based on the Task model schema.
</Note>

## Authentication

This endpoint requires a valid JWT token in the Authorization header.

```
Authorization: Bearer YOUR_JWT_TOKEN
```

## Request Body

<ParamField body="title" type="string" required>
  The title of the task
</ParamField>

<ParamField body="description" type="string">
  Optional description of the task
</ParamField>

<ParamField body="completed" type="boolean" default="false">
  Whether the task is completed. Defaults to false if not provided.
</ParamField>

## Response

<ResponseField name="id" type="integer">
  The unique identifier for the task
</ResponseField>

<ResponseField name="title" type="string">
  The title of the task
</ResponseField>

<ResponseField name="description" type="string">
  The description of the task (null if not provided)
</ResponseField>

<ResponseField name="completed" type="boolean">
  Whether the task is completed
</ResponseField>

<ResponseField name="userId" type="integer">
  The ID of the user who owns this task
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST http://localhost:3000/tasks \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN" \
    -d '{
      "title": "Complete API documentation",
      "description": "Write comprehensive API docs for all task endpoints",
      "completed": false
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "id": 1,
    "title": "Complete API documentation",
    "description": "Write comprehensive API docs for all task endpoints",
    "completed": false,
    "userId": 5
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": "Title is required"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": "Invalid or missing authentication token"
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": "Error creating task"
  }
  ```
</ResponseExample>
