Skip to main content

Compliance evidence export

The evidence export packages what your auditors usually ask for into one bundle: how the gateway is configured, whether its audit log is intact, and what it recorded over a period. Each bundle is stored with a SHA-256 checksum, so you and your auditor can confirm that a downloaded copy has not changed since it was handed over and that it matches the stored record. It is an enterprise feature, and every /compliance/evidence route returns 403 without a license.

The bundle is input for your own ISO/IEC 42001 or SOC 2 assessment. Generating it does not certify your deployment, your organization or Spanway against either standard. The control mapping is a suggestion for your auditor to confirm against your own scope and policies.

A real-world scenario​

An auditor preparing a SOC 2 report asks for proof of access control, audit logging and retention over the last quarter. The security lead generates a 90 day bundle, downloads the JSON and the HTML report, and sends both with the checksum so the auditor can confirm that nothing changed after handover.

Steps​

  1. In the Admin UI open Settings, then Compliance, and select the Evidence tab.

  2. Choose Last 90 days under Evidence window and click Generate bundle. The same call with the API:

    curl -X POST http://localhost:4000/compliance/evidence/generate \
    -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
    -d '{"window_days": 90}'
  3. In the bundle's row click JSON and Report under Download, or fetch them with the evidence_id from step 2.

    curl -s "http://localhost:4000/compliance/evidence/bundle?evidence_id=$ID" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -o bundle.json
    curl -s "http://localhost:4000/compliance/evidence/report?evidence_id=$ID" -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -o report.html
  4. Recompute the checksum as shown in Download and verify and send it with the files.

Expected result​

A toast confirms "Evidence bundle" with the first 12 characters of its checksum. The JSON download carries "checksum_valid": true, and the recomputed SHA-256 matches the sha256 of the bundle and the X-Evidence-SHA256 header of the report.

What a bundle contains​

SectionContents
control_mapEach Spanway control with its suggested ISO/IEC 42001 clause or Annex A control, its SOC 2 criteria, a pass, fail or not_applicable status and the evidence behind it.
compliance_reportThe full regime catalogue evaluated against the running configuration, with its summary score.
audit_logWhether audit logging is on, the audit log retention period, and the hash chain verification result for the window, including the first broken row if there is one.
retentionEvery retention period the cleanup job honours and when the job last finished.
access_controlSSO providers, whether environment credential login is disabled, whether the master key is a known default, custom roles with their granted and denied permissions, user counts by role, active SCIM tokens and SCIM-provisioned users, and the allowed_ips allow-list.
guardrailsEvery configured guardrail with its modes, and which ones mask personal data before the model call.
evals and red_teamUp to 25 eval runs and 25 red-team runs started in the window, with their status and pass rates.
change_historyAudit log counts by table and action for the window, and the newest 500 changes with who made them, when, and which object. Before and after values are left out.

Window bounds, the trigger (manual or scheduled), who generated it and a scope_statement repeating the paragraph above are recorded with every bundle.

Control map​

ControlISO/IEC 42001SOC 2Source
access.ssoA.3.2CC6.1sso_configured evaluator
access.master_keyCC6.1master_key_not_default evaluator
access.env_loginCC6.1env_credential_login_disabled evaluator
access.least_privilegeA.3.2CC6.2, CC6.3custom_roles_in_use evaluator
access.provisioningA.3.2CC6.2At least one active SCIM token
access.networkCC6.6allowed_ips is set
access.transmissionCC6.7tls_on_public_url evaluator
logging.audit_trailA.6.2.8, 7.5.3CC7.2, CC8.1Audit logging is on and the hash chain verifies for the window
logging.audit_retention7.5.3CC7.3audit_log_retention_configured evaluator
logging.monitoringA.6.2.6CC7.2external_logging_sink evaluator
data.request_log_retentionC1.2spend_log_retention_configured evaluator
data.prompt_minimisationP4.2, C1.1prompts_not_stored_or_masked evaluator
data.residencyA.10.3CC9.2residency_policy_enforced evaluator
guardrails.coverageA.9.2, A.6.2.6CC5.2At least one guardrail is configured
guardrails.piiA.9.2C1.1, P4.1pii_masking_pre_call evaluator
evaluation.evalsA.6.2.4, 9.1CC4.1At least one eval run completed in the window
evaluation.red_teamA.6.2.4, 6.1.2CC3.2, CC4.1At least one red-team run completed in the window
operations.capacityA.4.5A1.1rate_limits_configured evaluator

References are to ISO/IEC 42001:2023 and the 2017 Trust Services Criteria with the 2022 points of focus. The evaluators are described on the compliance page.

Generate a bundle​

A proxy admin generates a bundle over the last window_days days, from 1 to 366, defaulting to 90.

curl -X POST http://localhost:4000/compliance/evidence/generate \
-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \
-d '{"window_days": 90}'
{
"evidence_id": "5c0b0c2e-8f0e-4a51-9d0a-3e2f3f0c9b6e",
"trigger": "manual",
"window_start": "2026-07-20T12:00:00Z",
"window_end": "2026-10-18T12:00:00Z",
"sha256": "9f2c...",
"created_by": "admin@example.com",
"created_at": "2026-10-18T12:00:01Z"
}

