Skip to main content

Compliance and data governance

The compliance module scores the running gateway against a catalogue of regulatory and security regimes, and gives you the controls to fix what fails. It manages retention periods for the tables listed under Retention, a data residency policy, and data subject export and erasure. Compliance controls are an enterprise feature, and every /compliance route returns 403 without a license, except the two per-request checks below, which are free. Read routes need a proxy admin or admin viewer, and routes that change data need a proxy admin. A licensed custom role opens them to other people too: compliance.read opens the read routes, and compliance.write opens the routes that change data or run a request.

A real-world scenario​

A customer of yours asks, under GDPR, for every piece of data you hold about them and then for it to be deleted. Their id in your app is customer-42, which your app sends as the user field. The privacy officer exports the data to send to the customer, erases it once the customer confirms, and keeps the request history as proof that it was done within the deadline.

Steps​

  1. In the Admin UI open Settings, then Compliance, and select the Data Subject Requests tab.

  2. Set Subject type to End user (customer), type customer-42 in Subject id and click Export data. The Export ready dialog lets you save the file. The API call is the same.

    curl -X POST http://localhost:4000/compliance/data_subject/export \
    -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
    -d '{"subject_type": "end_user", "subject_id": "customer-42"}'
  3. When the customer confirms, click Erase data, type the id again in Type the id to confirm and click Erase data in the dialog.

    curl -X POST http://localhost:4000/compliance/data_subject/erase \
    -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
    -d '{"subject_type": "end_user", "subject_id": "customer-42", "confirm": true}'
  4. Check the requests table under the form on the same tab (columns Requested, Subject, Status and Summary), or list the requests with the API.

    curl "http://localhost:4000/compliance/data_subject/list" -H "Authorization: Bearer $SPANWAY_MASTER_KEY"

Expected result​

The export holds every row about the subject with secrets left out. After the erasure, the spend log rows name the subject as erased:<16 hex characters> with their prompts and responses emptied, and the history lists both requests as completed, or as partial when Lens could not be reached.

Regime catalogue​

Each regime is a list of controls. Every control cites the article or section it maps to and names an evaluator that checks the live configuration, so the score always reflects what is actually running.

Regime idRegimeControls
gdprEU General Data Protection Regulation15
uk_gdprUK GDPR and Data Protection Act 201813
ccpa_cpraCalifornia Consumer Privacy Act as amended by the CPRA11
hipaaHIPAA Security Rule13
eu_ai_actEU Artificial Intelligence Act11
soc2SOC 2 Trust Services Criteria13
iso_27001ISO/IEC 27001:2022 Annex A13
pipedaPersonal Information Protection and Electronic Documents Act (Canada)10
lgpdLei Geral de Protecao de Dados (Brazil)11
pdpa_sgPersonal Data Protection Act 2012 (Singapore)11
au_privacy_actPrivacy Act 1988 (Australia), Australian Privacy Principles11

The score is an evaluation of gateway configuration only. It helps you collect evidence for an audit, and it is not a certification. To hand your auditors a checksummed bundle mapped to ISO/IEC 42001 and SOC 2, see Compliance evidence export.

Evaluators​

EvaluatorPasses when
spend_log_retention_configuredmaximum_spend_logs_retention_period is set.
audit_logging_enabledA database is connected, store_audit_logs is on, and the audit log table exists.
audit_log_retention_configuredmaximum_audit_log_retention_period is set. Not applicable when audit logging is off.
prompts_not_stored_or_maskedstore_prompts_in_spend_logs is off, or a PII masking guardrail runs pre_call.
pii_masking_pre_callA PII masking guardrail (such as Presidio, Lakera or secret detection) runs pre_call.
residency_policy_enforcedrequired_model_region is set and enforced on every request, and nothing contradicts it.
provider_data_policy_enforcedAt least one active key (not blocked or expired), team or organization requires zero data retention, forbids training or restricts code traffic. A policy that sets only allowed_regions counts toward data residency instead. The evidence counts the deployments that qualify and the undeclared ones the router excludes. Not applicable without a database.
sso_configuredGoogle, Microsoft or generic OIDC SSO is configured.
master_key_not_defaultA master key is set and is not a known default.
env_credential_login_disableddisable_env_credential_login is on.
custom_roles_in_useAt least one custom role exists.
dsar_capability_licensedThe data subject endpoints are licensed.
tls_on_public_urlPROXY_BASE_URL starts with https://. Not applicable when unset.
external_logging_sinkAt least one logging callback ships request logs to an external system.
rate_limits_configuredAt least one key or team carries an rpm_limit or tpm_limit.
red_team_completedThe latest completed red team run finished within the last 90 days, withstood at least one attack and its worst finding is rated below high, so a single attack that leaked a credential or customer record fails it. The evidence names that run with its target model, pass rate, average CVSS score and severity and its worst finding, and says why it does not count when it fails. Not applicable without a database.

