Skip to main content

Versioning and workflow

Versioning and workflow are two switches on a table:

  • Versioning keeps history. When a feature is edited through the Feature API or WFS-T, its previous state is kept in the table as an ended version instead of being overwritten.
  • Workflow builds on versioning and adds approval. Every feature has a status — 1 drafted, 2 reviewed or 3 published — and a sub-user's workflow role decides which status their edits get.

Access model:

  • All requests require an Authorization: Bearer header.
  • Only the database owner (super user) can switch versioning and workflow on and off and set workflow roles. Others get 403 (SUPER_USER_ONLY).
  • Access to workflow items is by workflow role, not by schema ownership or table privileges. A sub-user without a role on the table gets 403 (NO_WORKFLOW_ROLE).
  • The database owner needs no role and acts as publisher.

How it works​

Versioning​

A versioned table has five extra system columns (see System columns). Each row is one version of a feature. The current version has no end date; when the feature is edited, the state before the edit is kept as a row with an end date — an ended version. All versions of a feature share the same gc2_version_gid.

Workflow​

On a table with workflow, a feature moves forward through three statuses:

StatusNameReached by
1draftedAn edit by an author.
2reviewedAn edit or an approval by a reviewer.
3publishedAn edit or an approval by a publisher or the database owner.

A typical flow:

  1. An author inserts, updates or deletes a feature through the Feature API or WFS-T. The edit is a draft (status 1).
  2. A reviewer lists the items waiting for them and approves the feature. It is now reviewed (status 2).
  3. A publisher approves it. It is now published (status 3).

Every edit and every approval is logged, and the latest logged step of a feature is its workflow item. An approval signs the feature with the caller's name in the slot of their role (author, reviewer, publisher), and the state before the step is kept as an ended version.

Users without a role on the table see published features only. There is no reject or "send back" operation: a feature only moves forward by approval, or gets a new status from a new edit.

Enable versioning and workflow​

versioning and workflow are boolean fields on the table resource. GET returns them in the full table response (not with namesOnly), and PATCH sets them. Workflow needs versioning; both can be enabled in one request:

Request
PATCH https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"versioning": true,
"workflow": true
}
RequestResult
"versioning": trueAdds the gc2_version_* columns. From then on, edits through the Feature API and WFS-T keep the previous state as an ended version.
"workflow": trueAdds gc2_status and gc2_workflow. Existing rows are marked as published.
"versioning": falseDeletes every ended version and drops the gc2_version_* columns. The table is left with one row per feature.
"workflow": falseDrops gc2_status and gc2_workflow and deletes the table's workflow log. Every row is an ordinary row afterwards, whatever status it had.
Disabling deletes data

"versioning": false deletes the history of the table, and "workflow": false deletes its workflow log. Neither can be undone.

The fields are set with PATCH only — create the table first, then enable them.

StatusMeaning
403SUPER_USER_ONLY — only the database owner can set either field.
409VERSIONING_REQUIRED — "workflow": true on a table without versioning, and "versioning": true is not in the same request.
409WORKFLOW_ENABLED — "versioning": false while the table has workflow. Send "workflow": false in the same request.
409NOT_A_TABLE — views and other relations cannot be versioned.
501HSTORE_NOT_AVAILABLE — workflow was enabled on a database that has not been migrated (the hstore extension is outside the search path). Newly created databases are not affected.

Workflow roles​

A role is given to a sub-user on one table:

RoleEffect
authorEdits become drafts (status 1).
reviewerEdits and approvals count as reviewed (status 2).
publisherEdits and approvals are published (status 3).
noneNo part in the workflow: the sub-user sees published features only and cannot edit the table.

Set roles​

PATCH takes one subuser/role object or an array of them and merges with the existing roles: sub-users not named keep their role. The response is 303 See Other. An unknown role is 400 (INVALID_REQUEST) and an unknown table is 404 (TABLE_NOT_FOUND).

Request
PATCH https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/workflow-roles HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

[
{ "subuser": "izzy", "role": "author" },
{ "subuser": "duff", "role": "reviewer" },
{ "subuser": "slash", "role": "publisher" }
]

Get roles​

GET lists the sub-users that have been given a role on the table:

Request
GET https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/workflow-roles HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Response
[
{ "subuser": "izzy", "role": "author" },
{ "subuser": "duff", "role": "reviewer" },
{ "subuser": "slash", "role": "publisher" }
]

Workflow items​

A workflow item says where one feature stands in the workflow: its latest logged step. Items are not created through this API — they come from edits through the Feature API and WFS-T. The item id {gid} is the feature's primary key value.

List items​

GET without a gid returns the items the caller can still move forward, newest first: drafted features for a reviewer, drafted and reviewed ones for a publisher and the database owner. Add all=true to list every item of the table.

Request
GET https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/workflow-items HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Response
[
{
"schema": "rockhall",
"table": "inductees",
"gid": 42,
"version_gid": 17,
"status": 1,
"status_name": "drafted",
"operation": "insert",
"user": "izzy",
"author": "izzy",
"reviewer": null,
"publisher": null,
"created": "2026-11-27 10:15:00+00"
}
]
Every item of the table
GET https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/workflow-items?all=true HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123

With a gid the response is that item as an object, whatever its status; a comma-separated list returns an array. An unknown item is 404 (WORKFLOW_ITEM_NOT_FOUND).

One item
GET https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/workflow-items/42 HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123

Approve an item​

PATCH on an item is the approval step. It takes no body: the feature is signed with the caller's role and moved to that role's status. The response is 303 See Other.

Request
PATCH https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/workflow-items/42 HTTP/1.1
Authorization: Bearer abc123

{gid} can be a comma-separated list, which is all or nothing: if one feature cannot be approved, none is.

