GridBase
    Console

    Search the API reference

    Find an endpoint by name or path

    Catalogs

    User-defined reference tables, their schemas and their rows.

    GET/catalogs
    POST/catalogs
    DEL/catalogs/{catalog}
    GET/catalogs/{catalog}
    POST/catalogs/{catalog}/refresh
    GET/catalogs/{catalog}/rows
    POST/catalogs/{catalog}/rows
    DEL/catalogs/{catalog}/rows/{row_id}
    PATCH/catalogs/{catalog}/rows/{row_id}
    GET/catalogs/{catalog}/schema
    How catalogs behaves

    A catalog is a table in the catalogs schema with a row in catalogs.register describing it. Anyone may read one; only its owner may write to it.

    Addressing: name or register id, one path

    {catalog} accepts either a table name or a register uuid:

    GET /api/v2/catalogs/us_egrid_emission_factors_2021
    GET /api/v2/catalogs/979c4d30-9a61-4ccc-8338-67a97883c530

    The two cannot be confused — a catalog name is letters, digits and underscores only, so nothing that parses as a uuid is a legal name.

    /catalogs/{catalog} is the catalog; /rows is its contents

    /catalogs/{catalog} is the catalog on every method, and /catalogs/{catalog}/rows is its contents on every method. One path never means the collection on one method and the resource on another.

    Behaviour worth knowing

    • Timestamps are UTC, in the register fields and inside catalog rows that have a timestamp column: 2024-11-20T16:49:30.309666Z.
    • A malformed register id is 400, naming the problem, not a 500 from the uuid cast.
    • An unknown sort column is 400 listing the columns.
    • dir takes asc or desc, and anything else is refused. An invalid direction is never silently substituted, so the order you asked for is the order you got.
    • Unknown columns in a write are named in the refusal.
    • The insert batch limit is enforced: 10,000 rows.
    • A platform catalog answers 403 with a reason. Most catalogs are ingested rather than created through the API and have no owner, so nobody may write them — which is a different fact from "no such catalog".
    • A locked catalog is 409 conflict, not 403. 403 says "you may not"; the truth is that nobody may right now, which is a state collision, and a client reading 403 reasonably retries with different credentials.
    • refresh is owner-only. It writes the register row and runs an unbounded count, so it is not something one contributor does to another user's catalog.
    • PATCH for a row, since the handler merges the fields you send.
    • row_id, not id, as the path parameter: :id says nothing about what it identifies once it is in a log line beside :catalog.

    Caching

    Reads are the live tier — 60 seconds. Only 2xx responses are stored, and a cached response replays its original status.

    The caveat is real: the cache keys on path and query, so it cannot be dropped for one writer. After a write, your own next read of that catalog may be up to 60 seconds stale. The alternative is serving every catalog scan uncached, and these are the largest read payloads in the API.

    /schema is Live too, although a schema only changes when the catalog is created or dropped: a longer-lived entry would keep answering 200 for a catalog that has since been deleted.

    Writes are no-store.

    List Catalogs

    GET/api/v2/catalogs

    Every enabled catalog.

    Query parameters

    • limitoptionale.g. 1000

      rows per page (default 1000, max 5000)

    • offsetoptionale.g. 0

      rows to skip (default 0)

    Notes

    • total is present. Without it a caller cannot tell a full page from a truncated one, on the one route whose whole purpose is discovery.
    • id is the register id, and is what every other route in this folder accepts in place of the name.
    • estimated_rows is null, not absent, when the register has never been refreshed. "Nobody has counted" is a different answer from "zero rows", and a client sizing a fetch needs to tell them apart.
    • tags is an object, always present, {} when there are none — so a caller reads tags.network without a null check. It comes back with the row rather than as 89 separate calls to the tags API.
    • Timestamps are UTC, with no local offset.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "catalogs.register",
        "class": "reference",
        "as_of": "2024-11-20T16:52:07.403737Z",
        "count": 2,
        "limit": 2,
        "offset": 0,
        "total": 89
      },
      "items": [
        {
          "id": "979c4d30-9a61-4ccc-8338-67a97883c530",
          "catalog_name": "us_egrid_emission_factors_2021",
          "description": "eGRID subregion emission factors for 2021.",
          "estimated_rows": 25,
          "locked": false,
          "tags": { "network": "us" },
          "created_at": "2024-11-20T16:52:07.403737Z",
          "updated_at": "2024-11-20T16:52:07.403737Z"
        }
      ]
    }
    Try it in the Explorer

    Create Catalog

    POST/api/v2/catalogs

    Create a catalog table and register it. **Requires the `contributor` role.**

    This runs DDL — it creates a real table in the catalogs schema. The catalog is owned by the calling account, which is what makes the write routes usable on it.

    Body

    • catalog_name: 1–63 characters, letters/digits/underscores, not starting with a digit, and not a SQL reserved word.
    • description: required.
    • columns: 1–50 definitions. data_type is one of: bigint, boolean, date, decimal, double precision, integer, jsonb, numeric, text, timestamp, timestamptz, varchar. An id primary key is added for you.

    Response: 201 { "meta": { "source": "catalogs.register", "class": "reference" }, "item": { "id": "…", "catalog_name": "my_emission_factors", "description": "Emission factors I maintain myself.", "estimated_rows": null, "locked": false, "tags": {}, "created_at": "2026-10-31T16:04:11.021043Z", "updated_at": "2026-10-31T16:04:11.021043Z" } }

    Notes

    • Everything a caller can get wrong is checked before the table is touched, and reported as invalid_param naming the field — a reserved word for a name, an unsupported column type (with detail.allowed), a duplicate column, more than 50 columns. Each is the caller's to fix, so none of them reaches the storage layer to come back as a 500.
    • A name already taken is 409 conflict.
    • estimated_rows is null until something counts: nothing has been inserted and nobody has run Refresh.

    Errors

    400missing_paramcatalog_name, description or columns absent
    400invalid_paramillegal name; illegal or unsupported column type
    400limit_exceededmore than 50 columns
    403forbiddenthe account lacks the contributor role
    409conflicta catalog with that name exists; two columns with the same name
    curl -X POST "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs" \
      -H "Authorization: $GRIDBASE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "catalog_name": "my_emission_factors",
      "description": "Emission factors I maintain myself.",
      "columns": [
        { "name": "subregion", "data_type": "varchar", "nullable": false },
        { "name": "co2_lbs_mwh", "data_type": "numeric", "nullable": true },
        { "name": "measured_at", "data_type": "timestamptz", "nullable": true }
      ]
    }'

    Delete Catalog

    DELETE/api/v2/catalogs/{catalog}

    Drop a catalog and its table. **Owner only. This destroys the rows.**

    Path parameters

    • catalogrequired

    Response: 200 { "meta": { "source": "catalogs.register" }, "item": { "id": "979c4d30-9a61-4ccc-8338-67a97883c530", "catalog_name": "my_emission_factors", "deleted": true } }

    Notes

    • There is no undo and no soft delete. The table goes.
    • A locked catalog cannot be deleted — 409 conflict.
    • Both the id and the name come back, because a client that addressed the catalog by one of them may want the other for its own records.

    Errors

    403forbiddennot yours, or a platform catalog with no owner
    404not_foundno such catalog
    409conflictthe catalog is locked
    curl -X DELETE "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}" \
      -H "Authorization: $GRIDBASE_API_KEY"

    Get Catalog

    GET/api/v2/catalogs/{catalog}

    One catalog's metadata.

    Path parameters

    • catalogrequired

      a table name **or** a register uuid. Both work:

    /api/v2/catalogs/us_egrid_emission_factors_2021
    /api/v2/catalogs/979c4d30-9a61-4ccc-8338-67a97883c530

    Notes

    • This path returns the catalog, not its rows. The rows are at /catalogs/{catalog}/rows, on every method — one path never means the collection on one method and the resource on another.
    • locked: true means nobody may modify it, owner included. Writes answer 409 conflict.

    Errors

    400invalid_paramthe name is not a legal catalog identifier, or the register id is malformed
    404not_foundno such catalog, or it is disabled
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "catalogs.register",
        "class": "reference",
        "as_of": "2024-11-20T16:52:07.403737Z"
      },
      "item": {
        "id": "979c4d30-9a61-4ccc-8338-67a97883c530",
        "catalog_name": "us_egrid_emission_factors_2021",
        "description": "eGRID subregion emission factors for 2021.",
        "estimated_rows": 25,
        "locked": false,
        "tags": {},
        "created_at": "2024-11-20T16:52:07.403737Z",
        "updated_at": "2024-11-20T16:52:07.403737Z"
      }
    }
    Try it in the Explorer

    Refresh Row Count

    POST/api/v2/catalogs/{catalog}/refresh

    Count the catalog's rows for real and store the result as `estimated_rows`. **Owner only.**

    Path parameters

    • catalogrequired

    Response: 200 — the catalog, with estimated_rows updated.

    Notes

    • Owner-only. The contributor role alone is not enough: this writes another user's register row and runs an unbounded table scan on demand, so it is not something one contributor does to another's catalog.
    • Refused while the catalog is locked.
    • It is a write despite reading like a read: it updates estimated_rows and last_updated on the register row.

    Errors

    403forbiddennot yours, or a platform catalog with no owner
    404not_foundno such catalog
    409conflictthe catalog is locked
    curl -X POST "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}/refresh" \
      -H "Authorization: $GRIDBASE_API_KEY"

    List Rows

    GET/api/v2/catalogs/{catalog}/rows

    A page of a catalog's rows.

    Path parameters

    • catalogrequired

      table name or register uuid

    Query parameters

    • limitoptionale.g. 1000

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

    • offsetoptionale.g. 0

      rows to skip (default 0)

    • sortoptional

      a column name. Must be one of the catalog's own columns — see `Get Schema`. Omit for no ordering.

    • diroptionale.g. asc

      asc or desc (default asc). Only meaningful with `sort`.

    This is the bulk read, and the one the published code examples use. It is addressable by register uuid, which is what a client usually holds:

    /api/v2/catalogs/979c4d30-9a61-4ccc-8338-67a97883c530/rows

    Notes

    • Timestamps inside the rows are UTC. The storage layer hands them back in the session's zone, so they are converted on the way out: 2024-11-20T16:49:30.309666Z, never 2024-11-20T11:49:30.309666-05:00.
    • meta.sort and meta.dir echo the ordering actually applied, and sort is absent when none was asked for.
    • An unordered page makes offset paging undefined — a row can appear on two pages or none. v2 does not invent an order, because choosing a column on the caller's behalf silently changes what page 2 contains; pass sort when you page, and meta.sort tells you whether one was applied.
    • Column values are passed through as the storage layer produced them. These are user-defined tables and v2 does not reinterpret their contents.

    Errors

    400invalid_paramunknown `sort` column (detail.allowed lists the catalog's columns); `dir` not asc/desc; `dir` without `sort`; limit/offset not an integer
    400limit_exceededlimit above 5000
    404not_foundno such catalog
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}/rows" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "catalogs.us_egrid_emission_factors_2021",
        "class": "reference",
        "count": 2,
        "limit": 2,
        "offset": 0,
        "total": 24,
        "sort": "subregion",
        "dir": "desc"
      },
      "items": [
        {
          "id": 24,
          "subregion": "SRVC",
          "total_generation_mwh": 102000000,
          "co2_emission_factor": 1080,
          "nox_emission_factor": 0.43,
          "so2_emission_factor": 0.08,
          "last_updated": "2024-11-20T16:49:30.309666Z"
        }
      ]
    }
    Try it in the Explorer

    Insert Rows

    POST/api/v2/catalogs/{catalog}/rows

    Bulk insert rows. **Owner only.**

    Path parameters

    • catalogrequired

      table name or register uuid

    Body

    • rows: 1–10,000 objects, keyed by column name. Omit auto_generated columns; the server fills them.

    Response: 201 { "meta": { "source": "catalogs.my_catalog" }, "item": { "catalog_name": "my_catalog", "rows_inserted": 2 } }

    Notes

    • Unknown columns are refused, naming them. detail.unknown lists the keys that are wrong, detail.allowed the ones the catalog takes, and detail.index which row in the batch. A nonexistent column is the caller's to fix, so it never reaches the storage layer as a 500.
    • The batch limit is enforced: 10,000 rows. Unenforced, an oversized batch either runs as an unbounded insert or fails inside the storage layer as a 500.
    • Most catalogs are ingested by the platform rather than created through the API and have no owner, so nobody may write them: those answer 403 with that as the reason. All 89 catalogs registered today are in that state. Create your own with Create Catalog to have something writable.

    Errors

    400missing_param`rows` absent or empty
    400invalid_paramunknown columns; a row with no columns; body not valid JSON for this endpoint
    400limit_exceededmore than 10,000 rows
    403forbiddennot yours, or a platform catalog with no owner
    404not_foundno such catalog
    409conflictthe catalog is locked
    curl -X POST "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}/rows" \
      -H "Authorization: $GRIDBASE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "rows": [
        { "subregion": "AKGD", "co2_emission_factor": 1620 },
        { "subregion": "AKMS", "co2_emission_factor": 1690 }
      ]
    }'

    Delete Row

    DELETE/api/v2/catalogs/{catalog}/rows/{row_id}

    Remove one row. **Owner only.**

    Path parameters

    • catalogrequired
    • row_idrequired

    Response: 200 { "meta": { "source": "catalogs.my_catalog" }, "item": { "catalog_name": "my_catalog", "id": 1, "deleted": true } }

    Notes

    • The id comes back 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.
    • Deleting a row that is not there is 404, not 200.

    Errors

    400invalid_paramrow_id not a positive integer
    403forbiddennot yours, or a platform catalog with no owner
    404not_foundno such catalog, or no such row in it
    409conflictthe catalog is locked
    curl -X DELETE "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}/rows/{row_id}" \
      -H "Authorization: $GRIDBASE_API_KEY"

    Update Row

    PATCH/api/v2/catalogs/{catalog}/rows/{row_id}

    Change columns on one row. **Owner only.**

    Path parameters

    • catalogrequired

      table name or register uuid

    • row_idrequired

      the row's integer id. Named `row_id` rather than `id`, which says nothing about what it identifies once it is in a log line beside `:catalog`.

    PATCH: the columns you send are merged into the stored row and the rest are left alone, which is what PATCH means and PUT does not.

    Body: the columns to change, keyed by name. At least one.

    Response: 200 { "meta": { "source": "catalogs.my_catalog" }, "item": { "catalog_name": "my_catalog", "id": 1, "updated": true, "columns": ["co2_emission_factor"] } }

    Notes

    • The columns changed are echoed back, so a caller does not have to diff a subsequent GET to find out whether the write took.
    • An empty body is 400, not a 200 that changed nothing.
    • Unknown columns are refused and named, as on the insert.

    Errors

    400invalid_paramunknown columns; empty body; row_id not a positive integer; catalog name not a legal identifier
    403forbiddennot yours, or a platform catalog with no owner
    404not_foundno such catalog, or no such row in it
    409conflictthe catalog is locked
    curl -X PATCH "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}/rows/{row_id}" \
      -H "Authorization: $GRIDBASE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "co2_emission_factor": 1625
    }'

    Get Schema

    GET/api/v2/catalogs/{catalog}/schema

    A catalog's columns.

    Path parameters

    • catalogrequired

      table name or register uuid

    Read this before writing. auto_generated columns are filled by the server and must not appear in an insert or an update; sending one is a 400 that names it.

    Notes

    • The columns are items, and the catalog is in meta.source — the same envelope as every other collection here, so the schema needs no reader of its own.
    • name here is also the allow-list for ?sort= on the rows route.
    curl "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}/schema" \
      -H "Authorization: $GRIDBASE_API_KEY"
    Response200
    {
      "meta": {
        "source": "catalogs.us_egrid_emission_factors_2021",
        "class": "reference",
        "count": 7
      },
      "items": [
        {
          "name": "id",
          "data_type": "integer",
          "nullable": false,
          "auto_generated": true,
          "primary_key": true
        },
        {
          "name": "subregion",
          "data_type": "character varying",
          "nullable": false,
          "auto_generated": false,
          "primary_key": false
        }
      ]
    }
    Try it in the Explorer