Each control result has a status of pass, fail or not_applicable and an evidence string such as maximum_spend_logs_retention_period is unset, request logs are kept forever. The report summary has total, passed, failed, not_applicable and score, which is the percentage of applicable controls that pass.

Endpoints​

MethodPathSummary
POST/compliance/eu-ai-actCheck one logged request against the EU AI Act
POST/compliance/gdprCheck one logged request against GDPR
POST/compliance/data_subject/exportExport everything held about a person
POST/compliance/data_subject/eraseErase a person's data
GET/compliance/data_subject/listList data subject requests
GET/compliance/retentionRead the retention periods
PATCH/compliance/retentionSet or clear retention periods
POST/compliance/retention/runRun the retention cleanup now
GET/compliance/residencyCheck data residency
PATCH/compliance/residencySet the required model region
GET/compliance/controlsEvaluate the compliance controls
GET/compliance/reportBuild the compliance report
POST/compliance/report/snapshotStore a compliance report snapshot
GET/compliance/report/historyList stored compliance snapshots
GET/compliance/evidenceList stored compliance evidence bundles
POST/compliance/evidence/generateGenerate a new compliance evidence bundle
GET/compliance/evidence/bundleDownload one compliance evidence bundle as JSON
GET/compliance/evidence/reportDownload one compliance evidence bundle as a printable report

Reports​

curl "http://localhost:4000/compliance/report?regime=gdpr" -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
{
"regimes": ["gdpr"],
"evaluated_at": "2026-10-14T11:00:00Z",
"controls": [
{"id": "gdpr.storage_limitation", "regime": "gdpr", "title": "Request logs expire", "citation": "Art. 5(1)(e)", "evaluator": "spend_log_retention_configured", "status": "pass", "evidence": "maximum_spend_logs_retention_period=30d"}
],
"summary": {"total": 15, "passed": 12, "failed": 2, "not_applicable": 1, "score": 85.7}
}

regime defaults to all. POST /compliance/report/snapshot stores the current report, and GET /compliance/report/history lists stored snapshots newest first, so auditors can see how the posture changed.

Retention​

curl -X PATCH http://localhost:4000/compliance/retention \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"maximum_spend_logs_retention_period": "30d", "maximum_audit_log_retention_period": "365d"}'

Retention covers exactly these tables. Any other table, including the daily user, team and organization spend rollups, is kept until you delete it. The Retention tab on the Compliance page shows each period and, for a period with a built-in default such as the Cloud tenant one, what applies while it is unset.

