Governance templates API
A governance template is a per-tenant, versioned rule template: a stable template_key + template_version, a display name, an opaque obligation_refs payload (which obligations it references), and a target_controls payload that maps each obligation onto a governable leaf — a gateway control, an organisation setting, or a status that is only checked (see GET /governance/leaves). This API lets an authorized admin catalogue templates and preview / apply a template's controls against a gateway (and the gateway's organisation).
The apply engine follows four rules:
- It always respects the tenant residency floor: a template may tighten a residency/PII control but can never downgrade it below the tenant's armed floor. A control the floor refuses is reported as
blocked_by_floorand is never persisted. - It only tightens: a leaf marked
tightenaccepts only its tightening value (a switch onlytrue; a retention is a minimum, "at least N days"), and apply never lowers a stored value — a longer request-log retention is never shortened. - It never escalates: what an apply may write is decided by the caller's own permission, server-side. A leaf the caller may not set is reported (
needs_tenant_admin/needs_platform_admin), never written, and does not fail the apply. - Check leaves never write: they only report whether a requirement is met.
Base URL: https://<your-gateway-host>/admin/v1
Required role for every endpoint: admin, tenant_admin, or ki_manager. A caller with any lower role (or none) is rejected 403/401. The client is never the authorization boundary — every call is re-gated and tenant-scoped server-side.
Tenant scope
Tenant scope is decided server-side; the client value never widens it.
| Caller | Scope |
|---|---|
admin |
Must target one tenant with ?tenant_id=<id> on the per-tenant routes. |
tenant_admin / ki_manager |
Always their own tenant. A ?tenant_id naming another tenant is ignored (pinned to the caller's own). |
The template routes are inherently per-tenant: an admin who omits ?tenant_id is rejected 400 { "error": "tenant_id required", "code": "tenant_id_required" }. An admin ?tenant_id that is not one canonical tenant UUID (8-4-4-4-12 hex groups, either case) is 400 { "error": "tenant_id must be a tenant id", "code": "bad_param" } — it never reaches the database. A non-admin whose account carries no tenant is refused 403.
The diff / apply routes take a gateway_id in the body instead of ?tenant_id: the caller must have access to that gateway (its tenant must match the caller's, unless admin), and the template is looked up scoped to the gateway's tenant — so a cross-tenant template reads as 404.
Myra templates
Besides the tenant's own templates, every tenant has the Myra templates — global, read-only templates that ship with the product: myra/eu-ai-act-deployer (EU AI Act: deployer obligations) and myra/gdpr-ai-personal-data (GDPR: personal data in AI use).
- Id —
myra:<template_key>@<template_version>, for examplemyra:myra/eu-ai-act-deployer@2. It never collides with a tenant template's UUID. The key carries a/: URL-encode the id in a path (myra%3Amyra%2Feu-ai-act-deployer%402) or send it as is — both reach the same route. - Read-only —
PATCHandDELETEreturn409 template_read_only; nothing changes. To change one, copy it (POST …/{id}/copy). - Preview & apply —
diff/applywork exactly as for a tenant template: the same validation, residency floor, tenant scope, deny-all guard and trial lock. - Versions — the current version of both Myra templates is 2 (
myra:myra/eu-ai-act-deployer@2,myra:myra/gdpr-ai-personal-data@2). The list carries the current version of each key;GET /governance/templates/{id},diffandapplyalso resolve an older version the product still ships (…@1stays resolvable by id). A template copied from version 1 is an independent organisation template and is not changed by version 2. An unknown key or version, or a malformedmyra:id, is404 template_not_found. - The
myra/key namespace is reserved — a tenant template cannot be created with atemplate_keystarting withmyra/in any letter case (400 template_key_reserved). copied_fromis server-recorded — only the copy route writes it; a create /PATCHbody whoseobligation_refsobject carriescopied_fromis400 invalid_obligation_refs.
Every template row (Myra or tenant) carries:
| Field | Myra template | Tenant template |
|---|---|---|
source |
"myra" |
"organisation" |
read_only |
true |
true only when authoritative (PATCH/DELETE → 409) |
is_authoritative |
0 (no DPO sign-off) |
0 or 1 |
copied_from |
null |
the id of the template it was copied from (myra:… or a tenant id), else null |
tenant_id |
null |
the owning tenant |
name_i18n, summary, disclaimer |
{ "en": "…", "de": "…" } |
absent |
published |
the publication date, YYYY-MM-DD |
absent |
changes |
version 2 and above: what changed since the previous version — a non-empty array of { "en": "…", "de": "…" }; absent on version 1 |
absent |
A Myra template's obligation_refs is { "controls": [ … ] } — every obligation of the template, including the ones no governable leaf covers:
{ "id": "art5-1e-storage-limitation",
"obligation": { "ref": "GDPR Art. 5(1)(e)", "text": { "en": "Storage limitation.", "de": "Speicherbegrenzung." } },
"kind": "manual",
"setting": { "label": { "en": "Conversation retention", "de": "…" }, "api_field": "conversation_retention_days",
"where": { "en": "Organisation settings › Data & retention (set by the platform operator)", "de": "…" },
"path": "/org/:orgId/settings?view=data" },
"recommended": { "en": "A defined period, e.g. 365 days; …", "de": "…" },
"why": { "en": "Conversations are deleted after a fixed period instead of being kept forever.", "de": "…" },
"covered_by": "manual" }
kind is leaf (a governable leaf with its leaf + value, also present in target_controls; an integer leaf carries a number of days, for example 183 = at least 183 days) or manual (a checklist item apply never changes). covered_by is derived from the leaf catalogue:
covered_by |
Meaning | Shown as |
|---|---|---|
template |
A gateway leaf apply sets (writer governance). |
Set by template · gateway |
tenant_setting |
An organisation setting apply sets for a caller holding TENANT_SETTINGS_MANAGE (writer tenant_settings). |
Set by template · organisation |
platform_admin |
An organisation setting only a platform admin's apply sets (writer platform_admin). |
Set by template · platform admin |
organisation |
A tenant-scoped leaf apply only reports as tenant_scoped (pii_masking_enforced). |
Set on organisation |
check |
A check leaf: the diff reports its status, apply never writes it. | Check only |
manual |
A checklist item no governable leaf covers. | Check manually |
Obligations sharing a leaf are merged into one target_controls entry (one control per leaf), their obligation texts joined. obligation_refs stays opaque to the engine: it is never applied. A client must parse it defensively — a tenant template's obligation_refs may hold any JSON array or object.
Authoritative flag
is_authoritative is not client-settable. Every template created through this API is stored non-authoritative (0); authoritative (DPO-signed) content is provisioned out of band. An existing authoritative template is read-only to this API: PATCH and DELETE against it return 409. The management UI marks every non-authoritative template with a watermark so it is never presented as a compliance guarantee.
GET /governance/leaves
The catalogue of governable leaves a template's target_controls may reference. Requires the governance permission (GOVERNANCE_MANAGE); it carries no tenant data. Returns a JSON array (sorted by leaf) of:
| Field | Values | Meaning |
|---|---|---|
leaf |
string | The leaf name used in target_controls[].leaf. |
kind |
boolean | integer |
The value type. An integer leaf is a whole number of days within min…max. |
mode |
set | check |
set: apply may write it. check: the diff reports its status; apply never writes it. |
scope |
gateway | tenant | platform |
Where the value lives: the diffed gateway's configuration, the organisation (tenant) settings, or the deployment. |
writer |
governance | tenant_settings | platform_admin | none |
Who may write it through apply: a template manager (GOVERNANCE_MANAGE), a caller holding TENANT_SETTINGS_MANAGE, a platform admin only, or nobody (check leaves; PII masking, which is set on the tenant). |
tighten |
boolean | true: a template may only tighten it — a boolean leaf accepts only true, an integer leaf is a minimum ("at least N days"). false: true and false are both accepted; the residency floor guards a downgrade. |
min, max |
integer | Integer leaves only (omitted otherwise): the accepted bounds. |
The eleven leaves:
leaf |
kind |
mode |
scope |
writer |
tighten |
Bounds | What it is |
|---|---|---|---|---|---|---|---|
agent_review_required |
boolean | set | tenant | tenant_settings | true | The organisation's agent-review switch; affects new agents only. | |
audit_chain_enabled |
boolean | check | platform | none | true | Tamper-evident sealing of the audit log is enabled in this environment. | |
audit_log_retention_days |
integer | check | platform | none | true | 30–3650 | The deployment's audit-log retention is at least this many days. |
compliance_report_enabled |
boolean | set | tenant | platform_admin | true | The monthly compliance report snapshots; platform-admin only. | |
config_approval_required |
boolean | set | tenant | tenant_settings | true | The organisation's four-eyes switch (Config approvals). | |
eu_region_routing |
boolean | set | gateway | governance | false | EU region routing on the gateway (residency floor applies). | |
pii_masking_enforced |
boolean | set | tenant | none | false | PII masking; derived from the tenant, reported as tenant_scoped, never written by apply. |
|
provider_allowlist_enforced |
boolean | set | gateway | governance | false | Provider allowlist enforcement on the gateway (residency floor, deny-all guard, trial lock apply). | |
request_log_retention_days |
integer | set | tenant | tenant_settings | true | 30–3650 | The organisation's request-log retention, at least this many days. |
siem_configured |
boolean | check | gateway | none | true | A SIEM target is configured for the gateway (its own, else the organisation's). | |
transfer_safeguards_required |
boolean | set | gateway | governance | true | The GDPR Art. 44–46 transfer safeguard: a provider outside the EU only while the gateway masks PII in requests. When the gateway masks no PII, its diff row carries the note pii_masking_off (non-EU providers are refused until masking is on). |
[
{ "leaf": "agent_review_required", "kind": "boolean", "mode": "set", "scope": "tenant",
"writer": "tenant_settings", "tighten": true },
{ "leaf": "request_log_retention_days", "kind": "integer", "mode": "set", "scope": "tenant",
"writer": "tenant_settings", "tighten": true, "min": 30, "max": 3650 }
]
This is the single source of truth for the leaf catalogue; clients must not hardcode it. The four organisation set leaves are written through the same writer as PATCH /admin/v1/tenants/{id} (same validation, platform-admin wall, retention maximum, four-eyes gate and audit rows — see Tenants & gateways).
GET /governance/templates
List the templates the tenant can use: the Myra templates first (current version of each), then the tenant's live templates by name. Returns a JSON array (an empty tenant still lists the Myra templates); each tenant row's obligation_refs and target_controls are decoded from storage (a null column yields null / [] respectively — never an object that would break a client .map).
GET /governance/templates/{id}
One template: a Myra id (myra:<key>@<version>) or the tenant's own template (tenant-scoped — another tenant's template, an unknown, soft-deleted or malformed id is 404 template_not_found). Returns the row in the shape of the list.
POST /governance/templates/{id}/copy
Copy a Myra or a tenant template into the caller's tenant (server-derived, never from the body) as an ordinary, editable template: template_version 1, is_authoritative 0, created_by = the caller, the source's target_controls, and obligation_refs = { "copied_from": "<source id>", "controls": [ … ] } (the source's checklist; a tenant source whose obligation_refs has another shape keeps it under source_refs). The copy is independent: editing it never changes the original. Optional body (JSON object; an absent body copies with the defaults):
| Field | Accepted | Default | Rejected → 400 |
|---|---|---|---|
name |
string, 1–255 chars | "<source name> (copy)" (cut to 255) |
null, non-string or "" (invalid_name) / > 255 (name_too_long) |
template_key |
string, 1–190 chars, not in the myra/ namespace (any letter case) |
the source key without myra/ + -copy; on a clash -copy-2, -copy-3 … up to -copy-50 |
null, non-string or "" (invalid_template_key) / > 190 (template_key_too_long) / myra/…, MYRA/… (template_key_reserved) |
An absent field takes the default; a present null is invalid (400), never the default. Defaults are cut on a character boundary to fit the column. A body that is not a JSON object is 400 malformed_body. When all 50 default keys are taken, the copy answers 409 duplicate_template — pass an explicit template_key. The copy is recorded in the audit log (governance.template.copied, with the source id). An explicit template_key that already exists (version 1) is 409 duplicate_template — it is never renamed silently. An unknown source is 404 template_not_found; a stored source template with an invalid target_controls is 422 invalid_stored_template (nothing written). On success returns 201 with the new row (source: "organisation", copied_from set).
POST /governance/templates
Create a template. Body (JSON object):
| Field | Accepted | Rejected → 400 |
|---|---|---|
template_key |
string, 1–190 chars (required) | missing / empty (template_key_required) / null or non-string (invalid_template_key) / > 190 (template_key_too_long) |
name |
string, 1–255 chars (required) | missing / empty (name_required) / null or non-string (invalid_name) / > 255 (name_too_long) |
template_version |
integer 1 … 2147483647 (default 1) |
present-but-non-numeric / < 1 / > 2147483647 (invalid_template_version) |
target_controls |
JSON array of { "leaf": <governable leaf>, "value": <by kind>, "obligation"?: <string> }; absent → stored []. value of a boolean leaf: a JSON boolean, and only true on a tighten leaf. value of an integer leaf: a whole JSON number within the leaf's min…max (a minimum, "at least N days"). A check leaf carries the requirement it checks as its value. Extra keys in an element are ignored. |
unknown leaf / a boolean leaf with a non-boolean value / false on a tighten leaf (a loosening value) / an integer leaf with a fraction, a string ("183"), null, a boolean or a value outside its bounds / a non-string obligation / duplicate leaf / an element that is not an object / not an array (invalid_target_controls) |
obligation_refs |
JSON array or object (opaque; never interpreted) | a scalar/string (invalid_obligation_refs) |
is_authoritative |
ignored — always stored 0 |
— |
A duplicate (tenant, template_key, template_version) returns 409 { "error": "a template with this key and version already exists", "code": "duplicate_template" }. On success returns 201 with the created row.
PATCH /governance/templates/{id}
Update a live template's mutable fields (name, obligation_refs, target_controls), tenant-scoped. Only fields present in the body are changed — an absent field is preserved (a partial PATCH never clears stored controls; a copy's checklist in obligation_refs stays when only name / target_controls are sent). A Myra id → 409 template_read_only. Present fields use the same validation as create (on PATCH an empty or non-string name is invalid_name, since the field is present). is_authoritative is ignored. An unknown / cross-tenant / soft-deleted id → 404; an authoritative template → 409 (read-only).
DELETE /governance/templates/{id}
Soft-delete a live template, tenant-scoped. Unknown / cross-tenant / already-deleted → 404; an authoritative template or a Myra id → 409 (read-only). On success returns 200 { "deleted": true }.
POST /governance/templates/{id}/diff
Preview what applying the template would change on a gateway for the calling user. No write. Body: { "gateway_id": "<id>" } (required string — absent or null is 400 gateway_id_required; a non-string, "", over-long (> 36 bytes), invalid-UTF-8 or control-character value is 400 gateway_id_invalid, before any access check). The caller must have access to the gateway (403/404/503 otherwise). The statuses depend on the caller's permission (Permission rule), so two users can see different previews of the same template. Returns:
{
"gateway_id": "…",
"tenant_id": "…",
"changes": [
{ "leaf": "eu_region_routing", "obligation": "GDPR Art. 44–46: …", "scope": "gateway",
"kind": "boolean", "mode": "set",
"current": true, "requested": false, "resulting": true, "status": "blocked_by_floor" },
{ "leaf": "request_log_retention_days", "obligation": "EU AI Act Art. 26(6): …", "scope": "tenant",
"kind": "integer", "mode": "set",
"current": 90, "requested": 183, "resulting": 183, "status": "apply",
"max": 365, "notes": ["within_max", "never_shortens"] },
{ "leaf": "compliance_report_enabled", "scope": "tenant", "kind": "boolean", "mode": "set",
"current": false, "requested": true, "resulting": false,
"status": "needs_platform_admin", "reason": "platform_admin_only" },
{ "leaf": "audit_chain_enabled", "scope": "platform", "kind": "boolean", "mode": "check",
"current": null, "requested": true, "resulting": null, "status": "check_unknown" }
],
"warnings": []
}
changes[] fields:
| Field | Type | Meaning |
|---|---|---|
leaf |
string | The governable leaf. |
obligation |
string | absent | The governance obligation the leaf maps to. |
scope, kind, mode |
string | The leaf's catalogue entry (GET /governance/leaves). |
current |
boolean | integer | null |
The value today. null = keep forever (request-log retention with no period) or unknown (a check that could not be read). |
requested |
boolean | integer | The template's value (for an integer leaf: the minimum). |
resulting |
boolean | integer | null |
The value after apply (equal to current when nothing is written). Always null on a check leaf. |
status |
string | See the table below. |
reason |
string | absent | On a needs_* row: tenant_settings_required (the caller lacks TENANT_SETTINGS_MANAGE), platform_admin_only (compliance_report_enabled) or retention_above_max (the value is above the organisation's request-log retention maximum). |
max |
integer | absent | request_log_retention_days rows only: the organisation's request-log retention maximum in days, when one is set. |
notes |
string[] | absent | Hint codes for the row (below). |
approval_id |
string | absent | held_for_approval only: the pending configuration approval. |
Per-control status:
| Status | Meaning |
|---|---|
apply |
A set leaf apply will write — the value changes (tightening) and the caller may set it. |
unchanged |
Already satisfied / a no-op. For a retention: the stored period is already at least the minimum, or logs are kept forever. |
blocked_by_floor |
The tenant residency floor refuses this downgrade — not persisted. |
tenant_scoped |
A PII leaf a gateway apply cannot change (set it on the tenant) — not persisted. |
needs_tenant_admin |
An organisation setting the caller may not set (reason: tenant_settings_required) — not written. |
needs_platform_admin |
Platform-admin only (reason: platform_admin_only), or a retention above the organisation's maximum (reason: retention_above_max, with max; for every role, a platform admin included, until the maximum is raised) — not written. |
check_ok |
A check leaf whose requirement is met. |
check_missing |
A check leaf whose requirement is not met. Apply never changes it; it is set where the setting lives. |
check_unknown |
A check leaf whose status could not be read right now (current: null). Never shown as OK. |
held_for_approval |
apply response only: the organisation's four-eyes gate captured the change; nothing is written until a second admin approves (approval_id). |
notes codes:
| Note | On | Meaning |
|---|---|---|
four_eyes |
an apply row (diff) |
Four-eyes is on for the organisation: apply will hold this change for approval. A hint from the stored switch: a caller whose role cannot be captured by the gate (no capture capability) is not held. |
new_agents_only |
agent_review_required |
Affects new agents only; existing agents stay as they are. |
keep_forever |
request_log_retention_days with current: null |
Logs are kept forever today: the minimum counts as satisfied (unchanged), with a warning. |
within_max |
an apply row of request_log_retention_days with max |
The value is within the organisation's maximum. |
never_shortens |
an apply row of request_log_retention_days |
Apply only ever lengthens retention. |
pii_masking_off |
transfer_safeguards_required |
The gateway masks no personal data in requests: once the safeguard is on, providers outside the EU are refused until a PII masker is enabled; EU providers keep working. |
warnings carries a human-readable note when the apply would introduce a deny-all condition (enforcing a provider allowlist with no usable providers), and when request_log_retention_days is keep forever on the organisation (the GDPR storage limitation principle, Art. 5(1)(e), expects a defined retention period).
Check leaves report presence and status only:
audit_chain_enabled—check_okwhen tamper-evident sealing is enabled,check_missingwhen it is not,check_unknownwhen its key cannot be read right now.audit_log_retention_days—currentis the deployment's audit-log retention in days (Audit-log retention);check_okwhen it is at least the requested days. The check is conservative: it compares the configured horizon, so it can reportcheck_missingeven where pruning does not run (audit entries are only pruned once sealed). It never reportscheck_unknown.siem_configured—check_okwhen the gateway's effective SIEM target (the gateway's ownconfig.siem, else the organisation's SIEM) has a known type and a destination. The response carries onlytrue/false— never the configuration, host or credentials.
POST /governance/templates/{id}/apply
Persist the template's controls, floor-safe and never escalating. Same body + gateway-access rules as diff. Only apply-status controls are written; every other status is skipped (needs_* rows are reported, not written, and do not fail the apply). Returns the same shape as diff (the applied result), where a change the four-eyes gate captured reads held_for_approval with its approval_id.
Permission rule
- The permission is derived server-side from the authenticated caller — never from the request. A caller holding
TENANT_SETTINGS_MANAGE(resolved through the effective-permission resolver, so a custom role granting it counts) may set thetenant_settingsleaves. If the custom-role permissions cannot be read,diffandapplyanswer503instead of reporting every organisation leaf asneeds_tenant_admin. - A platform admin (calling with
?tenant_id) may apply every set leaf,compliance_report_enabledincluded.compliance_report_enabledis platform-admin only for every other caller. - A request-log retention above the organisation's maximum is
needs_platform_admin(retention_above_max) for every role — the maximum is raised first (see Request-log retention). The maximum is re-checked inside the write: if it was lowered after the preview, the row is reportedneeds_platform_adminand the rest still applies. - Retention is never shortened: a stored period longer than the minimum, or keep forever (
null), counts as satisfied.
Four-eyes approval
Organisation settings go through the same four-eyes gate as PATCH /admin/v1/tenants/{id} (Config approvals). While four-eyes (config_approval_required) is on, the gate holds:
- a
request_log_retention_dayschange by a caller who is not a platform admin.
Switching four-eyes on is immediate while it is off; agent_review_required and compliance_report_enabled are never held. A held change is reported held_for_approval: a pending configuration approval is created whose summary names the template, its id and version (for example Governance template EU AI Act: deployer obligations (myra:myra/eu-ai-act-deployer@2, v2): Request-log retention: 90 days -> at least 183 days), and nothing is written until a second admin approves it. The held retention stays a minimum: on approval it is decided against the then-current value — a retention lengthened (or set to keep forever) in the meantime is kept, and a maximum lowered below the minimum fails the approval (retention_above_max).
Order and atomicity
- The full diff for the caller is computed first (nothing written).
- The apply refuses to introduce a deny-all condition —
409 { "error": "applying this template would deny ALL inference on the gateway (enable a usable provider allowlist first)", "code": "template_denies_all" }— and a trial-locked gateway control (403 trial_gateway_locked), before anything is written (organisation or gateway). - The organisation settings and their own audit rows commit in one transaction (after the four-eyes gate). A failure rolls it back: nothing written,
503— unless the four-eyes gate had already captured a change in the same apply: then the answer is500(re-run the preview; the pending approval exists and is listed in thegovernance.template_appliedevent withtenant_write_failed: true), so a retry never captures it twice. The request-log retention is decided "at least" on the current row, read with a row lock inside that transaction: a retention made longer (or keep forever) after the preview is never shortened (that row is then reportedunchangedwith the current value), and a maximum lowered after the preview reportsneeds_platform_admin. A tenant deleted meanwhile answers404 tenant_not_found. - Then the gateway leaves are written onto the gateway's stored configuration.
- If that gateway write fails after the organisation transaction committed, the answer is
500: re-run the preview — the organisation settings may already be applied.
Organisation settings are organisation-wide: applying the same template to a second gateway of the organisation shows them as unchanged. Re-applying a template that changes nothing writes nothing and records nothing.
Audit
Every apply that wrote anything records one governance.template_applied event (entity_type: governance_template, entity_id: the template id) with the actor, the tenant, the gateway, after.template_id and after.template_version, the before/after value of every written leaf (before.leaves, after.leaves), the leaves not written with their status (after.not_written[]: { leaf, status, approval_id? } for held_for_approval / needs_tenant_admin / needs_platform_admin), and after.gateway_write_failed: true when the gateway write failed after the organisation commit. The organisation fields also keep their own audit rows, written in their transaction: tenant.request_log_retention_changed, tenant.compliance_report_enabled_changed, tenant.config_approval_changed, tenant.agent_review_changed. A no-op apply records nothing.
A stored template whose target_controls is malformed (e.g. a legacy row, or a value outside a leaf's bounds) is never applied: diff and apply answer 422 invalid_stored_template, nothing written. The same payload sent to create or PATCH is 400 invalid_target_controls.
Error codes
| Status | Cause |
|---|---|
400 |
malformed body / failed field validation (e.g. invalid_target_controls: an unknown leaf, an out-of-bounds, fractional, string or null integer value, a loosening value, a duplicate leaf) / a template_key in the reserved myra/ namespace (template_key_reserved) / missing gateway_id / admin omitted ?tenant_id / a repeated or bare ?tenant_id / an admin ?tenant_id that is not one canonical tenant UUID (code: bad_param). |
401 |
unauthenticated. |
403 |
role below ki_manager, or a non-admin without a tenant; an apply that would change a locked gateway control while the gateway's tenant is on the free trial plan (code: trial_gateway_locked, nothing written). |
404 |
unknown / cross-tenant / soft-deleted template (code: template_not_found) or a gateway that vanished after the access check (code: gateway_not_found), or (apply) the gateway's organisation was deleted while its settings were written (code: tenant_not_found). |
409 |
duplicate (tenant, key, version) (also an explicit copy key); PATCH/DELETE of an authoritative or a Myra template; an apply that would deny all inference. Codes: duplicate_template, template_read_only, template_denies_all. |
422 |
a stored template with an invalid target_controls payload at diff / apply (code: invalid_stored_template, formerly stored_template_invalid). |
503 |
{ "error": "temporarily unavailable; retry later" } — a database READ failed (the gateway, its configuration, the template, the tenant, or the caller's custom-role permissions), or the organisation-settings transaction of an apply failed and was rolled back before any four-eyes capture: nothing written, retryable. |
500 |
{ "error": "internal error", "request_id": "…" } — a write failed (template create / update / delete, or the applied controls — the change may have landed: re-run the diff before applying again; in particular a gateway write failing after the organisation settings committed — they may already be applied), the template's read-back after a saved create / update failed (the template is saved — re-read, do not create it again), or the gateway's stored configuration or the organisation's stored request-log retention maximum is corrupt (fail closed — never read as "no maximum"). Any other engine failure answers 500 { "error": "failed to <action> template", "code": "governance_engine_failed" }. The Myra templates failing to load (a defect of the shipped data file) answers 500 { "error": "the Myra templates are unavailable", "code": "system_templates_unavailable" } on the list, a Myra read or copy, and the governance dashboard. |
The 4xx and engine answers above carry a sibling top-level code next to the unchanged error sentence; key off code, not the prose. The generic gate answers (403 role/tenant refusals, the storage 503 and sanitised 500 internal error) keep the shared admin shape described in Error codes.