Security & Compliance API Reference

Audit logging, security reviews, data archiving, and control mapping against NIST SP 800-53 (the federal security-control catalog).

Endpoints

Admin Units

List live (not deactivated) administrative units, filtered, sorted and paginated.

GET /v1/security/admin/units

Table 1. Parameters
Name In Required Description

jurisdiction

query

No

Filter by jurisdiction (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

unit_type

query

No

Filter by unit type (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

search

query

No

Full-text search across name, fips_code. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: name, unit_type, jurisdiction, fips_code.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated admin units

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-integer page) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: jurisdiction / unit_type 64, search 500, sort_by / sort_dir 32 bytes; or a NUL (U+0000) in jurisdiction, unit_type or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Register an administrative unit; idempotent on client_request_id, and a duplicate live

name in the jurisdiction is a 409.

POST /v1/security/admin/units

Table 2. Request Fields
Field Type Required Description

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same id + identical intent replays the original admin unit; a different intent under the same id is a 409 idempotency-conflict.

fips_code

string (optional)

No

Optional FIPS code for the unit. A NUL (U+0000) is refused.

jurisdiction

string

Yes

Jurisdiction the unit is scoped to. A NUL (U+0000) is refused.

name

string

Yes

Display name of the administrative unit. A NUL (U+0000) is refused.

state_fips

string

Yes

State FIPS code the unit belongs to. A NUL (U+0000) is refused.

unit_type

string

Yes

Unit type (e.g. county, region). A NUL (U+0000) is refused.

Responses
  • 200: Admin unit created (or replayed — same client_request_id + intent)

  • 401: Unauthorized

  • 403: Forbidden

  • 409: Duplicate name+jurisdiction, client_request_id claimed by a different operation, or replayed entity gone

  • 422: Validation failure (including a missing client_request_id), or a NUL (U+0000) in name, unit_type, fips_code, state_fips or jurisdiction (validation-failed naming the field, the value never echoed; before the authorization check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Read one live administrative unit; a deactivated unit is a 404.

GET /v1/security/admin/units/{id}

Table 3. Parameters
Name In Required Description

id

path

Yes

Admin unit ID

Responses
  • 200: Admin unit

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Rename, retype or re-code a unit under If-Match; refused with 409 while any worker binding

on it is live.

PUT /v1/security/admin/units/{id}

Table 4. Parameters
Name In Required Description

id

path

Yes

Admin unit ID

If-Match

header

Yes

REQUIRED row version from your last read, e.g. "3" or 3

Table 5. Request Fields
Field Type Required Description

fips_code

string (optional)

No

Optional FIPS code for the unit. A NUL (U+0000) is refused.

name

string

Yes

Display name of the administrative unit. A NUL (U+0000) is refused.

state_fips

string

Yes

State FIPS code the unit belongs to. A NUL (U+0000) is refused.

unit_type

string

Yes

Unit type (e.g. county, region). A NUL (U+0000) is refused.

Responses
  • 200: Admin unit updated

  • 400: Missing or malformed If-Match

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 409: A live worker binding holds the row — revoke every binding first (admin-unit-bound); the version moved since your read (stale If-Match, concurrent-modification) — re-read and retry; or the new name is already a live unit’s in this jurisdiction (duplicate-resource; value-free, a deactivated unit’s name is free)

  • 422: A body field whose value does not deserialize, e.g. a non-string name (validation-failed; the field is named, the value never echoed), a field over its length cap, or a NUL (U+0000) in name, unit_type, fips_code or state_fips (validation-failed; before the authorization check and the If-Match check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Deactivate (soft-delete) a unit; refused with 409 while any worker binding on it is live.

DELETE /v1/security/admin/units/{id}

Table 6. Parameters
Name In Required Description

id

path

Yes

Admin unit ID

Responses
  • 200: Admin unit soft-deleted

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 409: A live worker binding holds the row — revoke every binding first (admin-unit-bound); deactivation never cascades to revocation

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Alerts

List security alerts, filtered by severity, acknowledgement and text, paginated.

GET /v1/security/alerts

Table 7. Parameters
Name In Required Description

severity

query

No

Filter by severity (exact match; an unknown value matches nothing). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

acknowledged

query

No

true lists only acknowledged alerts, false only standing ones; omit for both.

search

query

No

Full-text search across rule_name, description. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: severity, rule_name, acknowledged, created_at.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated alerts

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-boolean acknowledged) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: severity / sort_by / sort_dir 32, search 500 bytes; or a NUL (U+0000) in severity or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Read one security alert by id.

GET /v1/security/alerts/{id}

Table 8. Parameters
Name In Required Description

id

path

Yes

Alert ID

Responses
  • 200: Alert found

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Acknowledge a standing alert as the acting worker, which re-arms its rule for the next scan;

an already-acknowledged alert is a 404.

PUT /v1/security/alerts/{id}/acknowledge

Table 9. Parameters
Name In Required Description

id

path

Yes

Alert ID

Responses
  • 200: Alert acknowledged

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found or already acknowledged

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Archive

List archive-ledger batches (including purged and legacy rows), filtered and paginated.

GET /v1/security/archive

Table 10. Parameters
Name In Required Description

source_service

query

No

Filter by source service (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

search

query

No

Full-text search across source_service, source_table. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: source_service, source_table, retention_until, archived_at.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated archive records

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-integer page) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: source_service 64, search 500, sort_by / sort_dir 32 bytes; or a NUL (U+0000) in source_service or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


hold, reporting counts and whether more remain.

POST /v1/security/archive/purge

Table 11. Parameters
Name In Required Description

limit

query

No

Rows per call, 1..=100. Default 100.

Responses
  • 200: Bounded purge: counts + a more flag

  • 400: A limit outside 1..=100; a malformed query parameter (e.g. a non-integer limit) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Archiver disabled (consent knob)

  • 409: An archive pass is running

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Enqueue an archive-then-prune run

POST /v1/security/archive/run

Enqueues ONE archive-then-prune run over this service’s audit-class tables (audit_log, dead_letter_audit) as a background job. The job holds the retention-archive lease for its whole life and runs bounded passes (the scheduled pass budget per pass) over ONE preserved set of table states until no eligible work remains — a quarantined poison row is excluded once and never re-selected. Every ledger row + staged event is attributed to the enqueuing operator. Body = { client_request_id } (REQUIRED; the same id replays the SAME job whatever its state, a fresh id is a new job; any other field is 422 validation-failed). Answers 202 with Location: /v1/security/jobs/{id} and the job (state = queued); poll the Location until succeeded (result = the pass report: per_table[] counters + more = false; an isolated table does NOT fail the job — its error is visible in result) or failed (error.token closed: refused_at_start naming the consent knob when it was flipped OFF between enqueue and start, no_progress when a pass moved nothing while work remained, exhausted after three crashed / interrupted attempts, engine_failed). A second enqueue while a run is queued or running is 409 job-already-active; a peer-held engine lease (the hourly scheduled pass) is NOT a refusal — the attempt waits for it (progress.phase = waiting_for_lease). The consent knob (CRAIG_SECURITYRETENTION_ARCHIVEENABLED) is checked synchronously at enqueue (403, nothing minted) AND re-checked by the attempt. Authorized as approve on the security archive (after which the knob refusal is visible).

Table 12. Request Fields
Field Type Required Description

client_request_id

UUID

Yes

The client-minted operation id: the same id replays the SAME job (whatever its state); a fresh id is a new job.

Responses
  • 202: Run enqueued (or a replay of the stored job — nothing re-enqueued); Location = /v1/security/jobs/{id}

  • 401: Unauthorized

  • 403: Forbidden — not permitted to approve the archive, or the archiver is disabled (consent knob; feature-disabled)

  • 409: A run is already queued or running in this jurisdiction (job-already-active), or this client_request_id was used with a different intent (idempotency-conflict)

  • 422: Validation failure — a missing client_request_id or a forged field (validation-failed)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Audit

Search the audit log with optional filters, sorting and pagination.

GET /v1/security/audit

Table 13. Parameters
Name In Required Description

user_id

query

No

Filter by the recorded user id (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

service

query

No

Filter by the recording service (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

action

query

No

Filter by action (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

resource_type

query

No

Filter by resource type (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

resource_id

query

No

Filter by the affected resource’s id (exact match).

from

query

No

Only rows recorded at or after this RFC 3339 instant.

to

query

No

Only rows recorded at or before this RFC 3339 instant.

actor_service

query

No

Filter by caller-service attribution (e.g. craig-web for BFF-originated audit rows). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

actor_user_sub

query

No

Filter by acting-worker normalized UUID sub.

search

query

No

Full-text search across action, user_id. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: timestamp, action, user_id, service, resource_type, actor_service, actor_user_sub.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated audit log

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-UUID resource_id) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: user_id / service / action / resource_type / actor_service 64, search 500, sort_by / sort_dir 32 bytes; or a NUL (U+0000) in user_id, service, action, resource_type, actor_service or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


The 100 most recent audit entries for one resource type and id.

GET /v1/security/audit/resource/{resource_type}/{resource_id}

Table 14. Parameters
Name In Required Description

resource_type

path

Yes

Resource type. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

resource_id

path

Yes

Resource ID

Responses
  • 200: Audit entries for resource

  • 401: Unauthorized

  • 403: Forbidden

  • 422: A NUL (U+0000) in the {resource_type} path segment, before the authorization check (validation-failed naming resource_type, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


The 100 most recent audit entries whose actor column equals the path user_id.

GET /v1/security/audit/user/{user_id}

Table 15. Parameters
Name In Required Description

user_id

path

Yes

User ID. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

Responses
  • 200: Audit entries for user

  • 401: Unauthorized

  • 403: Forbidden

  • 422: A NUL (U+0000) in the {user_id} path segment, before the authorization check (validation-failed naming user_id, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Background Jobs

Poll a background job

GET /v1/security/jobs/{id}

The generic read-only poll of a security background job: the job as a LOGICAL resource — state (queued / running / succeeded / failed; the last two are terminal and immutable), the current attempt and the attempts[] ledger (an interrupted / crash attempt re-queues a convergent kind up to max_attempts), the typed progress document, result (the kind’s report — for archive_run the archive pass report: per-table counters + more, an isolated table’s error visible — present iff succeeded), error (a CLOSED token + a categorical detail — refused_at_start names the consent knob, no_progress a pass that moved nothing — present iff failed), and resource when the kind links its own row. Authorized on the BackgroundJob resource type: admin realm-flat, the creator (human or service principal) by assigned_worker_sub; another actor is the fleet’s typed 403; an unknown id is 404 (no existence collapse — the row is looked up before the check). Cache-Control: no-store. Never writes.

Table 16. Parameters
Name In Required Description

id

path

Yes

Job id — the last segment of the Location the enqueuing 202 answered

Responses
  • 200: The job (Cache-Control: no-store)

  • 401: Unauthorized

  • 403: Forbidden — not the creator and not admin

  • 404: No such job

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Config

Return the deployment’s jurisdiction and its operator label for administrative units.

GET /v1/security/admin/config

Responses
  • 200: Deployment configuration

  • 401: Unauthorized

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Detection Rules

List every live detection rule, newest first.

GET /v1/security/detection-rules

Responses
  • 200: List of detection rules

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Create a detection rule; idempotent on client_request_id, and a duplicate rule_name is a

409.

POST /v1/security/detection-rules

Table 17. Request Fields
Field Type Required Description

business_end_hour

integer (optional)

No

Business-hours band end (0..=23, exclusive-of-after-hours upper bound — 17 means "17:00-17:59 is still business").

business_start_hour

integer (optional)

No

Business-hours band start (0..=23), meaningful for after_hours_access rules — hours are classified in the jurisdiction’s business timezone. Both-or-neither with business_end_hour; start < end (DB CHECK-backed).

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same id + identical intent replays the original detection rule; a different intent under the same id is a 409 idempotency-conflict.

description

string

Yes

What the rule detects. A NUL (U+0000) is refused.

notify_webhook

string (optional)

No

Optional webhook URL to notify on trigger. A NUL (U+0000) is refused; a value must also be an absolute http or https URL with a host, else the 422 naming notify_webhook (the service’s check, after the rule_type and severity checks). Absent or null means no webhook.

rule_name

string

Yes

Human-readable rule name. A NUL (U+0000) is refused.

rule_type

string

Yes

Rule category (e.g. rate, anomaly).

severity

string

Yes

Alert severity (e.g. low, high).

threshold

integer

Yes

Trigger threshold: the rule fires when its window holds at least this many matching audit rows. 0 or more; 0 fires on every scan.

window_minutes

integer

Yes

Evaluation window in minutes, at least 1: a shorter window counts no row, so the rule could never fire.

Responses
  • 200: Rule created (or replayed — same client_request_id + intent)

  • 400: Invalid rule_type or severity

  • 401: Unauthorized

  • 403: Forbidden

  • 409: Duplicate rule_name, client_request_id claimed by a different operation, or replayed entity gone

  • 422: Validation failure (including a missing client_request_id), a window_minutes under 1 or a negative threshold, or a NUL (U+0000) in rule_name, description or notify_webhook (before the authorization check), or a notify_webhook that is not an absolute http or https URL with a host (after the authorization check and the rule_type / severity checks, before the claim) (validation-failed naming the field, the value never echoed)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Partially update a detection rule under If-Match (enable / disable, threshold, window,

severity, webhook, business-hours band).

PUT /v1/security/detection-rules/{id}

Table 18. Parameters
Name In Required Description

id

path

Yes

Detection rule ID

If-Match

header

Yes

REQUIRED row version from your last read, e.g. "3" or 3

Table 19. Request Fields
Field Type Required Description

business_end_hour

integer (optional)

No

New business-hours band end (absent = keep).

business_start_hour

integer (optional)

No

New business-hours band start (absent = keep). Plain Option — the columns are pair-NULLable but "clear the band" is not a supported operation (a clear would silence the rule; set both hours instead).

enabled

boolean (optional)

No

Enable/disable the rule.

notify_webhook

string (optional)

No

Webhook URL — omitted keeps, explicit null clears, a URL sets (craig_validation::double_option makes the clear arm wire-reachable; the skip_serializing_if pairing is LOAD-BEARING — flip both together, never one). A NUL (U+0000) in a URL is refused; a URL must also be an absolute http or https URL with a host, else the 422 naming notify_webhook (the service’s check, after the severity check).

severity

string (optional)

No

New alert severity.

threshold

integer (optional)

No

New trigger threshold (absent = keep); 0 or more, as on create.

window_minutes

integer (optional)

No

New evaluation window in minutes (absent = keep); at least 1, as on create.

Responses
  • 200: Rule updated

  • 400: Invalid severity, or a missing/malformed If-Match

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 409: Version moved since your read (stale If-Match) — re-read and retry

  • 422: A body field whose value does not deserialize, e.g. a non-boolean enabled (validation-failed; the field is named, the value never echoed), a severity / notify_webhook over its length cap, a business_start_hour / business_end_hour outside 0..=23, a window_minutes under 1 or a negative threshold, or a NUL (U+0000) in notify_webhook (validation-failed; before the authorization check and the If-Match check); or a set notify_webhook that is not an absolute http or https URL with a host (validation-failed naming notify_webhook, the value never echoed; after the authorization, If-Match and severity checks, before the write)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Soft-delete a detection rule; it is no longer listed or run by the scan.

DELETE /v1/security/detection-rules/{id}

Table 20. Parameters
Name In Required Description

id

path

Yes

Detection rule ID

Responses
  • 204: Rule deleted

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Run every enabled detection rule now over the audit rows committed since the last scan,

and return the alerts this scan created.

POST /v1/security/detection/run

Responses
  • 200: Detection scan completed

  • 401: Unauthorized

  • 403: Forbidden

  • 500: Internal error, including a missing scan watermark

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: db-timeout: another scan held the scan watermark, or a count ran, past the statement timeout; scans run one at a time and the next scan evaluates the same rows


EventReplay

Replay outbox events in a time window

POST /v1/admin/events/replay

Re-stages the published outbox rows created in [from, to] (optionally one event_type) so the outbox worker republishes them. At most 100000 rows per call; when more is true, call again with the same window and resume_from. Rows already pending are left alone. dry_run=true only counts. A from older than the service’s outbox retention window is refused. Each batch commits on its own, so after a 5xx the committed batches stay re-staged and re-running the same window picks up the rest. Every admitted call, a dry run included, records an admin.events_replayed act naming the worker.

Table 21. Parameters
Name In Required Description

from

query

Yes

RFC 3339 inclusive lower bound on event_outbox.created_at.

to

query

Yes

RFC 3339 inclusive upper bound on event_outbox.created_at.

event_type

query

No

Optional event_type scope. When present, only rows whose event_type equals this value are counted and re-staged; when absent, the whole [from, to] window is in scope.

dry_run

query

No

If true, return the would-replay count without modifying rows.

resume_from

query

No

The resume_from cursor a previous response returned with more = true. Passed back with the same from / to / event_type, the re-stage continues strictly past that key. A string that is not a cursor is a 400 naming this field.

Responses
  • 200: The window’s count and what this call re-staged

  • 400: bad-request: a malformed or missing from / to, a non-boolean dry_run, from after to, from older than the outbox retention window, or a resume_from that is not a replay cursor (field names it)

  • 401: Missing or invalid bearer token

  • 403: The acting identity is not an admin, or is a bare service principal (worker-required): a replay is a worker’s act

  • 422: validation-failed: event_type longer than 255 bytes

  • 500: Internal error (the re-staged count overflowed, or an unclassified database error); batches already committed stay committed

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Major Changes

List live major changes, filtered, sorted and paginated.

GET /v1/security/changes

Table 22. Parameters
Name In Required Description

change_type

query

No

Filter by change type (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

search

query

No

Full-text search across description, affected_scope. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: change_type, description, affected_scope, effective_date, reported_to_acf, created_at.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated major changes

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-integer page) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: change_type 64, search 500, sort_by / sort_dir 32 bytes; or a NUL (U+0000) in change_type or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Record a major change reported by the acting worker; idempotent on client_request_id.

POST /v1/security/changes

Table 23. Request Fields
Field Type Required Description

affected_scope

string

Yes

Scope of systems/processes affected. A NUL (U+0000) is refused.

change_type

string

Yes

Category of the change (e.g. system, policy).

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same id + identical intent replays the original major change; a different intent under the same id is a 409 idempotency-conflict.

description

string

Yes

What changed. A NUL (U+0000) is refused.

effective_date

date

Yes

Date the change takes effect.

notes

string (optional)

No

Optional free-text notes. A NUL (U+0000) is refused.

Responses
  • 200: Major change recorded (or replayed — same client_request_id + intent)

  • 400: Invalid change_type

  • 401: Unauthorized

  • 403: Forbidden

  • 409: client_request_id claimed by a different operation, or replayed entity gone

  • 422: Validation failure (including a missing client_request_id), or a NUL (U+0000) in description, affected_scope or notes (validation-failed naming the field, the value never echoed; before the authorization check and the change_type check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Read one live major change; a deleted one is a 404.

GET /v1/security/changes/{id}

Table 24. Parameters
Name In Required Description

id

path

Yes

Major change ID

Responses
  • 200: Major change found

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Partially update a major change (ACF-reported flag and date, notes, description).

PUT /v1/security/changes/{id}

Table 25. Parameters
Name In Required Description

id

path

Yes

Major change ID

Table 26. Request Fields
Field Type Required Description

description

string (optional)

No

Updated description. A NUL (U+0000) is refused.

notes

string (optional)

No

Free-text notes — same keep/clear/set wire contract as reported_date. A NUL (U+0000) in a set value is refused.

reported_date

date (optional)

No

Date reported to ACF — omitted keeps, explicit null clears, a date sets (craig_validation::double_option makes the clear arm wire-reachable; the skip_serializing_if pairing is LOAD-BEARING — flip both together, never one).

reported_to_acf

boolean (optional)

No

Whether the change was reported to ACF.

Responses
  • 200: Major change updated

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 422: A body field whose value does not deserialize, e.g. a non-boolean reported_to_acf (validation-failed; the field is named, the value never echoed), a notes / description over its length cap, or a NUL (U+0000) in notes or description (validation-failed; before the authorization check and the lookup)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Soft-delete a major change.

DELETE /v1/security/changes/{id}

Table 27. Parameters
Name In Required Description

id

path

Yes

Major change ID

Responses
  • 204: Major change deleted

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


NIST

List live NIST controls, filtered, sorted and paginated.

GET /v1/security/nist

Table 28. Parameters
Name In Required Description

control_family

query

No

Filter by control family (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

implementation_status

query

No

Filter by implementation status (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

search

query

No

Full-text search across control_id, control_family. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: control_id, control_family, control_name, implementation_status.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated NIST controls

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-integer page) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: control_family 64, implementation_status / sort_by / sort_dir 32, search 500 bytes; or a NUL (U+0000) in control_family, implementation_status or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Map a NIST control; idempotent on client_request_id, and a duplicate live control_id is a

409.

POST /v1/security/nist

Table 29. Request Fields
Field Type Required Description

assessed_by

string (optional)

No

Who performed the assessment. A NUL (U+0000) is refused.

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same id + identical intent replays the original NIST control; a different intent under the same id is a 409 idempotency-conflict.

control_family

string

Yes

Control family (e.g. Access Control). A NUL (U+0000) is refused.

control_id

string

Yes

Control identifier (e.g. AC-2). A NUL (U+0000) is refused.

control_name

string

Yes

Human-readable control name. A NUL (U+0000) is refused.

evidence_key

string (optional)

No

Object-store key for supporting evidence. A NUL (U+0000) is refused.

implementation_notes

string (optional)

No

Free-text implementation notes. A NUL (U+0000) is refused.

implementation_status

string (optional)

No

Implementation status: one of planned, partial, implemented, not_applicable, else the typed 400 invalid-enum-value naming implementation_status (the service’s check, after the authorization check and before the claim). A NUL (U+0000) is refused first, as the 422. Absent or null stores planned.

last_assessed

date (optional)

No

Date the control was last assessed.

Responses
  • 200: Control created (or replayed — same client_request_id + intent)

  • 400: An implementation_status outside planned, partial, implemented, not_applicable (invalid-enum-value naming implementation_status and listing the vocabulary, the value never echoed; after the authorization check, before the claim)

  • 401: Unauthorized

  • 403: Forbidden

  • 409: Duplicate control_id, client_request_id claimed by a different operation, or replayed entity gone

  • 422: Validation failure (including a missing client_request_id), or a NUL (U+0000) in control_id, control_family, control_name, implementation_status, implementation_notes, evidence_key or assessed_by (validation-failed naming the field, the value never echoed; before the authorization check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Read the live control with this control_id.

GET /v1/security/nist/{control_id}

Table 30. Parameters
Name In Required Description

control_id

path

Yes

NIST control ID (e.g. AC-2)

Responses
  • 200: Control found

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 422: A {control_id} over 64 bytes or carrying a NUL (U+0000) (validation-failed naming control_id, the value never echoed; before the authorization check and the lookup)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Update a control’s status (an allowed transition only) and assessment details.

PUT /v1/security/nist/{control_id}

Table 31. Parameters
Name In Required Description

control_id

path

Yes

NIST control ID (e.g. AC-2)

Table 32. Request Fields
Field Type Required Description

assessed_by

string (optional)

No

Who performed the assessment. A NUL (U+0000) is refused.

evidence_key

string (optional)

No

Object-store key for supporting evidence. A NUL (U+0000) is refused.

implementation_notes

string (optional)

No

Free-text implementation notes. A NUL (U+0000) is refused.

implementation_status

string

Yes

New implementation status.

last_assessed

date (optional)

No

Date the control was last assessed.

Responses
  • 200: Control updated

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found (including a soft-deleted control)

  • 409: Implementation status moved concurrently since your read — re-read and retry

  • 422: A body field whose value does not deserialize, e.g. a non-date last_assessed (validation-failed; the field is named, the value never echoed), a field over its length cap, a {control_id} over 64 bytes, or a NUL (U+0000) in the {control_id} path segment (naming control_id), implementation_notes, evidence_key or assessed_by (validation-failed; the path first, then the body, both before the authorization check and the lookup)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Soft-delete the live control with this control_id; the id can then be reused.

DELETE /v1/security/nist/{control_id}

Table 33. Parameters
Name In Required Description

control_id

path

Yes

NIST control ID (e.g. AC-2)

Responses
  • 204: Control deleted

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 422: A {control_id} over 64 bytes or carrying a NUL (U+0000) (validation-failed naming control_id, the value never echoed; before the authorization check and the delete)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Partner Client Certificates

Resolve a caller’s certificate, by its fingerprint, to the partner it is registered against;

only an approved certificate of an active partner, inside its validity, resolves.

GET /v1/security/client-certificates/by-fingerprint/{sha256}

Table 34. Parameters
Name In Required Description

sha256

path

Yes

SHA-256 of the certificate’s DER encoding: 64 lowercase hexadecimal digits

Responses
  • 200: The partner and the registration that admit the caller

  • 400: sha256 is not 64 lowercase hexadecimal digits: it names no certificate (bad-request naming sha256, value-free), answered before authorization

  • 401: Unauthorized

  • 403: The caller is not the craig-exchange service identity, or it relays another identity (a delegated actor or subject token)

  • 404: No certificate with this fingerprint admits a caller now: it is unregistered, pending, revoked or outside its validity, or its partner is not active. The answer is the same for each

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


List a partner’s client certificates in every status, newest first.

GET /v1/security/partners/{id}/client-certificates

Table 35. Parameters
Name In Required Description

id

path

Yes

Partner ID

Responses
  • 200: The partner’s client certificates

  • 401: Unauthorized

  • 403: Forbidden, including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused and never widened

  • 404: Partner not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Register a partner’s client certificate; it stays pending and admits nobody until an

administrator approves it.

POST /v1/security/partners/{id}/client-certificates

Table 36. Parameters
Name In Required Description

id

path

Yes

Partner ID

Table 37. Request Fields
Field Type Required Description

certificate_pem

string

Yes

The partner’s certificate in PEM: exactly one CERTIFICATE block. It is public; no key is ever sent here. A NUL (U+0000) is refused.

label

string

Yes

What an administrator tells this certificate from another by, e.g. "benefits batch host, 2027". A NUL (U+0000) is refused.

Responses
  • 200: Registered (pending an administrator’s approval)

  • 400: certificate_pem is not exactly one X.509 certificate, is a certificate authority’s, is valid at no time (its validity ends before it begins), or is past its validity (invalid-client-certificate, naming certificate_pem; the certificate is never echoed); or a label made only of control characters (named, never echoed). Other control characters are removed from the label before it is stored

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Partner not found (a deleted partner is not found)

  • 409: The certificate is already registered and not revoked, against this partner or another

  • 422: An unknown key, a field empty or over its length cap, or a NUL (U+0000) in certificate_pem or label (validation-failed; the field is named, the value never echoed)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Approve a pending client certificate so that it admits a caller.

PUT /v1/security/partners/{id}/client-certificates/{certificate_id}/approve

Table 38. Parameters
Name In Required Description

id

path

Yes

Partner ID

certificate_id

path

Yes

Client certificate registration ID

Responses
  • 200: Approved

  • 401: Unauthorized

  • 403: Forbidden

  • 404: No pending registration of this partner has this id: it is another partner’s, already approved, revoked or absent

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Revoke a client certificate so that it admits nobody from this statement on.

PUT /v1/security/partners/{id}/client-certificates/{certificate_id}/revoke

Table 39. Parameters
Name In Required Description

id

path

Yes

Partner ID

certificate_id

path

Yes

Client certificate registration ID

Responses
  • 200: Revoked

  • 401: Unauthorized

  • 403: Forbidden

  • 404: No live registration of this partner has this id: it is another partner’s, already revoked or absent

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Partner Signer Keys

List a partner’s signer keys in every status, newest first.

GET /v1/security/partners/{id}/signer-keys

Table 40. Parameters
Name In Required Description

id

path

Yes

Partner ID

Responses
  • 200: Signer keys for partner

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 404: Partner not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Register a per-person JWS signer key for a partner; it stays pending and verifies nothing

until an admin approves it.

POST /v1/security/partners/{id}/signer-keys

Table 41. Parameters
Name In Required Description

id

path

Yes

Partner ID

Table 42. Request Fields
Field Type Required Description

algorithm

string (optional)

No

Signing algorithm (defaults to ES256 if omitted).

display_name

string

Yes

Human-readable display name, e.g. "Dr. Jones". A NUL (U+0000) is refused.

expires_at

datetime (optional)

No

Optional key expiry.

key_id

string

Yes

kid in the JWS header; globally unique. A NUL (U+0000) is refused.

public_key_jwk

object

Yes

Public key as a JWK (RFC 7517). The document may nest at most 4 levels, hold at most 32 values, and no string or key longer than 1,024 bytes; a document past a limit is refused before the key itself is checked, with the status each route documents for an invalid body.

user_identifier

string

Yes

Partner-scoped identifier for the signing person (email, employee id). A NUL (U+0000) is refused.

Responses
  • 200: Signer key registered (pending admin approval)

  • 400: Invalid algorithm (invalid-enum-value), a public_key_jwk that is not exactly a P-256 public key (invalid-signer-jwk; the key is never echoed), or a user_identifier / display_name made only of control characters (named, never echoed). Other control characters are removed from both labels before they are stored

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Partner not found

  • 409: Duplicate kid

  • 422: A body field whose value does not deserialize, e.g. a malformed expires_at (validation-failed; the field is named, the value never echoed), a field over its length cap, or a NUL in user_identifier, display_name or key_id (validation-failed)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Approve a pending signer key so it starts verifying signatures.

PUT /v1/security/partners/{id}/signer-keys/{signer_key_id}/approve

Table 43. Parameters
Name In Required Description

id

path

Yes

Partner ID

signer_key_id

path

Yes

Signer key ID

Responses
  • 200: Approved

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found or already approved

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Revoke a signer key so it stops verifying signatures.

PUT /v1/security/partners/{id}/signer-keys/{signer_key_id}/revoke

Table 44. Parameters
Name In Required Description

id

path

Yes

Partner ID

signer_key_id

path

Yes

Signer key ID

Responses
  • 200: Revoked

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found or already revoked

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Resolve a JWS kid to the signer’s public key and identity; only an approved, unrevoked,

unexpired key of an active partner resolves.

GET /v1/security/signer-keys/by-kid/{kid}

Table 45. Parameters
Name In Required Description

kid

path

Yes

JWS kid header value

Responses
  • 200: Signer key metadata + pubkey

  • 400: A kid over the identifier cap or containing a NUL (U+0000): it names no registered key (bad-request naming kid, value-free), before authorization

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Unknown/pending/revoked kid or inactive partner

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Partners

List non-deleted partners, filtered, sorted and paginated.

GET /v1/security/partners

Table 46. Parameters
Name In Required Description

kind

query

No

Filter by partner kind (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

status

query

No

Filter by partner status (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

search

query

No

Full-text search across name, contact_email. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: name, kind, status, created_at.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated partners

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-integer page) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: kind 64, status / sort_by / sort_dir 32, search 500 bytes; or a NUL (U+0000) in kind, status or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Create a partner organisation; idempotent on client_request_id (a matching resend returns

the same partner).

POST /v1/security/partners

Table 47. Request Fields
Field Type Required Description

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same id + identical intent replays the original partner; a different intent under the same id is a 409 idempotency-conflict.

contact_email

string (optional)

No

Contact email (capped at SHORT_TEXT_MAX to cover the RFC-5321 practical ceiling). A NUL (U+0000) is refused.

contact_phone

string (optional)

No

Contact phone. A NUL (U+0000) is refused.

kind

string

Yes

Partner kind. One of: hospital, school, le, other.

name

string

Yes

Partner display name. A NUL (U+0000) is refused.

rate_limit_rpm

integer (optional)

No

Per-minute rate limit (defaults to 60 if omitted).

Responses
  • 200: Partner created (or replayed — same client_request_id + intent)

  • 400: Invalid kind

  • 401: Unauthorized

  • 403: Forbidden

  • 409: client_request_id claimed by a different operation, or replayed entity gone

  • 422: Validation failure (including a missing client_request_id), or a NUL (U+0000) in name, contact_email or contact_phone (validation-failed naming the field, the value never echoed; before the authorization check and the kind check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Check a partner-presented API key: valid only when unrevoked, unexpired and owned by an

active partner. Returns the partner id and rate limit, or 401.

POST /v1/security/partners/verify

Table 48. Request Fields
Field Type Required Description

api_key

string

Yes

Raw API key — intake forwards the partner-presented credential here.

Responses
  • 200: Credential valid

  • 401: Credential invalid, revoked, or partner suspended

  • 403: Forbidden

  • 422: A body field whose value does not deserialize, e.g. a non-string api_key (validation-failed; the field is named, the value never echoed), or an api_key over 64 bytes (validation-failed)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Read one partner by id, whatever its status.

GET /v1/security/partners/{id}

Table 49. Parameters
Name In Required Description

id

path

Yes

Partner ID

Responses
  • 200: Partner found

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Update a partner’s details or suspend / re-activate it, guarded by the body’s version.

PUT /v1/security/partners/{id}

Table 50. Parameters
Name In Required Description

id

path

Yes

Partner ID

Table 51. Request Fields
Field Type Required Description

contact_email

string (optional)

No

Contact email — omitted keeps, explicit null clears, a string sets (craig_validation::double_option makes the clear arm wire-reachable; the skip_serializing_if pairing is LOAD-BEARING — without it a Rust-side keep-intent None would serialize as null, which the fixed deserializer reads as CLEAR: unintended data loss. Flip both attributes together, never one). A NUL (U+0000) in a set value is refused.

contact_phone

string (optional)

No

Contact phone — same keep/clear/set wire contract as contact_email. A NUL (U+0000) in a set value is refused.

name

string (optional)

No

New partner display name. A NUL (U+0000) is refused.

rate_limit_rpm

integer (optional)

No

Per-minute rate limit.

status

string (optional)

No

Status transition: active ↔ suspended (use DELETE for soft-delete).

version

integer

Yes

REQUIRED row version from your last read — the version CAS. Suspension cycles are ABA-vulnerable, so only the monotonic counter blocks a stale re-suspension replay; stale → 409 concurrent-modification.

Responses
  • 200: Partner updated

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 409: Version moved since your read (stale body version) — re-read and retry

  • 422: A body field whose value does not deserialize, e.g. a non-integer version (validation-failed; the field is named, the value never echoed), a field over its length cap, or a NUL (U+0000) in name, contact_email or contact_phone (validation-failed; before the authorization check and the status check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Soft-delete a partner (status deleted); the row stays for audit and its keys stop

authenticating.

DELETE /v1/security/partners/{id}

Table 52. Parameters
Name In Required Description

id

path

Yes

Partner ID

Responses
  • 200: Partner soft-deleted

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


List a partner’s API keys, revoked ones included; only hashes and prefixes, never a secret.

GET /v1/security/partners/{id}/keys

Table 53. Parameters
Name In Required Description

id

path

Yes

Partner ID

Responses
  • 200: Keys for partner (hash/prefix only)

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 404: Partner not found, or soft-deleted

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Issue a new API key for an active partner. The plaintext key is in this response only; a

resend with the same client_request_id is a 409 naming the key, never the secret.

POST /v1/security/partners/{id}/keys

Table 54. Parameters
Name In Required Description

id

path

Yes

Partner ID

Table 55. Request Fields
Field Type Required Description

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. One-time-secret contract: the plaintext key is returned exactly once, so a replay under the same id + intent is a 409 one-time-secret-already-issued naming the existing key id — never a 200 and never the secret again.

expires_at

datetime (optional)

No

Override the default 1-year expiry.

label

string (optional)

No

Operator-facing label (optional). A NUL (U+0000) is refused.

Responses
  • 200: Key issued; plaintext returned once — a replay never re-exposes it

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Partner not found (including soft-deleted)

  • 409: One-time secret already issued for this client_request_id (naming the key id, never the secret), the id is claimed by a different operation, or the partner is suspended (partner-not-active — re-activate and retry; the refusal consumed nothing)

  • 422: Validation failure (including a missing client_request_id), or a NUL (U+0000) in label (validation-failed naming the field, the value never echoed; before the authorization check, the replay precheck and the partner lookup)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Revoke one of a partner’s API keys; a key belonging to another partner reads as not found.

DELETE /v1/security/partners/{id}/keys/{key_id}

Table 56. Parameters
Name In Required Description

id

path

Yes

Partner ID

key_id

path

Yes

Key ID

Responses
  • 200: Key revoked

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Key not found or already revoked

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Rotation. Atomically revokes the named key and

issues a new one belonging to the same partner. Returns the new row
raw plaintext (one-time view, same contract as issue_key). It takes rotation’s first body — the 1-field claim id — and replays 409 naming the previously rotated-in key, never re-exposing its plaintext.

POST /v1/security/partners/{id}/keys/{key_id}/rotate

Table 57. Parameters
Name In Required Description

id

path

Yes

Partner ID

key_id

path

Yes

Key ID being rotated

Table 58. Request Fields
Field Type Required Description

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same one-time-secret replay contract as IssueKeyRequest: a replay 409s naming the key already issued by the original rotation, never re-exposing its plaintext.

Responses
  • 200: Rotated; new plaintext key returned once — a replay never re-exposes it

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Key not found or already revoked, or the partner is soft-deleted (masked)

  • 409: One-time secret already issued for this client_request_id (naming the new key id, never the secret), the id is claimed by a different operation, or the partner is suspended (partner-not-active — re-activate and retry; the refusal consumed nothing)

  • 422: Validation failure (including a missing client_request_id)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Reviews

List live security reviews, filtered, sorted and paginated.

GET /v1/security/reviews

Table 59. Parameters
Name In Required Description

review_type

query

No

Filter by review type (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

status

query

No

Filter by status (exact match). A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

search

query

No

Full-text search across review_type. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter.

sort_by

query

No

Sort column: review_type, status, scheduled_date, reviewer.

sort_dir

query

No

Sort direction: asc or desc (default: desc).

page

query

No

1-based page number (default 1); a page past the depth cap of 10,000 is a 400.

per_page

query

No

Rows per page (default 25, silently capped at 500); 0 returns only the total.

Responses
  • 200: Paginated reviews

  • 400: A page past the depth cap; a malformed query parameter (e.g. a non-integer page) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: review_type 64, status / sort_by / sort_dir 32, search 500 bytes; or a NUL (U+0000) in review_type, status or search, before the authorization check (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Schedule a security review; idempotent on client_request_id.

POST /v1/security/reviews

Table 60. Request Fields
Field Type Required Description

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same id + identical intent replays the original review; a different intent under the same id is a 409 idempotency-conflict.

review_type

string

Yes

Review category — the closed craig_reference::ReviewType vocabulary (biennial, incident, ad_hoc, access_review); anything else is refused with the typed 400 INVALID_ENUM_VALUE. Wire type stays String (the contract crate carries no reference-enum dependency); the service parses against the canonical enum.

reviewer

string

Yes

Name of the assigned reviewer. A NUL (U+0000) is refused.

scheduled_date

date

Yes

Date the review is scheduled for.

Responses
  • 200: Review created (or replayed — same client_request_id + intent)

  • 400: Invalid review_type — outside the canonical ReviewType vocabulary

  • 401: Unauthorized

  • 403: Forbidden

  • 409: client_request_id claimed by a different operation, or replayed entity gone

  • 422: Validation failure (including a missing client_request_id), or a NUL (U+0000) in reviewer (validation-failed naming the field, the value never echoed; before the authorization check and the review_type check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Read one live security review; a deleted one is a 404.

GET /v1/security/reviews/{id}

Table 61. Parameters
Name In Required Description

id

path

Yes

Review ID

Responses
  • 200: Review found

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Move a review to a new status (an allowed transition only) and record its completion date,

findings and remediation plan.

PUT /v1/security/reviews/{id}

Table 62. Parameters
Name In Required Description

id

path

Yes

Review ID

Table 63. Request Fields
Field Type Required Description

completed_date

date (optional)

No

Date the review was completed.

findings

object

No

Structured findings payload (stored as-is). It may nest at most 16 levels, hold at most 2,000 values, and no string or key longer than 16,384 bytes; a document past a limit, or with a NUL (U+0000) in any string or object key, is refused.

remediation_plan

object

No

Structured remediation-plan payload (stored as-is), under the same size limits as findings; a document past a limit, or with a NUL (U+0000) in any string or object key, is refused.

status

string

Yes

New review status.

Responses
  • 200: Review updated

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found (including a soft-deleted review)

  • 409: Status moved concurrently since your read — re-read and retry

  • 422: A body field whose value does not deserialize, e.g. a non-date completed_date (validation-failed; the field is named, the value never echoed), a status over 32 bytes, or a NUL (U+0000) in any string or object key of findings or remediation_plan (validation-failed; before the authorization check, the lookup and the transition check)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Soft-delete a security review.

DELETE /v1/security/reviews/{id}

A review with attached evidence is deleted too; its evidence records stay in place.

Table 64. Parameters
Name In Required Description

id

path

Yes

Review ID

Responses
  • 204: Review deleted

  • 401: Unauthorized

  • 403: Forbidden

  • 404: Not found

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Worker Admin Units

List the worker’s live bindings, oldest first.

GET /v1/security/admin/workers/{sub}/admin-units

Table 65. Parameters
Name In Required Description

sub

path

Yes

The worker’s subject (claims.sub)

Responses
  • 200: The worker’s LIVE bindings, oldest first (revoked rows read by id only)

  • 401: Unauthorized

  • 403: Not an admin or readonly auditor; an assignment-scoped grant is refused rather than widened, since these rows carry no per-worker ownership

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Bind a worker to an active county unit, copying its name, type and jurisdiction at assign;

idempotent on client_request_id.

POST /v1/security/admin/workers/{sub}/admin-units

Table 66. Parameters
Name In Required Description

sub

path

Yes

The worker’s subject (claims.sub)

Table 67. Request Fields
Field Type Required Description

admin_unit_id

UUID

Yes

The admin_unit_registry row to bind.

client_request_id

UUID

Yes

Client-minted idempotency id — REQUIRED. Same id
identical intent replays the original binding; a different intent under the same id is a 409 idempotency-conflict.

Responses
  • 200: Binding assigned (or replayed — same client_request_id + intent)

  • 400: The registry row is not bindable — not a county, or inactive (admin-unit-not-bindable)

  • 401: Unauthorized

  • 403: Not an admin

  • 404: No such admin unit

  • 409: The worker already holds a live binding to this unit (admin-unit-already-bound), client_request_id claimed by a different operation, or replayed entity gone

  • 422: Validation failure (including a missing client_request_id)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Read one of the worker’s bindings by id, live or revoked.

GET /v1/security/admin/workers/{sub}/admin-units/{id}

Table 68. Parameters
Name In Required Description

sub

path

Yes

The worker’s subject (claims.sub)

id

path

Yes

Binding ID

Responses
  • 200: The binding — live OR revoked, with the unit name frozen at assign

  • 401: Unauthorized

  • 403: Not an admin or readonly auditor

  • 404: No such binding under this worker

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Revoke a worker’s binding under If-Match; revoking an already-revoked binding answers the

row again.

DELETE /v1/security/admin/workers/{sub}/admin-units/{id}

Table 69. Parameters
Name In Required Description

sub

path

Yes

The worker’s subject (claims.sub)

id

path

Yes

Binding ID

If-Match

header

Yes

REQUIRED row version from your last read, e.g. "1" or 1

Responses
  • 200: Binding revoked — or already revoked (the idempotent replay answers the row, whatever If-Match it carried)

  • 400: Missing or malformed If-Match

  • 401: Unauthorized

  • 403: Not an admin

  • 404: No such binding under this worker

  • 409: The live row’s version moved since your read (stale If-Match) — re-read and retry

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


WorkerIdentities

Admin: set or clear a worker’s agency work phone

PUT /v1/security/admin/workers/{sub}/contact

Replaces the worker’s WHOLE contact record: a string sets the agency work line (E.164), null clears it; the key is required. Admin only — the worker_identity ruleset’s non-admin update DENY on the contact projection (its current revision) refuses every other role. A change stages security.worker_identity.contact_changed (the new value, the acting admin) in the same transaction; an unchanged value writes nothing. Never a personal number. Cache-Control: no-store.

Table 70. Parameters
Name In Required Description

sub

path

Yes

The worker’s subject (claims.sub)

Table 71. Request Fields
Field Type Required Description

contact_phone

string (optional)

Yes

E.164 (+14045550142) — the agency work line, never a personal number.

Responses
  • 200: The worker’s contact card after the write; Cache-Control: no-store

  • 401: Missing or invalid bearer

  • 403: Not an admin

  • 404: A worker this service has never seen (the worker signs in once first)

  • 422: The contact_phone key is missing, or the value is not E.164, or a body field whose value does not deserialize, e.g. a non-string contact_phone (validation-failed; the field is named, the value never echoed)

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Service-to-service: the live admin-units snapshot of one jurisdiction

GET /v1/security/worker-identities/admin-units

{ registry_generation, units: { sub → [unit_name] } } — every LIVE county binding of the requested jurisdiction (the name frozen at assign), read after the registry generation inside one transaction, so the rows are never older than the generation attests. No PII (pseudonymous subjects, county names). Service-only: a worker bearer — direct, or relayed through X-Craig-Actor — is refused before the engine; the caller must be a service principal the worker_identity ruleset’s admin_units projection row admits (claims.is_service AND resource.attrs.projection == 'admin_units', 1.3.0). Cache-Control: no-store.

Table 72. Parameters
Name In Required Description

jurisdiction

query

Yes

The jurisdiction whose live county bindings the snapshot carries — a craig_reference::State::jurisdiction_key. REQUIRED; an unknown key is a typed 400 INVALID_ENUM_VALUE on this field.

Responses
  • 200: The snapshot; Cache-Control: no-store

  • 400: An unknown jurisdiction key — the typed INVALID_ENUM_VALUE problem naming field jurisdiction. A missing or unknown query parameter (the query is closed) is refused by the query extractor itself with its value-free bad-request problem before the handler runs.

  • 401: Missing or invalid bearer

  • 403: Not a service caller, a relayed (X-Craig-Actor) call, or the deployment’s worker_identity ruleset carries no admin_units projection row yet

  • 422: A jurisdiction over its 64-byte length cap

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Service-to-service: batched worker contact cards for the foster-parent portal

POST /v1/security/worker-identities/contacts

{ sub → { display_name, contact_phone } } for ≤ 50 subs — the identity cache’s display name (the worker’s IdP name; null when the cache holds only the username, which is never returned) plus the admin-entered agency work line (null when unset); no username, no email. The request is WorkerContactsRequest ({ subs }). Service-only: a worker bearer is refused outright; a bare service principal passes only the worker_identity ruleset’s contact row (claims.service_id == 'craig-placement' AND resource.attrs.projection == 'contact'); a service call relaying X-Craig-Actor is refused 403 before the engine or any read (the engine would evaluate it as the acting worker). A sub this service has never seen is omitted; Cache-Control: no-store.

Table 73. Request Fields
Field Type Required Description

subs

array of UUID

Yes

Worker subjects to look up (≤ WORKER_CONTACTS_MAX_SUBS; a sub craig-security has never seen is simply absent from the response — never a per-sub 404).

Responses
  • 200: Contact cards keyed by sub (unknown subs omitted); Cache-Control: no-store

  • 400: Over the 50-sub cap (BATCH_TOO_LARGE, field subs)

  • 401: Missing or invalid bearer

  • 403: Not a service caller; a relayed (X-Craig-Actor) call; or a bare service principal the contact row does not admit

  • 422: A body field whose value does not deserialize, e.g. a non-UUID entry in subs (validation-failed; the field is named, the value never echoed)

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Autocomplete-search worker identities for reassignment UI

GET /v1/security/workers

Table 74. Parameters
Name In Required Description

search

query

No

Substring to match (case-insensitive) against preferred_username
display_name. Minimum 2 characters; shorter queries return HTTP 400. A NUL (U+0000), which the query’s TEXT predicate cannot bind, is a 422 validation-failed on this parameter, checked first, so a lone NUL is the 422 rather than the 400.

limit

query

No

Result cap. Default 25; max 100.

Responses
  • 200: Matched workers

  • 400: Search query too short; a malformed query parameter (e.g. a non-integer limit) is the extractor’s value-free bad-request problem, before the handler

  • 401: Unauthorized

  • 403: Forbidden — including a worker- or supervisor-scoped caller: these rows carry no per-worker ownership, so an assignment scope is refused rather than widened

  • 422: A filter over its length cap: search 500 bytes; or a NUL (U+0000) in search, checked before the authorization check and the 2-character minimum, so a lone NUL is this 422, not the 400 (validation-failed naming the parameter, value-free)

  • 500: Internal error

  • 503: Service Unavailable (RFC 9457 problem document): database pool exhaustion (carries Retry-After: 5), db-connection-lost, db-outcome-unknown, or a synchronous upstream dependency refusal.

  • 504: Gateway Timeout (RFC 9457 problem document): the route-class request ceiling elapsed (request-timeout) or the database canceled the statement (db-timeout) — the server yields first.


Edit this page · latest