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

# API Overview

> Overview of the Módulo de Registro de Vacaciones REST API — base URL, authentication, content types, and available endpoints.

The Vacaciones API is a JSON REST API that powers the Módulo de Registro de Vacaciones front end. All communication happens over HTTP and every request (except login) must include a valid JWT bearer token.

## Base URL

The base URL is configured via the `VITE_API_URL` environment variable in the front end. If the variable is not set, the default is used:

```
http://localhost:5175
```

All paths in this reference are relative to that base URL (e.g. `POST /api/auth/login` → `http://localhost:5175/api/auth/login`).

## Authentication

Every endpoint except `POST /api/auth/login` requires an `Authorization` header carrying a JWT obtained from the login endpoint.

```
Authorization: Bearer <token>
```

See [Authentication](/api/authentication) for details on obtaining and using tokens.

## Request format

All request bodies must be JSON. Set the `Content-Type` header accordingly:

```
Content-Type: application/json
```

## Error responses

Errors are returned as plain HTTP status codes with a text body. There is no structured JSON error envelope.

| Status | Meaning                                                 |
| ------ | ------------------------------------------------------- |
| `400`  | Bad request — malformed body or missing required fields |
| `401`  | Unauthorized — missing or invalid token                 |
| `404`  | Not found — the requested resource does not exist       |
| `500`  | Internal server error                                   |

## Available endpoints

<CardGroup cols={2}>
  <Card title="Authentication" icon="lock" href="/api/authentication">
    Obtain a JWT token via username and password login.
  </Card>

  <Card title="Personal" icon="users" href="/api/personal">
    Create, list, and delete employee records.
  </Card>

  <Card title="Schedules" icon="calendar" href="/api/schedules">
    Manage vacation schedules (cronogramas) per employee and year.
  </Card>

  <Card title="Ranges" icon="calendar-range" href="/api/ranges">
    Create, list, and delete vacation date ranges within a schedule.
  </Card>
</CardGroup>

### Authentication

| Method | Path              | Description                    |
| ------ | ----------------- | ------------------------------ |
| `POST` | `/api/auth/login` | Exchange credentials for a JWT |

### Personal

| Method   | Path                | Description        |
| -------- | ------------------- | ------------------ |
| `GET`    | `/api/personal`     | List all employees |
| `POST`   | `/api/personal`     | Create an employee |
| `DELETE` | `/api/personal/:id` | Delete an employee |

### Schedules

| Method | Path                         | Description                            |
| ------ | ---------------------------- | -------------------------------------- |
| `GET`  | `/api/schedules`             | List all vacation schedules            |
| `GET`  | `/api/schedules/:personalId` | List schedules for a specific employee |
| `POST` | `/api/schedules`             | Create a vacation schedule             |
| `PUT`  | `/api/schedules/:id`         | Update a vacation schedule             |

### Ranges

| Method   | Path                      | Description                |
| -------- | ------------------------- | -------------------------- |
| `GET`    | `/api/ranges/:scheduleId` | List ranges for a schedule |
| `POST`   | `/api/ranges`             | Create a vacation range    |
| `DELETE` | `/api/ranges/:id`         | Delete a vacation range    |

## Quick example

```bash theme={null}
# 1. Obtain a token
TOKEN=$(curl -s -X POST http://localhost:5175/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"secret"}' \
  | jq -r '.token')

# 2. List all employees
curl http://localhost:5175/api/personal \
  -H "Authorization: Bearer $TOKEN"
```
