Data Export API (FOIA, audit, portability)

For a policy analyst, auditor or data steward pulling a bulk export, and the operator who runs it: three GET endpoints satisfy the data-disclosure obligations. All three are user-only and admit the admin or quality_control role — contract.require_user_only(&claims, &["admin", "quality_control"]) in each handler — and a service-class bearer is 403 outright.

Endpoint Service Purpose

GET /v1/export/audit-events

canopy-security (src/api/export.rs)

The raw audit chain within the window — Pub 1075 §9 access-log review, CMS-aligned audit-trail requests, internal QC investigations. No redaction: the log is metadata about who accessed what.

GET /v1/export/persons

canopy-persons (src/api/export.rs)

FOIA disclosure (mode=foia, the default) or citizen data portability (mode=portability&person_id=<uuid>, the named subject only — no bulk portability dump). Shapes below.

GET /v1/export/determinations

canopy-snap (src/api/export.rs)

SNAP determinations finalized within the window — benefit_amount, status, signature (the signed JWS proving determination authenticity per ADR-002) and program_service_version — for FNS-QC sampling and reporting cross-checks. Determinations carry no SSN or DOB; callers combining them with PII for cross-program reporting own the downstream redaction.

Person-record FOIA redaction

mode=foia (default) projects the Person record to a public-records-safe shape:

Field Released? Rationale

id, first_name, last_name

✓

Names appear in court orders / public records; not exempt under the Georgia Open Records Act personal-privacy carve-outs.

birth_year

✓ (year only)

Full DOB is exempt under the personal-privacy carve-out; year-only is the standard de-identification for actuarial / demographic disclosure.

language_preference

✓

Not personally identifying.

active, created_at

✓

Operational metadata, not PII.

ssn_last_four, date_of_birth (full), gender, race, ethnicity, citizenship_status, disability_status, middle_name, suffix, updated_at

✗

Personal-privacy exemption (Georgia OCGA 50-18-72(a)(20) and HIPAA-adjacent disability/race fields). The Person API model already truncates SSN to last-4; the FOIA shape drops it entirely.

mode=portability&person_id=<uuid> returns the full record for the named data subject — for an applicant exercising the right to their own data, never for a public-records request.

Address join

Both modes return the person’s active addresses joined to the record:

Field FOIA released? Rationale

address_type, city, state, zip, county_fips

✓

City/state/zip survive at the FOIA level — these are part of the public address record (voter registration, court filings) and the county FIPS code is jurisdictional metadata, not personal.

line_1, line_2

✗

Street address is exempt under the personal-privacy carve-out; an attacker combining street + birth_year + name would have material to re-identify.

effective_date, end_date

✗

Timing-sensitive metadata that fingerprints a record even after PII is removed (e.g. a unique move-in date).

id, created_at, updated_at

✗ (FOIA only)

Implementation IDs / audit timestamps. Released in portability mode where the data subject is entitled to their full record.

In portability mode every Address column is released — full street, unit number, dates and the row’s identifier — so a caller can re-issue the export and detect address changes by id. Multi-address shapes: JSON nests addresses: […​] on the person object (an empty array when none); CSV flattens to one row per (person, address) pair with the person columns repeating, and a person with zero addresses still emits one row with empty trailing address columns — CSV consumers wanting one person row GROUP BY id after import.

Request parameters

Param Endpoints Meaning

from

all

Inclusive window start (RFC 3339 / ISO 8601). Defaults to 24 hours before to.

to

all

Exclusive window end. Defaults to now.

format

all

json (default) or csv. A recognized query value wins over a conflicting Accept: header; an unrecognized one falls through to Accept (text/csv → CSV, otherwise JSON).

limit

all

Row cap, clamped into 1..=50 000; default 10 000 (EXPORT_DEFAULT_LIMIT / EXPORT_HARD_CAP). Page by re-querying with a narrower from / to.

programs

audit-events

Repeated programs=<slug> keys with the storage slugs snap, tanf, medicaid, chip, caps, wic (ExportAuditParams, crates/canopy-contracts-security/src/export.rs; #1519). Empty = unscoped; non-empty = the audit visibility filter. An unknown slug is 422 (validate_program_slugs, services/canopy-security/src/api/events.rs).

mode

persons

foia (default) or portability.

person_id

persons

Required when mode=portability; the data subject’s UUID.

Responses

  • 200 OK in the requested format; CSV carries Content-Disposition: attachment; filename="…" for browser-driven exports.

  • 400 Bad Request — from >= to, or mode=portability without person_id.

  • 403 Forbidden — a service-class bearer, or a user token without the admin / quality_control role (the frozen contract, ADR-043, the frozen 401/403 contract).

  • 422 Unprocessable Entity — an unknown programs slug (audit-events).

Verify — the export’s own audit trail

Every export publishes one event — audit.export.requested (canopy-security), persons.export.requested (canopy-persons; adds mode and, in portability mode, person_id) or snap.export.requested (canopy-snap) — carrying actor, from, to, format and row_count. The canopy-security wildcard subscriber persists it into the audit chain, so querying that chain for export activity is itself an export. A failure to publish is logged at WARN and does not fail the request: the caller is already authenticated, the data is visible elsewhere and the chain still holds the original events — degraded, not catastrophic.

References

NOTE
History — the address join shipped with #347 (2026-05-04); #1519 added the programs visibility predicate to the audit-events export; the quality_control role the original plan named is implemented and admitted today.
Edit this page · default