PeriodTableRows it expires
maximum_spend_logs_retention_periodSpanway_SpendLogsRequest logs, including prompts and responses when store_prompts_in_spend_logs is on, together with the tool lookup (Spanway_SpendLogToolIndex) and guardrail lookup (Spanway_SpendLogGuardrailIndex) rows that point at them.
maximum_autorouter_session_retention_periodSpanway_AutoRouterSessionAuto-router benchmark session rollups, the per-user session rollups in Spanway_AutoRouterUserSession and the daily rollups in Spanway_AutoRouterDailySpend.
maximum_health_check_retention_periodSpanway_HealthCheckTableModel health check rows.
maximum_daily_tag_spend_retention_periodSpanway_DailyTagSpendPer-day tag spend aggregates.
maximum_audit_log_retention_periodSpanway_AuditLogAdministrative audit log entries.
maximum_memory_retention_periodSpanway_MemoryTableStored memories, which may name users.
maximum_online_eval_score_retention_periodSpanway_OnlineEvalScoreTableOnline eval scores, which may carry a judge's reason. They never outlive spend logs, since the shorter of this period and the spend log period applies.
maximum_eval_feedback_retention_periodSpanway_EvalFeedbackEnd-user feedback, ratings and comments on requests. Never kept longer than spend logs.
maximum_eval_dataset_retention_periodSpanway_EvalDatasetTableEval dataset items copied from spend logs or sessions, which are also removed from the stored dataset versions. Items typed in or imported are kept. Never kept longer than spend logs.
maximum_eval_review_retention_periodSpanway_EvalReviewItemTableHuman review items and their labels, copied from requests and eval results. Their age counts from the logged request, so they never outlive spend logs either.
maximum_workflow_run_retention_periodSpanway_WorkflowRunWorkflow runs with their steps, step attempt history, dead letters, events and messages, counted from their last update, and pinned test data, counted from when it was saved. They never outlive spend logs, and a run the workflow runner is still driving (before its deadline, or while a step holds a live lease) is kept.
maximum_custom_agent_run_retention_periodSpanway_CustomAgentRunCustom agent runs with their events and transcripts. They never outlive spend logs.
maximum_workflow_trigger_fire_retention_periodSpanway_WorkflowTriggerFireWorkflow trigger fire history, counted from when the fire arrived. It never outlives spend logs.
maximum_approval_request_retention_periodSpanway_ApprovalRequestSettled human approval requests with their lanes and decisions. Pending requests and grants that have not expired are kept.
maximum_environment_record_retention_periodSpanway_EnvPlanEnvironment plans past their expiry, with their bundles, and the export records. A plan that is being applied is kept.
maximum_code_index_run_retention_periodSpanway_CodeIndexRunTableFinished code graph index runs, which name the admin who queued them. Queued and running runs are kept.
maximum_cloud_closed_tenant_retention_periodSpanway_CloudTenantTableSpanway Cloud only. A cancelled tenant keeps its email, company, legal name, address, password hash and saved card until this period has passed since it closed, then they are blanked. A signup never verified is deleted once the period has passed since its last update. Tenants under a sanctions hold are kept. Cloud applies 90d when this is unset, and a self-hosted gateway has no tenants, so it does nothing there.
maximum_deleted_record_retention_periodSpanway_DeletedVerificationTokenThe archives of deleted keys and of deleted teams (Spanway_DeletedTeamTable), counted from deletion. They name key owners, team members and who deleted them.
maximum_access_request_retention_periodSpanway_AccessRequestTableSettled access requests of every type (keys, model access, team seats and budget increases), counted from their last update. Pending requests are kept, and a request stuck in applying counts as settled.
maximum_eval_run_retention_periodSpanway_EvalRunTableFinished eval runs with their results and transcripts, which copy model outputs and whole conversations. Once set, the shorter of this period and the spend log period applies, and pending or running runs are kept.
maximum_red_team_run_retention_periodSpanway_RedTeamRunTableFinished red team runs with the attack inputs and model outputs of their results. Once set, the shorter of this period and the spend log period applies.
maximum_error_log_retention_periodSpanway_ErrorLogsLegacy error logs, which the gateway no longer writes but which may still hold request bodies from older versions. Once set, the shorter of this period and the spend log period applies.
maximum_code_repo_retention_periodSpanway_CodeRepoTableDisconnected code graph repositories, which keep the repository name and who connected and last changed them. Counted from when their index rows were removed, and their index runs go with them. Connected repositories, and disconnected ones whose index rows are still waiting to be removed, are kept.
maximum_managed_file_retention_periodSpanway_ManagedFileTableManaged files, counted from upload, and the file bytes the spanway_db storage backend keeps in Spanway_ManagedFileContentTable. Copies already uploaded to a provider are not deleted, so delete those through DELETE /v1/files/{file_id} first.
maximum_adaptive_router_session_retention_periodSpanway_AdaptiveRouterSessionAdaptive router session state, counted from the session's last activity. Message content is never stored there.
maximum_compliance_snapshot_retention_periodSpanway_ComplianceSnapshotTableCompliance report snapshots, counted from when they were taken. They name the admin who took them.
maximum_compliance_evidence_retention_periodSpanway_ComplianceEvidenceTableEvidence bundles, counted from when they were generated. Their change history names who changed what.
maximum_data_subject_request_retention_periodSpanway_DataSubjectRequestTableThe data subject request log, counted from each request.
maximum_invitation_retention_periodSpanway_InvitationLinkInvitation links, accepted or not, counted from when the link expired. They name the invited user and who invited them.
maximum_sanctions_record_retention_periodSpanway_SanctionsEventTableSanctions screening cases, decisions, report tasks and the event log. A period shorter than 3653 days (10 years) is refused, and the cleanup job never deletes these rows, so the period is a record of how long you keep them.

