GovWrenv0.10.0
GitHub

API

Everything the web app does, it does through GovWren's JSON API. You can use the same API to connect another system. This guide covers the conventions and the main routes. The exact shape of every request and response is in the OpenAPI document.

The basics#

Base path/api/v1
FormatJSON in, JSON out
Sign-inAn API token in the Authorization header, or a session cookie set by POST /api/v1/session
ChangesNeed the X-CSRF-Token header
Success{"data": …, "meta": …}
ErrorsA problem document, application/problem+json
OpenAPIdocs/openapi.json in the repository, and /api/openapi.json on a running server

The API is not cached: every API response carries Cache-Control: no-store. The server does not serve interactive API documentation pages. Load the OpenAPI document into a viewer of your choice.

A script or another system should use an API token. A token acts as the account it belongs to, cut down to its scope, and needs no session and no CSRF token. Signing in with a password, as shown next, is what the web app does.

Sign in#

Send an email address and password. The answer sets the session cookie, govwren_session, and returns who you are, your roles, and a CSRF token.

curl -s -c cookies.txt \
  -H 'Content-Type: application/json' \
  -d '{"email": "you@example.org", "password": "your password"}' \
  http://127.0.0.1:8000/api/v1/session
{
  "data": {
    "account": {"id": 1, "name": "Your Name", "email": "you@example.org"},
    "roles": ["governance", "member"],
    "permissions": {"admin": false, "govern": true, "configure": true, "read_all": true,
                    "edit_all": true, "review": true, "steward": false},
    "steward_units": [],
    "member_units": [],
    "has_password": true,
    "csrf_token": "…"
  },
  "meta": {}
}

Send the CSRF token with every change#

Every request that is not a GET, HEAD, or OPTIONS must carry the session's CSRF token in the X-CSRF-Token header. Without it the answer is 403. Signing in and signing out are the exceptions.

curl -s -b cookies.txt \
  -H 'Content-Type: application/json' \
  -H 'X-CSRF-Token: THE_TOKEN' \
  -d '{"name": "Brightfen Labs"}' \
  http://127.0.0.1:8000/api/v1/vendors

GovWren also refuses changes that come from another site in a browser: a request whose Origin header does not match the host it was sent to, or that the browser marks as cross-site, answers 403. A command-line client sends no Origin header and is not affected.

Use a token from a script#

A token lets a script call the API without a password or a session.

  1. Sign in to GovWren, open Your account, and choose Manage your tokens.
  2. Choose Make a token. Say what it is for, choose what it may do, and when it stops working. Every token ends, a year at most from the day it is made; without a date, it ends after a year.
  3. Copy the token. It is shown once. GovWren keeps only its SHA-256 and cannot show it again.
Your API tokens: what each is for, what it may do, when it was last used, and whether it still worksYour API tokens: what each is for, what it may do, when it was last used, and whether it still works
API tokens

Send it with each request:

curl -s -H "Authorization: Bearer $GOVWREN_TOKEN" \
  http://127.0.0.1:8000/api/v1/checkpoint/UC-0042
ScopeThe token may
checkpointCall the checkpoint and nothing else
signalPush results onto records with POST /api/v1/signals, and nothing else. See Connecting other systems
readRead whatever its account can read
writeRead and change whatever its account can

What to know:

For a system that should not be tied to a person, make an account for it, give that account the least it needs, and make its token signed in as that account.

The checkpoint#

The checkpoint answers one question for another system: is this reference approved, for what data, and until when?

A purchasing form, an ethics application, or a data access request asks for a GovWren reference. The system that receives it asks the checkpoint before it proceeds.

curl -s -H "Authorization: Bearer $GOVWREN_TOKEN" \
  "http://127.0.0.1:8000/api/v1/checkpoint/UC-0042?data_class=protected"
{
  "data": {
    "ref": "UC-0042",
    "type": "use_case",
    "name": "Summarizing clinic letters",
    "checked_on": "2026-11-19",
    "status": "approved_with_conditions",
    "approved": true,
    "approved_until": "2027-05-01",
    "tier": 3,
    "data_class": "protected",
    "data_class_label": "Protected",
    "asked_data_class": "protected",
    "allowed": true
  },
  "meta": {}
}
FieldMeans
approvedFor a use case: an approval is in force today. For an AI system or model: it is approved in the catalog. For a vendor: it is active
approved_untilThe day a use case's approval ends
data_classThe most sensitive class of data the record covers
allowedPresent when you send data_class: the record is approved and covers data that sensitive
health_agreementFor an AI system: where it stands for health information. in_place or not_needed means health information may go to it; available, not_offered, ended, and unknown mean no agreement covers it

