Catalogs
User-defined reference tables, their schemas and their rows.
| GET | /catalogs | List Catalogs |
| POST | /catalogs | Create Catalog |
| DEL | /catalogs/{catalog} | Delete Catalog |
| GET | /catalogs/{catalog} | Get Catalog |
| POST | /catalogs/{catalog}/refresh | Refresh Row Count |
| GET | /catalogs/{catalog}/rows | List Rows |
| POST | /catalogs/{catalog}/rows | Insert Rows |
| DEL | /catalogs/{catalog}/rows/{row_id} | Delete Row |
| PATCH | /catalogs/{catalog}/rows/{row_id} | Update Row |
| GET | /catalogs/{catalog}/schema | Get 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.
dirtakesascordesc, 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. refreshis 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, notid, as the path parameter::idsays 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
/api/v2/catalogsEvery enabled catalog.
Query parameters
limitoptionale.g. 1000rows per page (default 1000, max 5000)
offsetoptionale.g. 0rows to skip (default 0)
Notes
totalis present. Without it a caller cannot tell a full page from a truncated one, on the one route whose whole purpose is discovery.idis the register id, and is what every other route in this folder accepts in place of the name.estimated_rowsis 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.tagsis an object, always present,{}when there are none — so a caller readstags.networkwithout 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"{
"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"
}
]
}Create Catalog
/api/v2/catalogsCreate 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_typeis one of: bigint, boolean, date, decimal, double precision, integer, jsonb, numeric, text, timestamp, timestamptz, varchar. Anidprimary 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_paramnaming the field — a reserved word for a name, an unsupported column type (withdetail.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_rowsis null until something counts: nothing has been inserted and nobody has runRefresh.
Errors
| 400 | missing_param | catalog_name, description or columns absent |
| 400 | invalid_param | illegal name; illegal or unsupported column type |
| 400 | limit_exceeded | more than 50 columns |
| 403 | forbidden | the account lacks the contributor role |
| 409 | conflict | a 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
/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
| 403 | forbidden | not yours, or a platform catalog with no owner |
| 404 | not_found | no such catalog |
| 409 | conflict | the 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
/api/v2/catalogs/{catalog}One catalog's metadata.
Path parameters
catalogrequireda 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: truemeans nobody may modify it, owner included. Writes answer 409conflict.
Errors
| 400 | invalid_param | the name is not a legal catalog identifier, or the register id is malformed |
| 404 | not_found | no such catalog, or it is disabled |
curl "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}" \
-H "Authorization: $GRIDBASE_API_KEY"{
"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"
}
}Refresh Row Count
/api/v2/catalogs/{catalog}/refreshCount 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_rowsandlast_updatedon the register row.
Errors
| 403 | forbidden | not yours, or a platform catalog with no owner |
| 404 | not_found | no such catalog |
| 409 | conflict | the 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
/api/v2/catalogs/{catalog}/rowsA page of a catalog's rows.
Path parameters
catalogrequiredtable name or register uuid
Query parameters
limitoptionale.g. 1000rows per page (default 1000, max 5000). Refused above the max.
offsetoptionale.g. 0rows to skip (default 0)
sortoptionala column name. Must be one of the catalog's own columns — see `Get Schema`. Omit for no ordering.
diroptionale.g. ascasc 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, never2024-11-20T11:49:30.309666-05:00. meta.sortandmeta.direcho the ordering actually applied, andsortis absent when none was asked for.- An unordered page makes
offsetpaging 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; passsortwhen you page, andmeta.sorttells 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
| 400 | invalid_param | unknown `sort` column (detail.allowed lists the catalog's columns); `dir` not asc/desc; `dir` without `sort`; limit/offset not an integer |
| 400 | limit_exceeded | limit above 5000 |
| 404 | not_found | no such catalog |
curl "https://utility-api-86672132515.us-east1.run.app/api/v2/catalogs/{catalog}/rows" \
-H "Authorization: $GRIDBASE_API_KEY"{
"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"
}
]
}Insert Rows
/api/v2/catalogs/{catalog}/rowsBulk insert rows. **Owner only.**
Path parameters
catalogrequiredtable name or register uuid
Body
- rows: 1–10,000 objects, keyed by column name. Omit
auto_generatedcolumns; 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.unknownlists the keys that are wrong,detail.allowedthe ones the catalog takes, anddetail.indexwhich 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 Catalogto have something writable.
Errors
| 400 | missing_param | `rows` absent or empty |
| 400 | invalid_param | unknown columns; a row with no columns; body not valid JSON for this endpoint |
| 400 | limit_exceeded | more than 10,000 rows |
| 403 | forbidden | not yours, or a platform catalog with no owner |
| 404 | not_found | no such catalog |
| 409 | conflict | the 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
/api/v2/catalogs/{catalog}/rows/{row_id}Remove one row. **Owner only.**
Path parameters
catalogrequiredrow_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: truebecause a bare{}reads as a response that failed to populate. - Deleting a row that is not there is 404, not 200.
Errors
| 400 | invalid_param | row_id not a positive integer |
| 403 | forbidden | not yours, or a platform catalog with no owner |
| 404 | not_found | no such catalog, or no such row in it |
| 409 | conflict | the 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
/api/v2/catalogs/{catalog}/rows/{row_id}Change columns on one row. **Owner only.**
Path parameters
catalogrequiredtable name or register uuid
row_idrequiredthe 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
| 400 | invalid_param | unknown columns; empty body; row_id not a positive integer; catalog name not a legal identifier |
| 403 | forbidden | not yours, or a platform catalog with no owner |
| 404 | not_found | no such catalog, or no such row in it |
| 409 | conflict | the 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
/api/v2/catalogs/{catalog}/schemaA catalog's columns.
Path parameters
catalogrequiredtable 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 inmeta.source— the same envelope as every other collection here, so the schema needs no reader of its own. namehere 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"{
"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
}
]
}