Send null to clear a period. Every period in one request is saved together or not at all: when one of them is set in config.yaml, nothing changes and the answer is 400, so fix or remove that key and send the request again. The change writes one audit row with object_id general_settings and the before and after value of each period you sent.

The response lists each period with its field, table, description, value and seconds, plus last_run_at for the cleanup job. effective_seconds is the period the cleanup job really applies and capped_by_spend_logs is true when the request log period shortens it. For example, with request logs at 30d and no period for end-user feedback, feedback still shows effective_seconds of 30 days, because tables that copy prompts and answers never outlive the request logs. Sanctions records have no effective_seconds, because the cleanup job never deletes them.

A period is a number with s, m, h, d, w or mo, such as 90d. In config.yaml a bare number such as 30 also works and counts as days, the cleanup job logs a WARNING asking you to write 30d, and the API and the Retention tab show it as 30 days too. The API itself only takes the text form.

When the cleanup runs​

The cleanup job runs once a day by default. Two general_settings keys change that, and both can be set in config.yaml or under Router Settings, General in the Admin UI, where a change applies without a restart.

SettingDefaultWhat it does
maximum_spend_logs_retention_interval1dHow often the job runs, such as 6h or 1d.
maximum_spend_logs_cleanup_cronunsetA crontab such as 0 3 * * * for 03:00 UTC every day. When set it wins over the interval.

A value that cannot be read logs an ERROR and leaves the job unscheduled, so no data is deleted until it is fixed. Four environment variables set how much one run may do, and the matching general_settings keys in the settings reference override them.

Environment variableDefaultWhat it does
SPEND_LOG_CLEANUP_BATCH_SIZE1000Rows deleted per statement.
SPEND_LOG_RUN_LOOPS500Statements per table per run.
SPEND_LOG_CLEANUP_RUN_BUDGET_SECONDS300Wall clock budget for one run across every table. The next run continues where this one stopped.
SPEND_LOG_CLEANUP_BATCH_TIMEOUT_SECONDS30Statement and lock timeout of each delete.

Run the cleanup now​

POST /compliance/retention/run runs the job once immediately and reports what it deleted per table with ran set to true. When no period is set it answers ran false. When another gateway instance is running the job at that moment it answers 409, and when the run fails it answers 500 with the error class, so retry later or read the gateway log. Each run writes an audit row with object_id retention:run and the per table counts, so you can see who started it. The action is deleted when the run removed rows and invoked when it found nothing to delete. Scheduled runs are not audited, their result is in the logs and metrics below.

curl -X POST http://localhost:4000/compliance/retention/run -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
{"ran": true, "results": [{"table_name": "Spanway_SpendLogs", "rows_deleted": 1840, "stop_reason": "exhausted"}]}

Reading and changing retention needs the compliance license feature. Reads are open to proxy admins and admin viewers, and changes and runs to proxy admins. A custom role that grants compliance.read can read the periods, and one that grants compliance.write can read them, change them and run the cleanup. Admin viewers can only read.

Data residency​

PATCH /compliance/residency sets required_model_region to eu, uk, ch, us, ca or apac, or null to clear it, and enforce turns its enforcement on or off. A field you leave out keeps its stored value.

curl -X PATCH http://localhost:4000/compliance/residency \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"required_model_region": "eu", "enforce": true}'

