Contract A08 (feature 004).
Favourites API (/v1/me/favorites)
A user can star plants in the web console. Favourites belong to the user,
not to an org. They show up as isFavorite on the
web plant list
and can be listed on their own here.
A Super Admin or Administrator's My favourites option on the plant list (web and mobile, 2026-11-25) is
GET /v1/plants?favorite=true, not this endpoint. Use this endpoint to collect favourite ids for the TCP
list_plants filters.plantIds. See Plant list by profile.
:::note Status
Verified against packages/api/src/handlers/favorites.ts and
packages/core/src/favorites/repository.ts. Deployed on dev (verified live 2026-10-13); no response was captured for these docs, so all examples are illustrative.
:::
Only type = PLANT exists here; DEVICE is rejected with 400.
:::info Device favourites live on the TCP server
Devices moved to the TCP server (ADR 0012), and so did device
favourites. Starring a device, listing starred devices, the automatic
favourite a Super Admin or Administrator gets when importing or looking up
a device, and the lazy-loaded favourites (15 first, then 10 per load) are
all WebSocket messages: add_favourite, remove_favourite,
list_favourites. See the TCP Server's
web console devices page
and the device import and favourites mobile guide.
This HTTP endpoint will not gain a DEVICE type.
:::
GET /v1/me/favorites — List favourites
- Auth: Required. Authorization: self. Every item is re-checked on
read (
plants ≥ VIEW); plants the user can no longer see are left out silently. - Headers:
Authorization. Favourites are per user:X-Org-Idis ignored and visibility is checked across all of the user's memberships.
| Param | Type | Required | Default | Validation |
|---|---|---|---|---|
type | PLANT | Yes | — | Anything else → 400 VALIDATION_FAILED |
limit | integer | No | 25 | 1–50 |
cursor | string | No | — | From a previous nextCursor |
Response
{
items: Array<{ type: 'PLANT'; entityId: string; createdAt: string; entity?: WebPlantListItem }>;
nextCursor?: string;
refs: Refs; // same shape as the web plant list
}
entity may be absent (B-1). Legacy plants — created by the mobile app
and not yet migrated — that the caller favourited are returned without
entity (packages/core/src/favorites/repository.ts; access comes from the
caller's legacy per-plant role). Render them from entityId alone or fetch
the plant. Such plants have no org id and no search tokens, so they still do
not appear in search suggestions or the web plant list until the owner
runs npm run migrate:legacy-plants (see
Operations).
Successful response — illustrative example
{ "items": [{ "type": "PLANT", "entityId": "01JB5Q0000000000000000000A", "createdAt": "2026-10-01T08:00:00.000Z",
"entity": { "plantId": "01JB5Q0000000000000000000A", "code": "PL-0518", "name": "DHA Phase 6 Residence",
"lifecycle": "ACTIVE", "gridTopology": "ON_GRID", "hasBattery": false,
"customerOrgId": "01JB5R0000000000000000000A", "tagIds": [],
"createdAt": "2025-03-03T09:00:00.000Z", "updatedAt": "2026-09-01T10:00:00.000Z",
"version": 4, "isFavorite": true } }],
"refs": { "orgs": {}, "tags": {} } }
Errors
| Status | code | When | What the FE should do |
|---|---|---|---|
| 400 | VALIDATION_FAILED | Missing or unknown type, unknown param | Fix the query |
| 400 | INVALID_CURSOR | Malformed or foreign cursor | Reload from page 1 |
| 401 | — (gateway body) | Missing/expired token | Refresh and retry |
| 503 | DEPENDENCY_UNAVAILABLE | DynamoDB | Retry with backoff |
Edge cases: a page can be short (hidden favourites removed) while
nextCursor is still present; keep paging. An empty list is 200 with
items: [].
:::note Admin-web 2026-11-24
Page 1 also carries total: the caller's stored favourites of that type, including ones they can no longer see. See Admin-web list totals, counts and filter options.
:::
PUT /v1/me/favorites/{type}/{id} — Star
DELETE /v1/me/favorites/{type}/{id} — Unstar
- Auth: Required. Authorization:
PUTneedsplants ≥ VIEWon the plant.DELETEdoes no access check; it only removes the user's own row. - Path:
type=PLANT;id= plant ULID. - Body: none. Idempotency: natural; no
Idempotency-Keyneeded. - Response:
204 No Content.
| Status | code | When | What the FE should do |
|---|---|---|---|
| 204 | — | Starred / unstarred. Repeating either call also returns 204; unstarring a plant that was never starred returns 204 | Update the star |
| 401 | — | Token | Refresh and retry |
| 404 | NOT_FOUND | PUT only: plant does not exist, or the user has no access path to it (deliberately the same answer) | Remove the star from the UI |
| 410 | GONE | PUT on a plant that is being deleted | Remove the plant from the UI |
| 422 | VALIDATION_FAILED | Unknown type or id is not a ULID | Bug in the client |
| 503 | DEPENDENCY_UNAVAILABLE | DynamoDB | Retry |
Edge cases: if the user later loses access to a starred plant, the
favourite stays stored but is hidden from lists and from favorite=true;
it reappears if access is restored.