Source: https://spooly.eu/en/docs/api/slots

# Slots

Which spool sits in which slot, in one format across all manufacturers. Changing slots only works with the slot autopilot active.

## List slots

`GET /slots`

One entry per slot. `spool` is null for an empty slot or a spool Spooly does not know. `slot_id` is empty if the slot autopilot is not active for the account. `printer` is the name of the printer, there is no separate printer ID here.

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

Response (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"
    }
  ]
}
```

## Assign a slot

`PUT /slots/{slot_id}`

If the printer reports a different color, the API responds with 409 `andere_farbe`. With `confirm_color` you assign the spool anyway.

Parameters:

- `slot_id` (Path): From `GET /slots`
- `spool_id` (Body): The identifier of the spool
- `confirm_color` (Body, optional): true if the different color is intended. Default false.
- `Idempotency-Key` (Header, optional): 1 to 128 visible ASCII characters. [Idempotency-Key](https://spooly.eu/en/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}'
```

Response (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"
}
```

## Clear a slot

`DELETE /slots/{slot_id}`

The spool stays in Spooly and is no longer in the slot. This is the only DELETE in the API.

Parameters:

- `slot_id` (Path): From `GET /slots`
- `Idempotency-Key` (Header, optional): 1 to 128 visible ASCII characters. [Idempotency-Key](https://spooly.eu/en/docs/api#api-idempotenz)

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

Response (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"
}
```
