GridBase
    Console

    Search the API reference

    Find an endpoint by name or path

    Tags

    Arbitrary name/value metadata attached to any entity by its uuid.

    GET/tags/{target_id}
    POST/tags/{target_id}
    DEL/tags/{target_id}/{tag_id}
    PATCH/tags/{target_id}/{tag_id}
    GET/tags/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, then id, 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=abc and ?limit=5000 are both 400 with a machine code, never silently the default.
    • A duplicate name is 409 conflict. The table has UNIQUE (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.

    List Tags

    GET/api/v2/tags/{target_id}

    Every tag on one entity.

    Path parameters

    • target_idrequired

      the uuid the tags are attached to — a sensor, node, network, or anything else.

    Query parameters

    • limitoptionale.g. 100

      rows per page (default 100, max 1000). Refused above the max.

    • offsetoptionale.g. 0

      rows to skip (default 0)

    Notes

    • Ordered by name, then id, which makes paging well defined: without a total order a row can come back on two pages or on none.
    • An entity with no tags is 200 with items: [] and total: 0, not a 404. Having no tags is not a missing entity.
    • value is null, not absent, for a bare label. The key is always present.
    • meta.total is the full count behind the target, so offset + count against it tells a caller whether more pages exist. There is no separate /count route; ?limit=1 gives one row and the full count.
    • No meta.class: a tag is not a reading.

    Errors

    400invalid_paramtarget_id is not a uuid; limit/offset not an integer; limit below 1; offset negative
    400limit_exceededlimit above 1000
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/tags/{target_id}" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "tag",
        "count": 2,
        "limit": 100,
        "offset": 0,
        "total": 2
      },
      "items": [
        {
          "id": 619359,
          "target_id": "00000a49-28ff-481b-a787-5ab8ad7da500",
          "name": "staleAfter",
          "value": "30m"
        },
        {
          "id": 684394,
          "target_id": "00000a49-28ff-481b-a787-5ab8ad7da500",
          "name": "urn",
          "value": "spp:lepa:lmp;market=rt"
        }
      ]
    }
    Try it in the Explorer

    Create Tag

    POST/api/v2/tags/{target_id}

    Attach a new tag to an entity.

    Path parameters

    • target_idrequired

      the 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 in detail. 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

    400missing_paramname absent, empty, or only whitespace
    400invalid_parambody 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
    409conflicta 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

    DELETE/api/v2/tags/{target_id}/{tag_id}

    Remove a tag.

    Path parameters

    • target_idrequired

      the uuid the tag is attached to

    • tag_idrequired

      the 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: true because 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

    400invalid_paramtarget_id not a uuid; tag_id not a positive integer
    404not_foundno 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

    PATCH/api/v2/tags/{target_id}/{tag_id}

    Change a tag's name or value.

    Path parameters

    • target_idrequired

      the uuid the tag is attached to

    • tag_idrequired

      the 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

    400invalid_paramtarget_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
    404not_foundno such tag on this target
    409conflictthe 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

    GET/api/v2/tags/names

    Every distinct tag name in use, across all targets.

    Query parameters

    • limitoptionale.g. 1000

      names per page (default 1000, max 5000)

    • offsetoptionale.g. 0

      names to skip (default 0)

    The vocabulary a UI offers in an autocomplete, or a client checks a name against before writing one.

    Notes

    • items is 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 unwraps items on this route alone.
    • total counts distinct names, which is the same thing items lists.
    • Names are whatever callers have written, including names that only differ in case. This route reports what is there rather than normalising it.

    Errors

    400invalid_paramlimit or offset is not an integer
    400limit_exceededlimit above 5000
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/tags/names" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "tag",
        "count": 5,
        "limit": 5,
        "offset": 0,
        "total": 53
      },
      "items": [
        "coord_match_score",
        "coord_quality",
        "coord_source",
        "dataClass",
        "staleAfter"
      ]
    }
    Try it in the Explorer