With enforce off, which is the default, required_model_region only drives the report, and routing enforces each end user's allowed_model_region and each key, team or organization data_policy.allowed_regions. With enforce on, the gateway also holds every request to required_model_region, as if every key carried it. The setting is stored as general_settings.enforce_required_model_region. Clearing required_model_region while enforce is on is refused with a 400. If the region is cleared or made invalid some other way, such as through /config/update, every request fails with a 500 until it is fixed, so enforcement never switches off silently. Routing checks regions on every request, whether or not enable_pre_call_checks is on, and Regions explains how a deployment's region is worked out. A deployment that declares no region never serves a request held to a region, and when no deployment of the requested model qualifies the request fails with a 400 instead of going elsewhere.

GET /compliance/residency lists what contradicts the policy, with how many of each were checked. End users, keys, teams and organizations carry a reason of missing (no region set), contradicts (no region inside the required one) or wider (some of their allowed_regions reach outside it). While enforcement is on, missing is not reported, since the gateway covers those requests. Deployments are reported only when they declare a region outside the required one. Fix them by setting model_info.data_region or a provider region, end users with allowed_model_region, and keys, teams and organizations with data_policy.allowed_regions. The residency_policy_enforced control passes only when required_model_region is set, enforcement is on and the report has no violations. One report reads at most 10,000 end users and at most 10,000 keys, teams and organizations together. end_users_checked and scopes_checked show how many were read, so a count of 10,000 means the gateway has more and the rest were not checked. Fix the reported ones first and query the database for the rest.

The same response carries a data_policy section with the number of keys, teams and organizations that require zero data retention or forbid training, and every deployment's declared data_retention, trains_on_data and region with whether it qualifies. Those requirements are enforced at routing time too, together with the end user's region. See Zero data retention and training policies.

Data subject requests​

What Spanway stores lists every store with the metadata it always keeps, when it keeps content, the retention period that deletes it and how export and erasure reach it.

curl -X POST http://localhost:4000/compliance/data_subject/export \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"subject_type": "end_user", "subject_id": "customer-42"}'

curl -X POST http://localhost:4000/compliance/data_subject/erase \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"subject_type": "user", "subject_id": "user-123", "confirm": true}'

subject_type is user (an internal user) or end_user. On Spanway Cloud an end_user subject id is read within the caller's tenant, so a tenant's caller exports or erases only its own customer of that id. Export returns everything held about the subject, with secrets such as password hashes and key values left out. For an internal user it includes their memories and model access requests, and lists their stored provider credentials, MCP credentials and MCP environment variables by provider or server and dates only, never the values. Erase deletes the subject's rows through the gateway's own deletion functions, hard-deletes the user's memories, provider credentials, MCP credentials, MCP environment variables, SSO identity assertion, model access notifications and pending MFA challenges in one transaction, keeps the user's key and model access requests under the pseudonym, and replaces their identifier in spend logs with a stable pseudonym of the form erased:<16 hex characters>, so usage totals stay correct without naming the person. The same update empties the stored prompt (messages), response and full proxy request of each of those spend log rows and clears the requester IP address. The pseudonym is an HMAC-SHA256 of the identifier keyed with SPANWAY_SALT_KEY, or the master key when that is unset, so it cannot be reversed by hashing guessed emails or user ids and differs between deployments with different keys. Erase is refused with a 500 when neither key is configured. Human review items copied from the subject's requests are deleted along with the golden dataset items exported from them, and an internal user's review labels are kept under the pseudonym, as Human review describes. Export includes those review items and labels. An internal user's custom agent runs are deleted, and so are the workflow runs that acted as them or that their keys stored, while a workflow run with a step still running is cancelled, scrubbed and pseudonymised. Export includes those runs. Their private workflow definitions that no other definition pins are deleted, and every other definition or version they own or wrote names them only by pseudonym. Export includes those definitions. Their workflow template installs are kept and name them only by pseudonym, and the idempotency keys their keys sent are dropped. Export includes those installs. Workflow pins the user or one of their keys owns, and pins copied from a run that acted as them, are deleted, and export includes them with their content when the gateway can still decrypt it. The managed files an internal user uploaded are deleted with the bytes the spanway_db storage backend kept for them, and export lists them with their size. Copies already uploaded to a provider stay there until you delete them through DELETE /v1/files/{file_id}. Auto-router session rollups for the subject are deleted and their daily auto-router rollups are kept under the pseudonym, and export includes both. Billing accounts whose billing_email is an internal user's email, compared without case, or that they created are exported, and erase clears that billing_email and replaces created_by with the pseudonym. For an end user, the billing account over that end user is exported and its billing_email cleared. The accounts and their invoices are kept as financial records, and the email held by Stripe on the account's customer is not changed. Status page incidents an internal user opened are exported, and erase keeps the incidents but names their creator by the pseudonym. Saved queries and charts an internal user owns, created or last changed are exported, and erase deletes the ones they own and names them by the pseudonym on the others. Eval dataset items copied from the subject's requests are exported, and the online scores of their requests and keys are exported and deleted by erase. If an erase fails after the user row is gone, running it again with the same key finishes the remaining deletes and pseudonymisation. Erasing a proxy admin, or yourself, is refused. Every request, including refusals, an export of a subject that does not exist and a Cloud caller outside any organization, is recorded and listed by GET /compliance/data_subject/list. On Spanway Cloud a caller who is not a proxy admin sees only the end user requests of its own organization in that list, and its subject_id filter is read within that organization. Every recorded request writes created on Spanway_DataSubjectRequestTable, and an export also writes exported with the export ledger fields, so reads of personal data can be filtered. A team that receives requests by email or a web form can triage them with the data subject request intake template before an admin runs the export or erasure here.