Proceed only when allowed is true, or approved is true if you did not ask about a data class. A reference that does not exist answers 404, and so does a restricted record or someone else's draft that the asking account may not see.

The checkpoint gives a record's standing and nothing about its content, so any signed-in person and any token may ask about any reference. A token with the checkpoint scope can do nothing else, which makes it safe to hand to another team.

Webhooks#

A webhook tells another system when something happens, so that it need not keep asking. An administrator sets them up under Admin → Webhooks.

Admin, Webhooks: each webhook with its address, what it is told, and its recent deliveriesAdmin, Webhooks: each webhook with its address, what it is told, and its recent deliveries
Webhooks and their deliveries
EventSent whendata holds
use_case.status_changedA use case is submitted, approved, declined, lapses, is suspended, or is retiredref, name (empty for a restricted use), from, to, tier, approved_until
decision.madeA review is decidedreview, ref, outcome, approved_until, by_rule
catalog.changedAn AI system's or model's catalog standing changesref, type, from, to
incident.reportedAn incident is reportedref, category

A message says what changed and never what a record holds. Call the API with the reference if you need more.

{"at": "2026-11-19T15:04:11.000000Z", "data": {"from": "in_review", "name": "Summarizing clinic letters",
 "ref": "UC-0042", "tier": 3, "to": "approved_with_conditions", "approved_until": "2027-05-01"},
 "event": 18211, "topic": "use_case.status_changed"}

Check the signature#

When you add a webhook, GovWren shows its signing secret once. Every delivery carries these headers:

HeaderHolds
X-GovWren-TopicThe event, such as decision.made
X-GovWren-DeliveryA number for this delivery. A delivery that is sent again keeps its number
X-GovWren-TimestampWhen it was sent, in seconds since 1970
X-GovWren-Signaturesha256= and the HMAC-SHA256 of the timestamp, a dot, and the body, keyed with the secret

Recompute the signature over the body exactly as received, compare in constant time, and refuse a timestamp more than a few minutes old:

import hashlib, hmac, time


def genuine(secret: str, headers: dict, body: bytes) -> bool:
    stamp = headers["X-GovWren-Timestamp"]
    expected = (
        "sha256="
        + hmac.new(secret.encode(), stamp.encode() + b"." + body, hashlib.sha256).hexdigest()
    )
    fresh = abs(time.time() - int(stamp)) < 300
    return fresh and hmac.compare_digest(expected, headers["X-GovWren-Signature"])

How delivery works#

Responses#

Every successful answer is an envelope with two keys:

{"data": {"ref": "VND-0041", "name": "Brightfen Labs", "status": "prospective", "version": 1},
 "meta": {}}

data is the thing you asked for: an object or a list. meta holds facts about the answer, such as paging. It is an empty object when there is nothing to say. The example is shortened; a real record has more fields.

A route that creates a record answers 201. Records are named by their permanent reference, such as UC-0142, SYS-0007, VND-0041, or RV-0087, not by a numeric id. People and units are named by numeric id.

Errors#

Every error is a problem document with the media type application/problem+json.

{
  "type": "about:blank",
  "title": "Forbidden",
  "status": 403,
  "detail": "The request is missing its CSRF token. Reload the page.",
  "instance": "/api/v1/vendors"
}

When particular fields are at fault, an errors list says which:

{
  "type": "about:blank",
  "status": 422,
  "detail": "The decision was not recorded.",
  "instance": "/api/v1/reviews/RV-0087/decision",
  "errors": [
    {"location": ["rationale"], "message": "Give the reason for the decision. It is shown to the requester."}
  ]
}

(The title is left out of this example.) detail and message are written to be shown to a person.

StatusMeaning
400The request could not be carried out
401Nobody is signed in, or the sign-in failed
403Your role does not allow this; or the CSRF token is missing; or the request came from another site
404There is no such record, or you may not see it
409A conflict: someone else changed the record, or the action no longer applies, such as deciding a review that is already decided
422The request is not valid. See errors
429Too many at once: failed sign-ins, or questions to Ask GovWren
500An unexpected error
503The database is unavailable

A record you are not allowed to see answers 404, the same as one that does not exist.

Lists: filter, sort, and page#

The three inventory lists, /use-cases, /systems, and /vendors, share one set of conventions.

