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

# Slots

Welche Spule in welchem Slot steckt, über alle Hersteller in einer Form. Ändern geht nur mit aktivem Slot-Autopilot.

## Slots auflisten

`GET /slots`

Ein Eintrag je Slot. `spool` ist null bei einem leeren Slot oder einer Spule, die Spooly nicht kennt. `slot_id` ist leer, wenn der Slot-Autopilot für das Konto nicht aktiv ist. `printer` ist der Name des Druckers, eine eigene Drucker-ID gibt es hier nicht.

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

Antwort (200):

```
{
  "items": [
    {
      "printer": "X1 Carbon von Tobi",
      "slot": "1-2",
      "spool": {
        "id": "7f3c2a10-5e1b-4c8e-9a44-2d6b1f0c7e21",
        "number": 1,
        "title": "Jade White",
        "material": "PLA",
        "color_hex": "#E8E9DF"
      },
      "slot_id": "9c1e4b7a2f6d08e35ab1c47d9e20f6a3"
    }
  ]
}
```

## Slot zuordnen

`PUT /slots/{slot_id}`

Meldet der Drucker eine andere Farbe, antwortet die API mit 409 `andere_farbe`. Mit `confirm_color` ordnest du trotzdem zu.

Parameter:

- `slot_id` (Pfad): Aus `GET /slots`
- `spool_id` (Body): Die Kennung der Spule
- `confirm_color` (Body, optional): true, wenn die andere Farbe gewollt ist. Standard false.
- `Idempotency-Key` (Kopf, optional): 1 bis 128 sichtbare ASCII-Zeichen. [Idempotency-Key](https://spooly.eu/docs/api#api-idempotenz)

```bash
curl -X PUT "https://spooly.eu/api/v1/slots/9c1e4b7a2f6d08e35ab1c47d9e20f6a3" \
  -H "Authorization: Bearer $SPOOLY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"spool_id":"7f3c2a10-5e1b-4c8e-9a44-2d6b1f0c7e21","confirm_color":false}'
```

Antwort (200):

```
{
  "change_id": 381,
  "spool": null,
  "slot": {
    "printer": "X1 Carbon von Tobi",
    "slot": "1-2",
    "spool": {
      "id": "7f3c2a10-5e1b-4c8e-9a44-2d6b1f0c7e21",
      "number": 1,
      "title": "Jade White",
      "material": "PLA",
      "color_hex": "#E8E9DF"
    },
    "slot_id": "9c1e4b7a2f6d08e35ab1c47d9e20f6a3"
  },
  "old_grams": null,
  "new_grams": null,
  "replayed": false,
  "task": null,
  "printer": null,
  "stock_empty": null,
  "summary": "Spule #1 Jade White einem Slot zugeordnet"
}
```

## Slot leeren

`DELETE /slots/{slot_id}`

Die Spule bleibt in Spooly, sie steckt nur nicht mehr im Slot. Das ist der einzige DELETE der API.

Parameter:

- `slot_id` (Pfad): Aus `GET /slots`
- `Idempotency-Key` (Kopf, optional): 1 bis 128 sichtbare ASCII-Zeichen. [Idempotency-Key](https://spooly.eu/docs/api#api-idempotenz)

```bash
curl -X DELETE "https://spooly.eu/api/v1/slots/9c1e4b7a2f6d08e35ab1c47d9e20f6a3" \
  -H "Authorization: Bearer $SPOOLY_KEY"
```

Antwort (200):

```
{
  "change_id": 381,
  "spool": null,
  "slot": {
    "printer": "X1 Carbon von Tobi",
    "slot": "1-2",
    "spool": null,
    "slot_id": "9c1e4b7a2f6d08e35ab1c47d9e20f6a3"
  },
  "old_grams": null,
  "new_grams": null,
  "replayed": false,
  "task": null,
  "printer": null,
  "stock_empty": null,
  "summary": "Slot geleert"
}
```