The rows that only count or archive what the subject did are handled too. Their per-day spend rollups (Spanway_DailyUserSpend, or Spanway_DailyEndUserSpend for an end user) and per-day error counts (Spanway_DailyRequestErrors) move to the pseudonym, so spend and error totals stay correct. When the pseudonym already has a row for the same day and key, because the same identifier was erased before, the counts are added to it. The archive of the user's earlier deleted keys (Spanway_DeletedVerificationToken) is deleted, and archived keys the user created, updated or deleted name them only by pseudonym. Archived teams (Spanway_DeletedTeamTable) drop the user from their admins and members and name whoever deleted them by pseudonym. Managed vector stores the user created stay with their team and name the user by pseudonym. Alerts about the user (Spanway_AlertInboxTable) and alerts they acknowledged, own or resolved name them only by pseudonym. The comments the user wrote on agent traces (Spanway_TraceComment) are deleted, counted as trace_comments_deleted, and an export lists them under trace_comments. Legacy error logs (Spanway_ErrorLogs) whose stored request names the subject are deleted. Eval results and transcripts produced for the dataset items the erasure removes are deleted with them. Export lists all of these rows, together with the user's linked SSO identities, MFA enrolment (dates and how many recovery codes are left, never the secret), invitation links (never the link token) and archived keys without the key hash.

The tool registry remembers which key and app first called each tool. Export lists the tools the user's keys discovered, with the key alias and user agent, and erasure clears the key hash, key alias and user agent on those tools while keeping the tools and their policies. The erase answer counts them in tool_discoveries_cleared. Skill scan results name the user who uploaded each skill or plugin: export lists them under skill_scans, and erasure replaces that user id with the pseudonym, counted in skill_scans_pseudonymised.

Records that exist to prove what happened are handled this way.

RecordExportErase
Audit log rowsRows about the subject and rows they made.Earlier rows are hash chained and stay until maximum_audit_log_retention_period removes them. The erasure itself writes one row naming the subject only by pseudonym, with no copy of the deleted user or end user and {"reason": "data_subject_erasure"} as its value, and writes no rows for the keys it deletes.
Compliance snapshotsSnapshots the subject took.created_by is replaced with the pseudonym.
Evidence bundlesBundles the subject generated or whose change history names them.created_by is replaced with the pseudonym. The bundle itself is left as it is so its SHA-256 still verifies, and maximum_compliance_evidence_retention_period bounds how long it keeps the subject's name.
The data subject request logThe subject's earlier requests.Every request about the subject, and the erasure itself, is recorded under the pseudonym, so the log no longer holds the identifier. Refused erasures keep it, since nothing was erased.
Sanctions cases, decisions, report tasks and events on Spanway CloudNot included.Not touched, see record retention. Handle a request for that data separately, with counsel's advice.

Cloud tenant audit entries never carry the tenant's email or address in the first place.