ParameterMeaning
qWords to look for in the name, reference, and summary
sortA field to sort by. Put - in front for descending. The default is -updated_at
limitHow many to return, from 1 to 200. The default is 50
cursorWhere to continue from. Use the value a previous answer gave you
ListFiltersSort fields
/use-casesunit, status, tier, domain, stage, data_class, owner, mineupdated_at, name, ref, tier, status, stage
/systemsunit, status, kind, catalog_status, vendor, owner, mineupdated_at, name, ref, catalog_status, kind
/vendorsstatusupdated_at, name, ref, status

The answer's meta describes the page:

{"data": [ … ],
 "meta": {"total": 300, "offset": 0, "limit": 50, "next_cursor": "eyJvZmZzZXQiOjUwfQ", "prev_cursor": null}}

Pass next_cursor back as cursor to get the next page. It is null on the last page. Treat a cursor as opaque.

A list shows only what you may see. Someone who sees only a summary of a use case gets fewer fields for it, and a sight of summary.

Other lists are short and are returned whole: /catalog (takes q), /accounts (takes q and status), /units, and /reviews (takes scope=open or scope=all).

Change a record safely#

To change a use case, AI system, or vendor, send a PATCH with only the fields that change and the version you were looking at.

curl -s -b cookies.txt -X PATCH \
  -H 'Content-Type: application/json' \
  -H 'X-CSRF-Token: THE_TOKEN' \
  -d '{"version": 1, "website": "https://brightfen.example"}' \
  http://127.0.0.1:8000/api/v1/vendors/VND-0041

If someone else has saved the record since, the answer is 409 and nothing is changed. Fetch the record again, and repeat your change with the new version. Every change is written to the history against the account that made it.

Routes#

"Who" is the least a caller needs. Many routes check again against the record itself: its unit, its owners, and its visibility. The server checks every route against one policy table, and a route with no entry in it is refused.

System and session#

MethodPathWhoWhat it does
GET/health/liveAnyoneIs the server process running?
GET/health/readyAnyoneCan the server do its work? 503 if not
GET/metaAnyoneThe product's name, version, and branding
GET/sessionAnyoneWho is signed in, or 401
POST/sessionAnyoneSign in
DELETE/sessionAnyoneSign out
POST/session/demoAnyoneSign in as a sample person. Answers 404 unless this is a demo
POST/session/passwordSigned inChange your own password

People and units#

MethodPathWhoWhat it does
GET/accountsSigned inFind people. Members get a short card for each: name, address, title, and status
POST/accountsAdminAdd a person
GET/accounts/{account_id}Signed inOne person
PATCH/accounts/{account_id}Signed inChange your own details; an admin may change anyone's
PUT/accounts/{account_id}/rolesAdminSet a person's roles
PUT/accounts/{account_id}/unitsAdminSet the units a person works in
POST/accounts/{account_id}/passwordAdminGive a person a new password
GET/rolesSigned inThe roles and what each allows
GET/unitsSigned inThe units, as a list and as a tree
POST/unitsAdminAdd a unit
GET/units/{unit_id}Signed inOne unit, with the units above it
PATCH/units/{unit_id}AdminRename, move, or close a unit
POST/imports/unitsAdminImport units from CSV
POST/imports/peopleAdminImport people from CSV

The import routes take the CSV file itself as the request body, not JSON. They run dry by default: add ?dry_run=false to apply. The answer reports rows created, updated, and unchanged, and every problem by row.

Inventory#

MethodPathWhoWhat it does
GET/vocabulariesSigned inThe lists of values records choose from
GET/use-cases, /systems, /vendorsSigned inFind records
POST/use-cases, /systems, /vendorsSigned inAdd a record. A use case starts as a draft
GET/use-cases/{ref}, /systems/{ref}, /vendors/{ref}Signed inOne record
PATCH/use-cases/{ref}, /systems/{ref}, /vendors/{ref}Signed inChange a record. Catalog and vendor standing need governance or an admin
PUT/use-cases/{ref}/owners, /systems/{ref}/ownersSigned inSet a record's owners
PUT/use-cases/{ref}/systemsSigned inSet the AI systems a use case uses
GET/use-cases/{ref}/history, /systems/{ref}/history, /vendors/{ref}/historySigned inEverything that has happened to a record
GET/record-typesSigned inThe fields of models, datasets, and agent profiles, and the links each kind of record may make
GET, POST/models, /datasetsSigned inFind or add models and datasets. Their fields are those /record-types lists
GET, PATCH/models/{ref}, /datasets/{ref}Signed inOne record, or a change to it
PUT/models/{ref}/owners, /datasets/{ref}/ownersSigned inSet a record's owners
GET/models/{ref}/history, /datasets/{ref}/historySigned inEverything that has happened to a record
POST/linksSigned inLink one record to another: {"source": "MDL-0048", "relation": "trained_on", "target": "DS-0050"}
DELETE/links/{link_id}Signed inRemove a link
GET/records/{ref}/graphSigned inWhat a record relies on and what relies on it, out to depth steps (1 to 6, default 3)
PUT/records/{ref}/referencesSigned inSet a record's pointers to other systems
POST/vendors/{ref}/agreementsSigned inAdd an agreement to a vendor
PATCH, DELETE/agreements/{agreement_id}Signed inChange or remove an agreement
GET/admin/inventoryGovernance or adminHow much of the inventory everyone can see
PUT/admin/inventoryGovernance or adminChange it. Send {"visibility": "open"}, "summary", or "unit"

