> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plazen.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticated endpoints

> Overview and conventions for the Plazen API

### List notifications

```endpoint theme={null}
method: GET
path: /api/notifications
summary: List active notifications
```

**Auth:** Supabase session required.\
**Success 200:** JSON array where `show = true`, ordered by `created_at desc`.\
**Errors:** `401`, `500 { error: "Failed to fetch notifications" }`.

### Tasks collection

```endpoint theme={null}
method: GET
path: /api/tasks
summary: List tasks for a date (and external events)
queryParams:
  - name: date
    description: YYYY-MM-DD (optional)
  - name: timezoneOffset
    description: Minutes offset from UTC (optional; adjusts serialization)
```

* Generates routine tasks for the date when applicable.
* **Auth:** Session required.
* **Success 200:** JSON of tasks + external events.
* **Errors:** `401`, `500`.

```endpoint theme={null}
method: POST
path: /api/tasks
summary: Create a task (auto-scheduling supported)
requestBody:
  - name: title
    required: true
    description: Task title (stored encrypted)
  - name: ...scheduling fields
    required: false
    description: Time info; non-time-sensitive tasks may be auto-slotted
```

**Success:** Created task JSON.\
**Errors:** `401`, `400/500`.

```endpoint theme={null}
method: PATCH
path: /api/tasks
summary: Update a task (reschedule, complete, rename)
requestBody:
  - name: id
    required: true
  - name: title
    description: Encrypted at rest
  - name: completed
    description: Mark done
  - name: start/end/other scheduling
    description: Reschedule fields
```

**Success:** Updated task JSON.\
**Errors:** `401`, `400/500`.

```endpoint theme={null}
method: DELETE
path: /api/tasks
summary: Delete a task
requestBody:
  - name: id
    required: true
    description: Task ID (owned by caller)
```

**Success:** Deletion confirmation JSON.\
**Errors:** `401`, `400/500`.

### Routine task template

```endpoint theme={null}
method: PATCH
path: /api/routine-tasks/:id
summary: Update a routine task template
pathParams:
  - name: id
    required: true
requestBody:
  - name: title
    description: Encrypted at rest
  - name: description
  - name: duration_minutes
  - name: is_active
```

**Auth:** Session required.\
**Success 200:** Updated routine task (title decrypted in response).\
**Errors:** `401`, `500`.

```endpoint theme={null}
method: DELETE
path: /api/routine-tasks/:id
summary: Delete a routine task template
pathParams:
  - name: id
    required: true
```

**Auth:** Session required.\
**Success 200:** Deletion success.\
**Errors:** `401`, `500`.

### Username check (introduced in [v1.14.0](https://www.plazen.org/release-notes/bcbc8be0-77b5-4c8d-ad64-21ed9fac8fef))

```endpoint theme={null}
method: GET
path: /api/profile/username/check?username=<username>
summary: Check if a username is available and valid
```

**Auth:** Supabase session required.\
**Success 200:** `{ available: boolean, valid: boolean, message?: string }`\
**Errors:** `401 { error: "Unauthorized" }`, `500  { error: "Failed to check username availability" }`.