For an internal user who signed up on Spanway Cloud, export also returns the tenant rows they own or whose signup email is theirs, with the company, legal name and address, and never the password hash, verification token or saved card. Erasing the owner of a tenant that is still active or suspended is refused with a 409, so close the workspace first. Erasing the owner of a cancelled tenant, or the email of a signup never verified, blanks those details at once instead of waiting for maximum_cloud_closed_tenant_retention_period. A tenant under a sanctions hold keeps them, because sanctions records must be kept, and the summary counts it as cloud_tenants_held_for_sanctions.

Export and erase also reach Lens, which keeps its own copies of request logs and traces in ClickHouse. Export returns up to 1,000 Lens request logs and 1,000 spans for the subject, read through CLICKHOUSE_URL when the gateway has it, or through the Lens service otherwise, whose reader does not see the spans of Lens eval runs. Erase deletes, by user id and email (or end user id), the Lens request logs, call costs, feedback, trace summaries, eval and agent trace rollups, every span of a trace the subject took part in, and the subject's own spans. It counts each table again after its delete, so lens_status is completed only when nothing is left. The gateway sends the erasure to the Lens service through SPANWAY_LENS_URL and SPANWAY_LENS_SERVICE_TOKEN, and Lens deletes with its own ClickHouse user, so no ClickHouse credentials are needed on the gateway. A gateway that has CLICKHOUSE_URL deletes through it directly instead, with a user allowed to ALTER TABLE ... DELETE on the Lens database (CLICKHOUSE_DATABASE). When Lens cannot be reached or does not confirm the delete, the gateway rows are still erased, lens_status is failed, lens_error says why, and the request is recorded with status partial instead of completed. Fix the connection and run the same erasure again to finish Lens. An export that could not read Lens is recorded as partial the same way. With no Lens and no ClickHouse configured, lens_status is not_configured and the request completes.

With cloud.enabled, end users are stored per tenant as <organization_id>/<id>, so two organizations that send the same end user id have two separate end users, and erasing one never touches the other. Only end users written before tenant scoping, or on a self-hosted gateway shared by several organizations without cloud tenancy, share one row per id. On such a gateway erasing that end user erases it for every organization, so use end user ids that are unique to one organization, for example prefixed with it.

Closed Cloud workspaces​

On Spanway Cloud a job runs every day at 01:30 UTC and erases each workspace closed for longer than maximum_cloud_closed_tenant_retention_period (90 days by default). Members who belong only to that workspace and the workspace's end users are erased the same way as above, each recorded as a data subject erasure by spanway-cloud-retention, and members of other workspaces only lose the membership. Then the workspace's keys, request logs with their prompts, files, teams and the organization row are deleted, and one audit row is written per workspace on Spanway_OrganizationTable with the counts. A workspace under a sanctions hold is skipped. Lens copies of the erased users and end users are erased with them, while Lens copies of requests made with the workspace's service keys alone stay until Lens retention removes them.

Per-request checks​

POST /compliance/gdpr and POST /compliance/eu-ai-act check a single spend log entry, for example whether pre-call guardrails ran and whether the audit record is complete. They are part of the free gateway and need no license.

The Compliance page in the Admin UI shows the report, the retention and residency settings, and the data subject request history. Each tab checks the license feature it needs, compliance for most tabs and compliance_evidence for Evidence, and shows a notice naming the missing feature instead of failing lists. The Sanctions tab always shows the gateway's jurisdiction policy, which is free, and explains that name screening runs only on Spanway Cloud when the gateway is not a Cloud deployment or its license lacks cloud.

Errors​

Compliance routes answer errors as {"detail": {"error": "<message>"}}.

