Tags
Arbitrary name/value metadata attached to any entity by its uuid.
| GET | /tags/{target_id} | List Tags |
| POST | /tags/{target_id} | Create Tag |
| DEL | /tags/{target_id}/{tag_id} | Delete Tag |
| PATCH | /tags/{target_id}/{tag_id} | Update Tag |
| GET | /tags/names | Tag Names |
How tags behaves
The target is any uuid in the system — a sensor, a node, a network. There is no foreign key, by design: tags annotate whatever a caller needs to annotate.
Behaviour worth knowing
- The list is ordered by
name, thenid, so paging it is well defined: a row cannot appear on two pages or on none. - An entity with no tags is 200 with an empty list. Having no tags is not a missing entity.
- Bad paging is refused.
?limit=abcand?limit=5000are both 400 with a machinecode, never silently the default. - A duplicate name is 409
conflict. The table hasUNIQUE (target_id, name), and a caller is told the request can never succeed rather than invited to retry it. - PATCH, not PUT. PATCH merges the fields you send, which is what the method promises.
{"value": null}clears a value. An absent field and an explicit null are distinguished, so a value can be removed and not only changed.- Over-long input is 400, naming the field.
- Path parameters are snake_case —
:target_id,:tag_id.
There is no separate count route: meta.total on the list is the same
number, so ?limit=1 returns one row and the full count.
Caching
Nothing here is cached; every route sends Cache-Control: no-store and
X-Cache-Status: BYPASS. Tags are written through this same API, usually
by the client about to read them back, so a 60-second copy would hide a
caller's own write. These are single-row lookups on an indexed uuid, so
there is nothing to win.
meta.class
Absent on every route here. A tag is not a reading, a derivation or a forecast — calling someone's typed label "measured" would be untrue. The field-presence rule omits what does not apply.
Create Tag
/api/v2/tags/{target_id}Attach a new tag to an entity.
Path parameters
target_idrequiredthe uuid to tag
Body
- name: required, 1–255 characters. Trimmed.
- value: optional. Omit it or send null for a bare label; both store null.
Response: 201 { "meta": { "source": "tag" }, "item": { "id": 684395, "target_id": "00000a49-28ff-481b-a787-5ab8ad7da500", "name": "staleAfter", "value": "30m" } }
Notes
{meta, item}— the single-object envelope, as on every other route.- A tag name is unique per target. Creating one that exists is 409
conflict, with the name and target indetail. Reporting the constraint violation as a 500 would tell a caller to retry a request that can never succeed, and log it as a server fault. - To change an existing tag, PATCH it. This route does not upsert.
Errors
| 400 | missing_param | name absent, empty, or only whitespace |
| 400 | invalid_param | body is not valid JSON for this endpoint (the binding error is in detail.parse_error); name longer than 255; value longer than 65536; target_id not a uuid |
| 409 | conflict | a tag with that name already exists on this target |
curl -X POST "https://utility-api-86672132515.us-east1.run.app/api/v2/tags/{target_id}" \
-H "Authorization: $GRIDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "staleAfter",
"value": "30m"
}'Delete Tag
/api/v2/tags/{target_id}/{tag_id}Remove a tag.
Path parameters
target_idrequiredthe uuid the tag is attached to
tag_idrequiredthe tag's integer id
Response: 200 { "meta": { "source": "tag" }, "item": { "id": 619359, "deleted": true } }
Notes
- The id is returned so a client issuing several deletes can match responses
to requests, and
deleted: truebecause a bare{}reads as a response that failed to populate. Neither is prose a client has to match on. - A tag id belonging to another target is 404, as it is on PATCH.
- Deleting an already-deleted tag is 404, not 200. This route does not pretend to be idempotent about a row it cannot find.
Errors
| 400 | invalid_param | target_id not a uuid; tag_id not a positive integer |
| 404 | not_found | no such tag on this target |
curl -X DELETE "https://utility-api-86672132515.us-east1.run.app/api/v2/tags/{target_id}/{tag_id}" \
-H "Authorization: $GRIDBASE_API_KEY"Update Tag
/api/v2/tags/{target_id}/{tag_id}Change a tag's name or value.
Path parameters
target_idrequiredthe uuid the tag is attached to
tag_idrequiredthe tag's integer id (a SERIAL, not a uuid)
PATCH, because the write is a merge: the fields you send are updated and the ones you omit are left alone. That is what PATCH means, and what PUT does not.
Body — send either field, or both:
- name: a new name. May not be null.
- value: a new value, or null to clear it.
Response: 200 { "meta": { "source": "tag" }, "item": { "id": 619359, "target_id": "00000a49-28ff-481b-a787-5ab8ad7da500", "name": "staleAfter", "value": "45m" } }
Notes
{"value": null}clears the value. An absent field and an explicit null are distinguished, so a value can be removed and not only changed.- A body with no recognised field is 400, not a 200 that changed nothing. Reporting success for a request that did nothing is how a client with a typo'd field name ships broken writes that look fine.
- The item returned is re-read from the table, so it is what a subsequent GET will show rather than what this handler assembled.
- A tag id that exists but belongs to another target is 404, not 403 — that the id exists at all is not something to learn from a request about a different entity.
Errors
| 400 | invalid_param | target_id not a uuid; tag_id not a positive integer; body empty of updatable fields (detail.updatable lists them); name null; name or value too long |
| 404 | not_found | no such tag on this target |
| 409 | conflict | the new name already exists on this target |
curl -X PATCH "https://utility-api-86672132515.us-east1.run.app/api/v2/tags/{target_id}/{tag_id}" \
-H "Authorization: $GRIDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"value": "45m"
}'Tag Names
/api/v2/tags/namesEvery distinct tag name in use, across all targets.
Query parameters
limitoptionale.g. 1000names per page (default 1000, max 5000)
offsetoptionale.g. 0names to skip (default 0)
The vocabulary a UI offers in an autocomplete, or a client checks a name against before writing one.
Notes
itemsis a list of strings, and still inside the envelope. A bare JSON array would leave a caller unable to tell a full page from a truncated one, and would break a generic client that unwrapsitemson this route alone.totalcounts distinct names, which is the same thingitemslists.- Names are whatever callers have written, including names that only differ in case. This route reports what is there rather than normalising it.
Errors
| 400 | invalid_param | limit or offset is not an integer |
| 400 | limit_exceeded | limit above 5000 |
curl "https://utility-api-86672132515.us-east1.run.app/api/v2/tags/names" \
-H "Authorization: $GRIDBASE_API_KEY"{
"meta": {
"source": "tag",
"count": 5,
"limit": 5,
"offset": 0,
"total": 53
},
"items": [
"coord_match_score",
"coord_quality",
"coord_source",
"dataClass",
"staleAfter"
]
}