Download and verify​

GET /compliance/evidence lists stored bundles newest first, without their contents. GET /compliance/evidence/bundle?evidence_id=... returns the JSON bundle with checksum_valid, which is false when the stored contents no longer match the checksum recorded at generation. GET /compliance/evidence/report?evidence_id=... returns the same bundle as a self-contained HTML report, ready to print to PDF from a browser, with the checksum in the report and in the X-Evidence-SHA256 header. The report is refused with 409 when the stored bundle fails its checksum.

The checksum is SHA-256 over the bundle serialized as UTF-8 JSON with sorted keys and no whitespace. An auditor can recompute it from the bundle field of the JSON download.

The checksum has no key and is stored in the same database row as the bundle, so on its own it does not prove that the gateway produced the contents. Anyone who can write to that row can change the bundle and its checksum together. When audit logging is on, every generated bundle also writes a created row to the audit log that records its sha256, and the audit log is covered by the hash chain. To tie a bundle to its generation, compare its checksum with that audit row and check that the chain verifies over the period that contains it.

curl -s "http://localhost:4000/compliance/evidence/bundle?evidence_id=$ID" -H "Authorization: Bearer $SPANWAY_API_KEY" \
| python3 -c 'import hashlib, json, sys
bundle = json.load(sys.stdin)["bundle"]
print(hashlib.sha256(json.dumps(bundle, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()).hexdigest())'

Reads are open to proxy admins and admin viewers, and generation needs a proxy admin. A custom role can open them to other people too: a role that grants compliance.read lists, downloads and verifies bundles, and a role that grants compliance.write as well can generate them. compliance.write covers only the changes, so grant both to an auditor who also generates bundles. A custom role built on proxy_admin_viewer can take reads away by denying compliance.read. Every generation is written to the audit log as created, and every download as exported, against Spanway_ComplianceEvidenceTable.

Scheduled bundles​

Turn on scheduled bundles when your auditor expects fresh evidence every week or month without anyone remembering to click Generate. Set compliance_evidence_interval under general_settings to a duration such as 7d or 30d to store a bundle automatically. It is unset by default, which means bundles are made only when someone generates one. Each scheduled bundle costs one evidence query run against the database and the storage of one bundle, and a proxy admin changes it in the config file or through /config/field/update. A background job checks hourly and, once the interval has passed since the last scheduled bundle, generates a new one over the last 90 days and writes a created audit row for it with compliance_evidence_schedule as the actor. Manually generated bundles do not move the schedule. With Redis configured, the pods share a lock and only one of them generates the bundle. Without Redis there is no shared lock, so on a deployment with several pods each pod can store its own scheduled bundle for the same interval.

general_settings:
compliance_evidence_interval: 7d

Bundles are kept until maximum_compliance_evidence_retention_period deletes them, counted from when they were generated, or forever when it is unset. A bundle's change history names who changed what, so a data subject request exports the bundles that name the subject, and erasure replaces created_by with the pseudonym but leaves the bundle unchanged so its SHA-256 still verifies.

Admin UI​

The Evidence tab of the Compliance page lists stored bundles with their checksum, generates a new one over a chosen window, and downloads the JSON bundle or the HTML report.

API​

MethodPathWhoPurpose
GET/compliance/evidenceProxy admin, admin viewer, compliance.readList stored bundles, newest first, with page and page_size.
POST/compliance/evidence/generateProxy admin, compliance.writeGenerate and store a bundle over window_days.
GET/compliance/evidence/bundleProxy admin, admin viewer, compliance.readDownload one bundle as JSON with checksum_valid.
GET/compliance/evidence/reportProxy admin, admin viewer, compliance.readDownload one bundle as an HTML report.

Errors​

StatusMessageMeaning and fix
403The 'compliance_evidence' feature needs a Spanway enterprise license. You must be a Spanway Enterprise user to use this feature. ...The gateway has no valid Enterprise license. Set SPANWAY_LICENSE.
403Your Spanway license does not include the 'compliance_evidence' feature. Contact sales@spanway.ai to add it.The license is valid but does not list compliance_evidence.
403Only proxy admins can read this resourceReads need a proxy admin, an admin viewer or a custom role with compliance.read.
403Only proxy admins can change this resourceGeneration needs a proxy admin or a custom role with compliance.write.
404evidence bundle <id> not foundThe id is wrong, or retention deleted the bundle.
409stored evidence bundle does not match its checksumThe stored row changed after generation. Treat the bundle as damaged, check the audit log for the created row and generate a new one.
500DB not connectedSet DATABASE_URL.

Logs​

LevelLineMeaning
INFOcompliance: stored scheduled evidence bundle <evidence_id>The schedule set by compliance_evidence_interval stored a new bundle. Normal.
DEBUGCompliance evidence exports are an Enterprise Feature. Skipping...compliance_evidence_interval is set but the license does not include compliance_evidence, so no bundle is scheduled. Add the feature to the license or unset the interval.