Email#

MethodPathWhoWhat it does
GET/mailAdminHow email is set up, and how many messages are waiting, sent, and given up on
POST/mail/testAdminSend yourself a test message now. 502 if the mail server will not take it

A person's own choice is email_notices on their account: immediate, digest, or none.

The program#

MethodPathWhoWhat it does
GET/programGovernance or adminThe form, scoring model, routing rules, and vocabularies in force, with their versions
POST/program/checkGovernance or adminCheck a proposed program and preview what it would have done to past requests. Changes nothing
PUT/programGovernance or adminPublish. Send only the parts that change: forms, scoring_model, review, vocabularies
GET/catalog/requestsSigned inTools people have asked to have evaluated: all for those who read everything, your own otherwise
POST/catalog/requestsSigned inAsk for a tool to be evaluated: {"name": "…", "reason": "…"}

Import and export#

MethodPathWhoWhat it does
POST/imports/records/{kind}GovernanceImport systems, models, datasets, or vendors from CSV sent as the body. dry_run defaults to true. mapping is JSON, {column: field}; without it GovWren guesses and returns its guess with the fields on offer
GET/exports/{kind}Signed inDownload use-cases, systems, models, datasets, or vendors as format=csv or format=json, with the same filters as the list

Finding and tidying#

MethodPathWhoWhat it does
GET/search?q=…Signed inRecords of every kind that match, as far as you may see each
GET/viewsSigned inYour saved views; list narrows to one list
POST/viewsSigned inSave a view: {"list": "model", "name": "…", "params": {…}}. A name already used is replaced
DELETE/views/{view_id}Signed inRemove one of your views
GET/duplicates?type=…Governance, auditors, adminsLikely duplicates among systems, models, datasets, or vendors
POST/records/{ref}/mergeGovernanceFold this record into another of the same kind: {"into": "SYS-0033"}

Every record's detail also carries completeness (a score and what is missing) and merged_into.

Evidence#

MethodPathWhoWhat it does
POST/evidence/files?name=…Signed inSend a file as the request body. The answer carries a file_id
GET/evidenceSigned inFind evidence: q, kind, and state (current, expiring, expired, withdrawn). All of it for those who read everything; otherwise what you look after
POST/evidenceSigned inAdd evidence. supports lists what it is attached to: record references, or condition:7, review_task:3, agreement:5
GET/evidence/{ref}Signed inOne piece of evidence, if you may see something it supports
PATCH/evidence/{ref}Its owner, governance, or an adminChange it, or withdraw it with {"status": "withdrawn"}
GET/evidence/{ref}/fileSigned inDownload the file

Catalog and requests#

MethodPathWhoWhat it does
GET/catalogSigned inThe AI systems the organization has evaluated
POST/catalog/{ref}/registerSigned inRegister a use. Approved at once if it fits; otherwise a request is begun
GET/intakeSigned inThe request form, scoring model, and routing rules in force
POST/intakeSigned inBegin a request. Needs what it is for and which unit
GET/use-cases/{ref}/intakeSigned inA request's form and answers
PUT/use-cases/{ref}/intakeSigned inSave a draft's answers. Nothing needs to be complete
POST/use-cases/{ref}/submitSigned inSubmit a request, and work out its tier
GET/use-cases/{ref}/tierSigned inWhy a use case has the tier it has
POST/use-cases/{ref}/tierReviewer or governanceChange a tier, with a reason