Approve several
PATCH https://api.gc2.io/api/v4/schemas/rockhall/tables/inductees/workflow-items/42,43 HTTP/1.1
Authorization: Bearer abc123
StatusMeaning
400INVALID_REQUEST — a gid that is not a feature id or a comma-separated list of ids.
403NO_WORKFLOW_ROLE — the caller has no role on the table. Also returned when reading items.
404TABLE_NOT_FOUND; FEATURE_NOT_FOUND on approval; WORKFLOW_ITEM_NOT_FOUND on read.
409WORKFLOW_STATUS_CONFLICT — the feature is already at or past the caller's status, for example a reviewer approving a reviewed or published feature.
409VERSION_ENDED — the id addresses an ended version; history cannot be changed.
409WORKFLOW_NOT_ENABLED — the table has no workflow.

Workflow log​

GET /api/v4/workflow-log returns the log across tables, newest first: every step logged by an edit or an approval. The database owner gets the whole log; a sub-user gets the entries of the tables they have a role on, and an empty array if they have no role anywhere.

ParameterDescription
schemaOnly entries of tables in this schema.
limitNumber of entries to return, 1–1000. Default 100.
offsetNumber of entries to skip. Default 0.

A malformed parameter is 400 (INVALID_REQUEST). No total count is returned, so page until fewer than limit entries come back.

Request
GET https://api.gc2.io/api/v4/workflow-log?schema=rockhall&limit=50&offset=0 HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
Response
[
{
"id": 312,
"schema": "rockhall",
"table": "inductees",
"gid": 42,
"version_gid": 17,
"status": 2,
"status_name": "reviewed",
"operation": "update",
"user": "duff",
"author": "izzy",
"reviewer": "duff",
"publisher": null,
"created": "2026-11-27 11:02:00+00",
"roles": {
"izzy": "author",
"duff": "reviewer",
"slash": "publisher"
}
},
{
"id": 311,
"schema": "rockhall",
"table": "inductees",
"gid": 42,
"version_gid": 17,
"status": 1,
"status_name": "drafted",
"operation": "insert",
"user": "izzy",
"author": "izzy",
"reviewer": null,
"publisher": null,
"created": "2026-11-27 10:15:00+00",
"roles": {
"izzy": "author",
"duff": "reviewer",
"slash": "publisher"
}
}
]

An entry has the fields of an item plus id and roles. status is the status that step gave the feature. To send the feature of an entry on, PATCH the workflow item addressed by the entry's schema, table and gid.

Using the SDK​

In the @mapcentia/gc2-sdk the two switches are set with patchTable on the admin client, and roles, items and the log are exposed through the Workflow class. Errors are thrown as CentiaApiError with .status and .code:

import { createCentiaAdminClient } from '@mapcentia/gc2-sdk'

const client = createCentiaAdminClient({ baseUrl, auth: { getAccessToken } })
const tables = client.provisioning.tables

// Workflow needs versioning; both can be switched on in one request
await tables.patchTable('rockhall', 'inductees', { versioning: true, workflow: true })

const table = await tables.getTable('rockhall', 'inductees')
// { name: 'inductees', ..., versioning: true, workflow: true }
import { createCentiaClient, Workflow } from '@mapcentia/gc2-sdk'

const workflow = new Workflow(createCentiaClient({ baseUrl, auth: { getAccessToken } }))

// Set roles (merges with the existing roles; database owner only)
await workflow.patchWorkflowRoles('rockhall', 'inductees', [
{ subuser: 'izzy', role: 'author' },
{ subuser: 'duff', role: 'reviewer' },
])
const roles = await workflow.getWorkflowRoles('rockhall', 'inductees')

// The items the caller can still move forward, newest first
const pending = await workflow.getWorkflowItem('rockhall', 'inductees')

// Every item, one item, or several
const all = await workflow.getWorkflowItem('rockhall', 'inductees', undefined, { all: true })
const one = await workflow.getWorkflowItem('rockhall', 'inductees', 42)
const some = await workflow.getWorkflowItem('rockhall', 'inductees', [42, 43])

// Approve: signs with the caller's role and sets that role's status. A list is all or nothing
await workflow.patchWorkflowItem('rockhall', 'inductees', [42, 43])

// The log across tables, newest first
const log = await workflow.getWorkflowLog({ schema: 'rockhall', limit: 50, offset: 0 })

// Send a feature on from a log entry
const entry = log[0]
await workflow.patchWorkflowItem(entry.schema, entry.table, entry.gid)

System columns​

Enabling versioning and workflow adds these columns to the table. They are removed again when the switch is turned off.

ColumnAdded byDescription
gc2_version_gidVersioningThe feature's version id, the same across all versions of the feature.
gc2_version_start_dateVersioningWhen the version started.
gc2_version_end_dateVersioningWhen the version ended. null on the current version; set on an ended version.
gc2_version_uuidVersioningA UUID for the version.
gc2_version_userVersioningThe user of the version.
gc2_statusWorkflowThe workflow status: 1 drafted, 2 reviewed, 3 published.
gc2_workflowWorkflowThe signatures of the feature: who signed as author, reviewer and publisher.

Item fields​

FieldDescription
schema, tableThe feature's table.
gidThe feature's primary key value; the id of the item in the path.
version_gidThe feature's version id (gc2_version_gid), the same across all versions of the feature.
status1 drafted, 2 reviewed, 3 published.
status_namedrafted, reviewed or published.
operationWhat the latest step was: insert, update or delete.
userWho made the latest step.
author, reviewer, publisherWho signed in each role, or null.
createdWhen the latest step was made.
idLog entries only. Id of the log entry.
rolesLog entries only. The workflow roles on the table when the step was made, as a sub-user to role map.