StatusMessageMeaning and fix
403The 'compliance' 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. The per-request checks still work without it.
403Your Spanway license does not include the 'compliance' feature. Contact sales@spanway.ai to add it.The license is valid but does not list compliance. Ask for a license that includes it.
403Only proxy admins can read this resourceThe caller is not a proxy admin, an admin viewer or a custom role holding compliance.read. Use such a key.
403Only proxy admins can change this resourceThe caller is not a proxy admin or a custom role holding compliance.write. Admin viewers can only read.
403On Spanway Cloud only a caller in an organization can act on its end usersA Cloud caller without an organization tried an end user request. Use a key of the tenant's organization.
400a caller cannot erase itselfUse another admin account to erase this user.
400user_id=<id> is a proxy admin, demote the user before erasing itChange the user's role first, then erase.
400no retention period givenThe retention update had no periods. Send at least one.
400general_settings key '<field>' is set in the config file and cannot be changed here.That period comes from config.yaml, so nothing in the request was saved. Change it in the file, or remove it there to manage it from the API.
422Value error, retention period must be positive, got '0d' or another period that cannot be readSend a number with s, m, h, d, w or mo, such as 90d.
422Value error, sanctions records must be kept at least 10 years (3653d) under ...The sanctions period is below the legal minimum. Send 3653d or longer.
409Another gateway instance is running the retention cleanup now. Try again when it finishesA run is already in progress on another replica. Wait and run again.
500The retention cleanup failed with <ErrorClass>. Check the gateway logs and retryThe run stopped on an error. The log line Error during spend log cleanup names the cause, often a database timeout.
400required_model_region cannot be empty while it is enforced, so send a region or turn enforcement off in the same changeSend a region, or send "enforce": false in the same request when clearing it. The same message comes from /config/update and /config/field/update.
404user_id=<id> not found or end user user_id=<id> not foundErase found nothing for that id. The subject id is wrong. On Spanway Cloud enter the end user id as the Customers page lists it.
404<subject_type> <id> not found, for example end_user acct-48213 not foundExport found nothing for that id. The request is recorded as failed. Check the id.
409user_id=<id> owns Cloud tenant <tenant_id>, which is still open. Close the workspace before erasing its ownerClose the workspace first, then erase its owner.
500erasure needs SPANWAY_SALT_KEY or a master key to derive pseudonymsSet SPANWAY_SALT_KEY.
500DB not connectedSet DATABASE_URL.

Logs​

LevelLineMeaning
INFOcloud: erased closed workspace tenant=<tenant_id> users_erased=<n> users_refused=<n> end_users_erased=<n> end_users_refused=<n> keys=<n> request_logs=<n> files=<n> teams=<n>The daily job erased one closed workspace. Normal. A refused count above 0 means someone, usually a proxy admin, was kept, so check the data subject request list for the failed rows.
INFOcloud: another pod is erasing closed workspaces, skippingAnother gateway replica holds the job lock. Normal when several replicas run.
INFOSpend log cleanup run finished: outcome=completed elapsed=<s> [<table>: deleted=<n> stop_reason=<reason>, ...]A retention cleanup run finished every table it had to clean. Normal.
WARNINGSpend log cleanup run finished: outcome=budget_exhausted (or batch_cap_reached, aborted)The run stopped early because its time budget or statement cap ran out, or a delete failed. The next run continues. Action needed only when it repeats every run, then raise maximum_spend_logs_cleanup_run_budget or run the cleanup more often.
INFOAnother pod is already running cleanupAnother replica holds the cleanup lock, so this one skipped. Normal with several replicas.
ERRORError during spend log cleanup: <ErrorClass>: <message>The run failed, usually on a database timeout. Check the database and the message, the next run tries again.
ERRORInvalid maximum_spend_logs_retention_interval value: <value> or Invalid maximum_spend_logs_cleanup_cron value: <value>The schedule cannot be read, so the cleanup job is not scheduled and nothing is deleted. Fix the setting.
WARNING<setting> is an integer (<n>); treating as days. Use a string like '3d' to be explicit.A period in config.yaml is a bare number. It works as days, write it as <n>d to silence this.
WARNINGInvalid <setting> value: <value>A period cannot be read, so that table is not cleaned. Fix the value.
WARNINGCould not record the spend log cleanup last run time: <error>The run happened but the Retention tab's last run time was not updated. Check the database.
WARNINGCould not expire log-derived eval dataset items: <error>Dataset items copied from logs were not cleaned this run, the other tables were. Check the message.

The job also publishes Prometheus metrics: spanway_spend_log_cleanup_runs_total by outcome, spanway_spend_log_cleanup_rows_deleted_total, spanway_spend_log_cleanup_rows_remaining, spanway_spend_log_cleanup_batch_failures_total and spanway_spend_log_cleanup_batch_duration_seconds, each by table. See Prometheus metrics.