GridBase
    Console

    Search the API reference

    Find an endpoint by name or path

    Events

    Grid events — outages, alerts, planned work — attached to a target sensor, with their affected areas and the nodes those areas touch.

    GET/events
    POST/events
    DEL/events/{event_id}
    GET/events/{event_id}
    GET/events/{event_id}/areas
    GET/events/{event_id}/nodes
    GET/events/active/map
    GET/events/count
    GET/events/nearby
    How events behaves

    Nine routes, one envelope.

    1. The list is bounded by a time window

    GET /api/v2/events defaults to 30 days either side of now and accepts from/to up to a 366-day span. The table holds 1,213,926 rows; a month either side of now plans across 60,053 of them.

    The window straddles now in both directions because an event may be planned work that has not started; a window ending at now would hide every scheduled outage.

    meta.coverage always states the window actually applied, so a caller never has to infer it. To reach further back, ask: ?from=2024-01-01&to=2024-12-31.

    2. The count honours the filters

    /events/count takes the same parameters as /events and both read them through one function, so the two cannot drift. /events also carries the filtered count as meta.total, which is usually the better call: one request instead of two.

    3. A delete of something that does not exist is a 404

    Deleting an id that was never real is refused rather than answered "deleted".

    The same holds on /areas and /nodes: 404 means no such event, and items: [] means the event exists and has none. The two are different facts and they get different answers.

    Parameter names

    Every query parameter is snake_case, and the path parameter is :event_id.

    On /events/nearby the parameters are postal_code (matching /geo/zip/{postal_code}) and radius_miles, which defaults to 25; the response warns when the default was used, so a short list is not mistaken for an empty neighbourhood.

    active_only takes true or false, and nothing else — one spelling for a flag is one fewer thing for a client and a log reader to disagree about.

    severity

    A smallint, running 1–5 in the data today. The accepted range is the column's, not the data's: capping at 5 would refuse a valid query the day a publisher emits a 6. ?severity=high is refused with a machine code.

    Caching

    /events, /events/count, /events/nearby, /events/active/map and the single event are the live tier: an event's status changes while it runs. /areas and /nodes are slow — they derive from the target's geometry, which does not change mid-event. The two writes are NoStore.

    Writes

    POST /events and DELETE /events/{event_id} need write capability on the token and the contributor role.

    POST validates every NOT NULL column, so an event cannot be created with an empty type, an empty description, or a start_at at the zero time.

    List Events

    GET/api/v2/events

    Events whose `start_at` falls in the window.

    Query parameters

    • limitrequirede.g. 10
    • offsetoptionale.g. 0
    • fromoptionale.g. 2026-10-01
    • tooptionale.g. 2026-11-30
    • target_idoptionale.g. 743c1bf7-8500-4d04-9516-ec5dfd78423f
    • severityoptionale.g. 5
    • min_severityoptionale.g. 3
    • max_severityoptionale.g. 5
    • statusoptionale.g. active
    • categoryoptionale.g. Met
    • typeoptionale.g. weather
    • active_atoptionale.g. 2026-11-11T12:00:00Z
    • sortoptionale.g. start_at
    • diroptionale.g. desc

    The window

    Defaults to 30 days either side of now, from/to to override, max span 366 days. meta.coverage states what was applied.

    The bound is why a bare request is quick: unbounded it plans across all 1,213,926 rows of public.event, where the default window plans across 60,053. To reach further back, say so: ?from=2024-01-01&to=2024-12-31.

    Both directions, because an event may be planned work that has not started.

    Query Parameters

    • from, to: RFC 3339 or a bare YYYY-MM-DD. Filters on start_at. Defaults to now ±30 days, max span 366 days.
    • target_id: the sensor the event is attached to.
    • severity: exact match. min_severity / max_severity for a range. 1-5 in the data; the accepted range is the column's.
    • status, category, type: exact match.
    • active_at: RFC 3339. Events that had started and had not ended at that instant. Independent of from/to, which bound when an event started.
    • sort: any of meta.sortable. Default created_at.
    • dir: asc | desc. Default desc.
    • limit: default 100, max 1000.
    • offset: default 0.

    Response

    Worth knowing

    meta.total is the filtered count, so a client can size the collection and page it.

    No events is 200 with items: [] — never null, and never a 404. Having no events in the window is an answer, not a missing resource.

    limit above the ceiling is refused with limit_exceeded naming the max, not clamped.

    Timestamps are UTC, whatever offset the column carries.

    Errors

    400invalid_paramtarget_id not a uuid; severity not an integer; active_at not RFC 3339; unknown sort or dir
    400limit_exceededlimit above 1000
    400window_too_largefrom/to span longer than 366 days
    Cost
    0.13s for a page of 1, 0.52s for a page of 2 with the count.
    Cache
    live tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/events?limit=10" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "event",
        "class": "measured",
        "coverage": { "from": "2026-10-12T11:31:13Z", "to": "2026-12-11T11:31:13Z" },
        "count": 10, "limit": 10, "offset": 0, "total": 60053,
        "sort": "created_at", "dir": "desc",
        "sortable": ["category", "certainty", "created_at", "end_at", "id",
                     "name", "severity", "source", "source_id", "start_at",
                     "status", "target_id", "type", "urgency"],
        "sort_directions": ["asc", "desc"]
      },
      "items": [
        {
          "id": "9a9d714c-5869-4314-bd23-3fdb82c168e8",
          "target_id": "743c1bf7-8500-4d04-9516-ec5dfd78423f",
          "severity": 1,
          "name": "Test Message",
          "type": "weather",
          "description": "...",
          "start_at": "2026-11-11T11:30:00Z",
          "end_at": null,
          "created_at": "2026-11-11T11:30:16.461862Z",
          "status": "Actual", "category": "Met",
          "certainty": "Observed", "urgency": "Past",
          "source": "nws", "source_id": "...", "source_url": null
        }
      ]
    }
    Try it in the Explorer

    Create Event

    POST/api/v2/events

    Create an event.

    Needs write capability on the token and the contributor role. Both are enforced by the v2 group gate; the two are an intersection, not a fallback.

    Every NOT NULL column is validated

    Binding the body straight onto the database row and checking target_id alone lets {"target_id": "..."} insert an event with an empty type, an empty description and start_at at the zero time, which renders as year 1. It also lets a client send id and created_at and watch them be silently dropped.

    Required: target_id, severity, type, description, start_at, source, source_id. Optional (the nullable columns): name, end_at, status, category, certainty, urgency, source_url.

    Required means present, not non-zero. "severity": 0 is a value a caller may mean, and absence is the thing being refused — which is why the request type is all pointers.

    end_at, when given, must be after start_at — otherwise an event can be stored ending before it began.

    Response

    201, {meta, item} carrying the stored row with its generated id and created_at.

    Errors

    400invalid_parambody is not JSON; target_id is the nil uuid; end_at not after start_at
    400missing_paramany required field absent — `field` names which
    403forbiddentoken is read-only, or the caller lacks `contributor`
    curl -X POST "https://utility-api-86672132515.us-east1.run.app/api/v2/events" \
      -H "Authorization: $GRIDBASE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "target_id": "743c1bf7-8500-4d04-9516-ec5dfd78423f",
      "severity": 3,
      "type": "outage",
      "description": "Planned feeder maintenance",
      "start_at": "2026-12-01T08:00:00Z",
      "end_at": "2026-12-01T16:00:00Z",
      "name": "Feeder 12 maintenance",
      "status": "issued",
      "category": "Infra",
      "certainty": "Observed",
      "urgency": "Future",
      "source": "ops",
      "source_id": "ops-2026-12-01-f12",
      "source_url": "https://example.invalid/ops/f12"
    }'

    Delete Event

    DELETE/api/v2/events/{event_id}

    Delete an event.

    Path parameters

    • event_idrequirede.g. 00000000-0000-0000-0000-000000000000

    Needs write capability on the token and the contributor role.

    Deleting something that is not there is a 404

    A delete is an Exec and never returns sql.ErrNoRows, so checking for that error is a dead branch: deleting an id that was never real would answer 200 {"message": "deleted"}, reporting having deleted something it did not find — and a client cleaning up has no way to notice it was wrong about what existed.

    Here the event is read first. 404 if it is not there, and only then the delete.

    Response

    {meta, item} — the same shape the tag delete uses, so a client handling both reads one.

    The example above targets the nil uuid and asserts the 404, so the request is safe to run against any environment. Point it at a real id to delete.

    Errors

    400invalid_paramevent_id is not a uuid
    404not_foundno event with that id
    403forbiddentoken is read-only, or the caller lacks `contributor`
    curl -X DELETE "https://utility-api-86672132515.us-east1.run.app/api/v2/events/00000000-0000-0000-0000-000000000000" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": { "source": "event" },
      "item": { "id": "...", "deleted": true }
    }

    Get Event

    GET/api/v2/events/{event_id}

    One event by id.

    Path parameters

    • event_idrequirede.g. 9a9d714c-5869-4314-bd23-3fdb82c168e8

    {meta, item}, like every other single object here, so a generic client unwraps this body the same way it unwraps the rest.

    meta.as_of is the event's created_at — the moment this record was written, not the time of the request.

    Response

    Errors

    400invalid_paramevent_id is not a uuid
    404not_foundno event with that id
    Cost
    0.08s.
    Cache
    live tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/events/9a9d714c-5869-4314-bd23-3fdb82c168e8" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "event",
        "class": "measured",
        "as_of": "2026-11-11T11:30:16.461862Z"
      },
      "item": { ...the event, fields as in List Events... }
    }
    Try it in the Explorer

    Event Areas

    GET/api/v2/events/{event_id}/areas

    The event's affected areas, as GeoJSON.

    Path parameters

    • event_idrequirede.g. 9a9d714c-5869-4314-bd23-3fdb82c168e8

    404 now means the event does not exist

    404 means no such event; items: [] means the event has no areas. Answering 404 "no event areas found" on sql.ErrNoRows is a dead branch — a list query never returns that error — and answering 200 with an empty list for an id that was never real has it backwards. A client cannot then tell "this event affects no areas" from "there is no such event", which is the whole point of a 404.

    Here the event is checked first: 404 if it does not exist, items: [] if it exists and has no areas.

    Response

    class: "reference" — an area is a catalogued boundary, not a reading.

    Errors

    400invalid_paramevent_id is not a uuid
    404not_foundno event with that id
    Cost
    0.13s.
    Cache
    slow tier. An event's geometry does not change while it runs.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/events/9a9d714c-5869-4314-bd23-3fdb82c168e8/areas" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": { "source": "event_area", "class": "reference", "count": 0 },
      "items": [
        {
          "event_id": "9a9d714c-5869-4314-bd23-3fdb82c168e8",
          "description": "Surprise Valley California",
          "area": { "type": "Polygon", "coordinates": [ ... ] }
        }
      ]
    }
    Try it in the Explorer

    Event Nodes

    GET/api/v2/events/{event_id}/nodes

    The nodes whose geometry the event's affected area touches.

    Path parameters

    • event_idrequirede.g. 9a9d714c-5869-4314-bd23-3fdb82c168e8

    Same rule as Event Areas: 404 means there is no such event, and items: [] means the event affects no nodes.

    class: "computed" — this is a spatial intersection, not a stored fact.

    Response

    Field order puts network_name beside network_id.

    Errors

    400invalid_paramevent_id is not a uuid
    404not_foundno event with that id
    Cost
    0.17s.
    Cache
    slow tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/events/9a9d714c-5869-4314-bd23-3fdb82c168e8/nodes" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": { "source": "node", "class": "computed", "count": 2 },
      "items": [
        {
          "id": "...", "name": "COLE", "network_id": "...",
          "network_name": "PJM", "lat": 39.9, "lon": -75.1,
          "node_type_id": "..."
        }
      ]
    }
    Try it in the Explorer

    Active Events Map

    GET/api/v2/events/active/map

    Currently active events with the geometry to draw them.

    Query parameters

    • limitrequirede.g. 50
    • offsetoptionale.g. 0

    The limits are deliberately low

    default 250, max 2000.

    This is the slowest endpoint in the API — ~819ms mean over 491 calls in the measured window — because every row carries a geometry. A map draws what fits on a screen, so the ceiling that matters is the one a viewport needs; a caller who genuinely wants more pages for it.

    centroid_lon / centroid_lat are numbers or null

    They are ST_X/ST_Y of a point, so they are a number or they are null — never a string. Letting the driver decide the type makes the JSON type whatever came back from the database that time.

    Response

    Errors

    400limit_exceededlimit above 2000
    Cost
    0.68s for a page of 1.
    Cache
    live tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/events/active/map?limit=50" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "event", "class": "measured",
        "count": 50, "limit": 50, "offset": 0
      },
      "items": [
        {
          ...the event...,
          "geometry": { "type": "Polygon", "coordinates": [ ... ] },
          "centroid_lon": -119.9,
          "centroid_lat": 41.5
        }
      ]
    }
    Try it in the Explorer

    Count Events

    GET/api/v2/events/count

    How many events match the filter.

    Query parameters

    • fromoptionale.g. 2026-10-01
    • tooptionale.g. 2026-11-30
    • target_idoptionale.g. 743c1bf7-8500-4d04-9516-ec5dfd78423f
    • severityoptionale.g. 5
    • statusoptionale.g. active

    Takes the same parameters as /events, read through the same function, so the count cannot apply a different filter from the list it describes.

    The count applies your filters

    A count that ignored them would be SELECT count(*) FROM event — 1,213,926 whatever you asked for, and no way to learn how many rows your own filter matched. The parameters here are the list's, read through the same function.

    Measured: a bare count is 60,053 (the default window); ?severity=5 is 1,191.

    Why this one exists when Tags and Notes drop theirs

    v2 does not usually keep a /count beside a list: meta.total is the same number and ?limit=1 fetches it, so Tags and Notes both dropped the route.

    Events keeps it because the measurement differs. public.event holds 1,213,926 rows, and ?limit=1 still runs the list query beside the count: 0.13s, against 0.07s for the count alone. On a table where the list is the expensive half, the second endpoint buys something.

    When you want both numbers and the rows, call /events and read meta.total — one request, not two.

    Response

    {meta, item}, not {meta, items} — there is no collection here, so there is no count in meta either.

    Error Responses: the same set as List Events.

    Cost
    0.07s unfiltered, 0.37s with a severity filter.
    Cache
    live tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/events/count" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "event",
        "class": "measured",
        "coverage": { "from": "2026-10-12T11:31:13Z", "to": "2026-12-11T11:31:13Z" }
      },
      "item": { "count": 60053 }
    }
    Try it in the Explorer

    Events Nearby

    GET/api/v2/events/nearby

    Events near a postal code, with the distance to each.

    Query parameters

    • postal_coderequirede.g. 10001
    • radius_milesrequirede.g. 50
    • active_onlyoptionale.g. true
    • statusoptionale.g. active
    • categoryoptionale.g. Met
    • typeoptionale.g. weather
    • start_afteroptionale.g. 2026-11-01T00:00:00Z
    • start_beforeoptionale.g. 2026-11-30T00:00:00Z
    • end_afteroptionale.g. 2026-11-01T00:00:00Z
    • end_beforeoptionale.g. 2026-11-30T00:00:00Z
    • limitoptionale.g. 100
    • offsetoptionale.g. 0

    Renamed parameters

    • zipcode becomes postal_code, matching /geo/zip/{postal_code}.
    • the radius is radius_miles, as everywhere else here — a radius is not a range.

    radius_miles has a default of 25, so a bare request gets an answer. When the default is used the response says so in meta.warnings, and a short list is not mistaken for an empty neighbourhood.

    The four date filters are this query's own, not the list's, which is why they are not from/to — those would mean something different here.

    active_only takes true or false only, default true. One spelling for a flag is one fewer thing for a client and a log reader to disagree about.

    Query Parameters

    • postal_code: required.
    • radius_miles: 1-500, default 25.
    • active_only: true | false, default true.
    • status, category, type: exact match.
    • start_after, start_before, end_after, end_before: RFC 3339.
    • limit: default 100, max 1000.
    • offset: default 0.

    Response

    notes carries provenance about the data — how the distance was measured — where warnings describes what this request did. A client may reasonably surface a note to a user and should not surface a paging warning the same way.

    a postal-code centroid.

    Errors

    400missing_parampostal_code absent
    400invalid_paramradius_miles outside 1-500 or not an integer; a date filter not RFC 3339; active_only not true/false
    400limit_exceededlimit above 1000
    Cost
    1.05s. The slowest read in this package; it is a spatial query against
    Cache
    live tier.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/events/nearby?postal_code=10001&radius_miles=50" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "event", "class": "measured",
        "count": 0, "limit": 100, "offset": 0,
        "warnings": ["radius_miles defaulted to 25"],
        "notes": ["distance_miles is measured from the centroid of the postal code"]
      },
      "items": [
        { ...the event..., "distance_miles": 12.4 }
      ]
    }
    Try it in the Explorer