POST /catalog/{ref}/register answers {"registered": true, "ref": …} when the use was approved, and {"registered": false, "reason": …, "ref": …} when a request was begun instead.

Reviews, decisions, and conditions#

MethodPathWhoWhat it does
GET/me/workSigned inWhat is waiting on you
GET/notificationsSigned inYour notices
POST/notifications/readSigned inMark notices as read
GET/reviewsSigned inReviews you have a part in
GET/reviews/{ref}Signed inOne review: the decision packet
GET/use-cases/{ref}/reviewSigned inThe latest review of a use case
POST/reviews/{ref}/triageGovernanceConfirm or adjust the reviews required, and start them
POST/reviews/{ref}/tasks/{task_id}/claimReviewer or governanceTake a review task
POST/reviews/{ref}/tasks/{task_id}/assignGovernanceGive a review task to someone
POST/reviews/{ref}/tasks/{task_id}/completeReviewer or governanceRecord a finding: no_concerns, conditions, or objection
POST/reviews/{ref}/commentsSigned inAdd to the discussion. visibility is internal or requester
POST/reviews/{ref}/decisionGovernanceDecide: approved, declined, or returned, with a rationale
POST/reviews/{ref}/withdrawSigned inTake a request back. For the requester or governance
POST/conditions/{condition_id}/closeSigned inMark a condition met, or waive it, with a note

What a review returns depends on who asks. The requester never receives findings, reviewers' notes, or internal comments.

Dashboard and branding#

MethodPathWhoWhat it does
GET/dashboardGovernance, auditor, or adminWhere the program stands
GET/admin/brandingAdminThe branding, for editing
PUT/admin/brandingAdminChange the product name, palette, and accent
POST/admin/branding/checkAdminHow an accent color would read, before saving it
POST/admin/branding/images/{kind}AdminUpload a logo or tab icon. The image is the request body
DELETE/admin/branding/images/{kind}AdminRemove a logo or tab icon

kind is logo-light, logo-dark, or favicon.

Ask GovWren#

MethodPathWhoWhat it does
POST/askSigned in, if an administrator has turned it on for themAnswer a question from what the person may see, citing its sources. 404 while it is off
GET/admin/assistantAdminThe assistant as configured, and whether Ask GovWren is on and for whom
PUT/admin/assistantAdminTurn Ask GovWren on or off, or change who may ask

The answer's answer is plain text, with each source cited as [1], [2]; sources lists them by n, with href, the path of each in the web app, and cited. left_out counts records that bore on the question but hold data above what the assistant may be shown. A person may ask 30 questions an hour, and have two waiting at once; more answer 429.

A worked example#

This signs in, reads the catalog, and lists approved Critical-tier use cases. It uses jq to read the JSON.

BASE=http://127.0.0.1:8000/api/v1

# Sign in, keep the cookie, and take the CSRF token from the answer.
TOKEN=$(curl -s -c cookies.txt -H 'Content-Type: application/json' \
  -d '{"email": "you@example.org", "password": "your password"}' \
  "$BASE/session" | jq -r '.data.csrf_token')

# Read: which tools are approved, and for what data?
curl -s -b cookies.txt "$BASE/catalog" \
  | jq '.data[] | select(.usable) | {ref, name, edition, permitted_data_class}'

# Read a list with filters, sorting, and paging.
curl -s -b cookies.txt "$BASE/use-cases?status=live&tier=4&sort=name&limit=20" \
  | jq '{total: .meta.total, names: [.data[].name]}'

# Change: add a vendor. Changes need the token.
curl -s -b cookies.txt -H 'Content-Type: application/json' -H "X-CSRF-Token: $TOKEN" \
  -d '{"name": "Brightfen Labs", "website": "https://brightfen.example"}' \
  "$BASE/vendors" | jq '.data.ref'

# Sign out.
curl -s -b cookies.txt -X DELETE "$BASE/session"

To try this against the demo organization, use port 8010 and sign in without a password, from the machine the demo runs on:

curl -s -c cookies.txt -H 'Content-Type: application/json' \
  -d '{"email": "SAMPLE_PERSON_EMAIL"}' \
  http://127.0.0.1:8010/api/v1/session/demo

The sample people and their addresses are listed under demo.accounts in GET /api/v1/meta.

Stability#

Everything under /api/v1 is recorded in docs/api-contract.json: every route and the query parameters it accepts. A test in the repository fails if a route or a parameter in that record is removed or renamed.

Describes GovWren 0.10.0. Apache License 2.0. Screenshots show an invented organization; every person and record in them is fictional.