Quelle: https://spooly.eu/docs/api/maintenance

# Wartung

Das Wartungsbuch: Drucker mit Stunden, Aufgaben mit Status und Fälligkeit, der Verlauf, und Aufgaben erledigen oder zurückstellen.

## Wartungsbuch abrufen

`GET /maintenance`

`status` ist `due`, `soon` oder `ok`. `metric` ist `hours`, `prints`, `kg`, `days`, `print_days`. `eta_days` schätzt die Tage bis fällig, 0 oder weniger heißt überfällig. Es ist null, wenn Spooly noch zu wenig Drucke für eine Schätzung hat oder das Teil als Ersatz im Regal liegt. Aufgabennamen kommen in der Sprache des Kontos.

```bash
curl "https://spooly.eu/api/v1/maintenance" \
  -H "Authorization: Bearer $SPOOLY_KEY"
```

Antwort (200):

```
{
  "printers": [
    {
      "printer_id": "e41b7c09a3d65f28b0c94e17d2a86f35",
      "printer": "X1 Carbon von Tobi",
      "hours": 812.5,
      "prints": 640,
      "filament_kg": 41.3,
      "due_count": 1,
      "soon_count": 2,
      "health_score": 84,
      "hours_confirmed": true
    }
  ],
  "tasks": [
    {
      "id": "mc_4f60b9158e2a",
      "printer_id": "e41b7c09a3d65f28b0c94e17d2a86f35",
      "printer": "X1 Carbon von Tobi",
      "name": "Nozzle 0.4 mm",
      "status": "due",
      "metric": "kg",
      "interval": 5,
      "used": 5.2,
      "remaining": -0.2,
      "eta_days": 0,
      "snoozed_until": null,
      "last_done_at": "2026-08-12T09:30:00Z",
      "default_action": "replace"
    }
  ],
  "printers_without_plan": [],
  "due_count": 1,
  "soon_count": 2,
  "snoozed_count": 0
}
```

## Wartungsverlauf

`GET /maintenance/log`

Neueste zuerst, ohne Fotos. `type` ist `replace`, `clean`, `check`, `service`, `snooze`, `setup`. Gelöschte Aufgaben bleiben im Verlauf, nur ohne Namen.

Parameter:

- `task_id` (Abfrage, optional): Nur diese Aufgabe
- `printer_id` (Abfrage, optional): Nur dieser Drucker
- `limit` (Abfrage, optional): 1 bis 200, Standard 50
- `offset` (Abfrage, optional): 0 bis 1.000.000, Standard 0

```bash
curl "https://spooly.eu/api/v1/maintenance/log?task_id=mc_4f60b9158e2a" \
  -H "Authorization: Bearer $SPOOLY_KEY"
```

Antwort (200):

```
{
  "items": [
    {
      "id": "ml_7b34c4d1e8f2",
      "task_id": "mc_4f60b9158e2a",
      "task": "Nozzle 0.4 mm",
      "printer": "X1 Carbon von Tobi",
      "type": "replace",
      "notes": "Neue Düse 0,4 mm",
      "cost": 12.5,
      "at": "2026-08-12T09:30:00Z"
    }
  ],
  "total": 12,
  "limit": 50,
  "offset": 0
}
```

## Wartung erledigen

`POST /maintenance/tasks/{task_id}/complete`

Der Zähler beginnt neu, das Lager wird abgezogen, die Fällig-Meldung geht weg. Ohne `action` gilt `default_action` der Aufgabe. `stock_empty` nennt einen Lagerartikel, der dadurch leer wurde.

Parameter:

- `task_id` (Pfad): `id` der Aufgabe aus `GET /maintenance`
- `action` (Body, optional): `replace`, `clean` oder `check`
- `notes` (Body, optional): Bis 1.000 Zeichen
- `Idempotency-Key` (Kopf, optional): 1 bis 128 sichtbare ASCII-Zeichen. [Idempotency-Key](https://spooly.eu/docs/api#api-idempotenz)

```bash
curl -X POST "https://spooly.eu/api/v1/maintenance/tasks/mc_4f60b9158e2a/complete" \
  -H "Authorization: Bearer $SPOOLY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"replace","notes":"Neue Düse 0,4 mm"}'
```

Antwort (200):

```
{
  "change_id": 381,
  "spool": null,
  "slot": null,
  "old_grams": null,
  "new_grams": null,
  "replayed": false,
  "task": {
    "id": "mc_4f60b9158e2a",
    "printer_id": "e41b7c09a3d65f28b0c94e17d2a86f35",
    "printer": "X1 Carbon von Tobi",
    "name": "Nozzle 0.4 mm",
    "status": "ok",
    "metric": "kg",
    "interval": 5,
    "used": 0,
    "remaining": 5,
    "eta_days": 0,
    "snoozed_until": null,
    "last_done_at": "2026-11-01T10:15:00Z",
    "default_action": "replace"
  },
  "printer": {
    "printer_id": "e41b7c09a3d65f28b0c94e17d2a86f35",
    "printer": "X1 Carbon von Tobi",
    "hours": 812.5,
    "prints": 640,
    "filament_kg": 41.3,
    "due_count": 0,
    "soon_count": 2,
    "health_score": 84,
    "hours_confirmed": true
  },
  "stock_empty": null,
  "summary": "Wartung Nozzle 0.4 mm an X1 Carbon von Tobi erledigt"
}
```

## Wartung zurückstellen

`POST /maintenance/tasks/{task_id}/snooze`

Die Aufgabe meldet sich nach den angegebenen Tagen wieder.

Parameter:

- `task_id` (Pfad): `id` der Aufgabe aus `GET /maintenance`
- `days` (Body): 7, 14 oder 30
- `reason` (Body, optional): Bis 200 Zeichen
- `Idempotency-Key` (Kopf, optional): 1 bis 128 sichtbare ASCII-Zeichen. [Idempotency-Key](https://spooly.eu/docs/api#api-idempotenz)

```bash
curl -X POST "https://spooly.eu/api/v1/maintenance/tasks/mc_4f60b9158e2a/snooze" \
  -H "Authorization: Bearer $SPOOLY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"days":14,"reason":"Teil ist bestellt"}'
```

Antwort (200):

```
{
  "change_id": 381,
  "spool": null,
  "slot": null,
  "old_grams": null,
  "new_grams": null,
  "replayed": false,
  "task": {
    "id": "mc_4f60b9158e2a",
    "printer_id": "e41b7c09a3d65f28b0c94e17d2a86f35",
    "printer": "X1 Carbon von Tobi",
    "name": "Nozzle 0.4 mm",
    "status": "due",
    "metric": "kg",
    "interval": 5,
    "used": 5.2,
    "remaining": -0.2,
    "eta_days": 0,
    "snoozed_until": "2026-11-15T10:15:00Z",
    "last_done_at": "2026-08-12T09:30:00Z",
    "default_action": "replace"
  },
  "printer": null,
  "stock_empty": null,
  "summary": "Wartung Nozzle 0.4 mm um 14 Tage verschoben"
}
```
