# API contract

Base URL in development: `http://127.0.0.1:8000`
Production base URL: `https://api.trackerslens.com`

All application endpoints return JSON.

Documentation endpoints return HTML by default. Add `?format=md` or use the `.md` suffix for raw Markdown.

## Auth

### `GET /sanctum/csrf-cookie`

Initializes CSRF cookie for SPA requests.

### `POST /api/register`

Request:

```json
{
  "name": "Thomas Lane",
  "email": "user@example.com",
  "password": "secret-password",
  "password_confirmation": "secret-password"
}
```

Response: `201 Created` with the authenticated user payload.

### `POST /api/login`

Request:

```json
{
  "email": "user@example.com",
  "password": "secret",
  "remember": true
}
```

Response: `204 No Content` on success.

### `POST /api/logout`

Response: `204 No Content` on success.

### `GET /api/user`

Response:

```json
{
  "id": 1,
  "name": "Thomas Lane",
  "email": "user@example.com",
  "plan": "pro"
}
```

## Public documentation

### `GET /docs/api-contract`

Returns this API contract as a styled HTML page.

Raw Markdown: `GET /docs/api-contract?format=md` or `GET /docs/api-contract.md`.

### `GET /docs/landing-integration`

Returns the landing/API integration log as a styled HTML page.

Raw Markdown: `GET /docs/landing-integration?format=md` or `GET /docs/landing-integration.md`.

### `GET /docs/laravel-backend-plan`

Returns the backend implementation plan as a styled HTML page.

Raw Markdown: `GET /docs/laravel-backend-plan?format=md` or `GET /docs/laravel-backend-plan.md`.

## Dashboard

### `GET /api/dashboard/summary`

Response:

```json
{
  "kpis": [
    {
      "label": "Total Boxes",
      "value": 24,
      "delta": 18,
      "trend": "up"
    }
  ],
  "box_segments": [
    {
      "label": "Published",
      "value": 12
    }
  ]
}
```

### `GET /api/dashboard/activity`

Response:

```json
{
  "items": [
    {
      "type": "box_published",
      "title": "Box published",
      "detail": "Crypto Tracker",
      "created_at": "2026-05-13T11:30:00Z"
    }
  ]
}
```

### `GET /api/dashboard/system-status`

Response:

```json
{
  "services": [
    {
      "name": "API Service",
      "status": "operational"
    }
  ]
}
```
