Skip to content

Commit 28e6d62

Browse files
committed
Update Device API documentation: clarify full-replace and partial-update semantics for device fields #1597
1 parent b530a6e commit 28e6d62

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

docs/API_DEVICE.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Manage a **single device** by its MAC address. Operations include retrieval, upd
5050
* **POST** `/device/<mac>`
5151
Create or update a device record.
5252

53+
> ⚠️ **Full-replace (PUT) semantics.** Every editable field is written on each call. Any field omitted from the payload is reset to its default (empty string or `0`). This matches how the frontend edit form works — it always sends the complete device state.
54+
>
55+
> To update a **single field** without affecting others, use [`POST /device/<mac>/update-column`](#7-update-a-single-column) instead.
56+
5357
**Request Body**:
5458

5559
```json
@@ -62,8 +66,8 @@ Manage a **single device** by its MAC address. Operations include retrieval, upd
6266

6367
**Behavior**:
6468

65-
* If `createNew=true`creates a new device
66-
* Otherwise → updates existing device fields
69+
* If `createNew=true`inserts a new device row
70+
* Otherwise → **replaces all editable fields** on the existing device
6771

6872
**Response**:
6973

@@ -163,7 +167,11 @@ Manage a **single device** by its MAC address. Operations include retrieval, upd
163167
## 7. Update a Single Column
164168

165169
* **POST** `/device/<mac>/update-column`
166-
Update one specific column for a device.
170+
Update exactly one field for a device without touching any other fields.
171+
172+
> **Partial-update (PATCH) semantics.** Only the specified column is written. All other fields are left unchanged. Use this for automation, integrations, and any workflow that needs to update a single attribute.
173+
>
174+
> To replace all fields at once (e.g. saving from the edit form), use [`POST /device/<mac>`](#2-update-device-fields).
167175
168176
Allowed `columnName` values: `devName`, `devOwner`, `devType`, `devVendor`, `devGroup`, `devLocation`, `devComments`, `devIcon`, `devFavorite`, `devAlertEvents`, `devAlertDown`, `devCanSleep`, `devSkipRepeated`, `devReqNicsOnline`, `devForceStatus`, `devParentMAC`, `devParentPort`, `devParentRelType`, `devSSID`, `devSite`, `devVlan`, `devStaticIP`, `devIsNew`, `devIsArchived`, `devCustomProps`.
169177

0 commit comments

Comments
 (0)