Audit logs
The audit log answers "who changed what, and when" for everything an admin or a key does through the management API. Creating, updating, blocking or deleting keys, users, teams, team members, projects, custom roles and their assignments, organizations, organization memberships, customers, budgets, tags, guardrails, policies, agents and their kill switch, agents' stored credentials and their suspension, custom agents and custom agent runs, skills and Skills page plugins, credentials, vector stores, search tools, prompts, access groups, JWT key mappings, model deployments, the AI hub, cost tracking settings, price map reloads, personal provider connections, the encryption migration, spend and cost exports, tool policies and team or key tool blocks, MCP servers with their submissions, pins, toolsets, live sessions and the write tools enabled on them, personal MCP credentials and variables, fallbacks, memory entries, workflow runs, definitions, variables, triggers and template installs, code graph repositories and credentials, review queues and their items, approval policies, decisions and the gateway's own approval events, environment exports, plans and applies, invitations, global spend resets, fine-tuning job changes, file uploads and deletes, batch creates and cancels, code interpreter containers and their files, assistants, custom pass-through endpoints, realtime client secrets, logging destinations (gateway wide and per team), data subject exports and erasures, the scheduled erasure of closed Cloud workspaces and gateway settings all produce a row. Each row records who made the change, which object changed, and the value before and after the change, and the rows are chained with hashes so that an edit made directly in the database can be detected. Audit logging is part of Spanway Enterprise.
A real-world scenario
A team's monthly budget was raised from 500 to 750 dollars and the finance lead wants to know who did it. A proxy admin opens the Logs page, switches to the Audit Logs tab, filters on Table = Teams and the team's id, and finds the updated row with max_budget 500 before and 750 after, the admin's email and the hash of the key they used. Before the quarterly compliance review, the same admin clicks Verify chain, which recomputes every hash and reports that no row was edited or removed since the log began.
Turn on audit logging
spanway_settings:
store_audit_logs: true
You can also set SPANWAY_STORE_AUDIT_LOGS=true in the environment. When neither is set, audit logging follows the license, so it is on for licensed gateways. When it is set, rows keep being written even if the license lapses, so the chain never has a gap, but reading the log over the API needs a valid license again. A failed audit write never fails the management request that triggered it. Most rows are written in the background, while a few changes, such as bulk team member budgets, gateway settings, MCP servers and hosted admin MCP tool calls, wait for their row before they answer, so a slow audit table can slow those down.
| Setting | Where | Default | What it does |
|---|---|---|---|
store_audit_logs | spanway_settings | follows the license | On writes a row for every change, off writes none. Turn it on explicitly when the record must survive a license lapse, which is what auditors expect. Turning it off removes the trail, so only a security owner should do it. |
SPANWAY_STORE_AUDIT_LOGS | environment | unset | The same switch, used only when store_audit_logs is not set. |
audit_log_callbacks | spanway_settings | none | Also sends each row to the destinations listed, see below. |
s3_audit_callback_params | spanway_settings | unset | Bucket settings (s3_bucket_name, s3_region_name, s3_path and the other s3_callback_params keys) for the s3_v2 audit destination, so audit rows can go to a different bucket than request logs. Unset uses s3_callback_params. |
audit_webhook | general_settings | unset | Posts rows to an HTTPS endpoint, see Signed webhook. |
Read the log
-
Sign in as a proxy admin or admin viewer and open Logs, then the Audit Logs tab. The table lists changes newest first, 50 per page.
-
Click Filters and narrow the list by Object ID, Changed By, Team ID, Key Hash, Action or Table, then click Apply Filters.
-
Click an Object ID to open the entry. The drawer shows Table, Object ID, Changed By and API Key (Hash), then Before and After. For updates only the fields that changed are shown.
-
The same list is available from the API:
curl "http://localhost:4000/audit?table_name=Spanway_TeamTable&page=1&page_size=50" \-H "Authorization: Bearer $SPANWAY_API_KEY"Expected result:
{"audit_logs": [{"id": "8d2e5a4c-2b0f-4c11-9e3b-7d55a0c4e8f2","updated_at": "2026-11-20T09:14:02.418Z","changed_by": "admin@example.com","changed_by_api_key": "88c5a1b2e3f4d5c6b7a8f9e0d1c2b3a4f5e6d7c8b9a0f1e2d3c4b5a6f7e8d9c0","action": "updated","table_name": "Spanway_TeamTable","object_id": "team-finance","before_value": {"max_budget": 500.0},"updated_values": {"max_budget": 750.0},"previous_hash": "9a41c0d7e2b6f4a1c8d3e5f7a9b1c3d5e7f9a1b3c5d7e9f1a3b5c7d9e1f3a5b7","entry_hash": "6b1f2e3d4c5b6a798817263544536271808f9e0d1c2b3a4958677685940312ab"}],"total": 1284,"page": 1,"page_size": 50,"total_pages": 26}
GET /audit takes changed_by, changed_by_api_key, action, table_name, object_id, start_date, end_date, object_team_id, object_key_hash, search, sort_by and sort_order, with page and page_size up to 100. GET /audit/{id} returns one row. Both are available to proxy admins, view-only proxy admins and users whose custom role holds audit.read, both return previous_hash and entry_hash with each row, and both answer 403 on a gateway without a valid license.
What a row contains
| Field | Meaning |
|---|---|
id | Unique id of the audit row. |
updated_at | Database time of the change, in UTC with millisecond precision. |
changed_by | The user id of the caller, ci key <alias> for a change a CI key made, scim token <name> for a change a SCIM token made, or the proxy admin name when the caller has none. When the key's or its team's metadata has allow_spanway_changed_by_header: true, the spanway-changed-by request header is recorded instead, so a back office tool that acts for its own signed-in users can name the person behind each change. That lets the key name anyone, so only a proxy admin should set it, and only on a key used by a trusted internal service. Changes the gateway makes on its own carry a fixed actor instead: compromised_key_report for a key blocked through a leaked key report, and key_hygiene_policy for the hourly key hygiene job, workload_identity:<policy> and workload_identity_cleanup for workload identity, auto_register for JWT auto registration, and sso_proxy_admin_id, sso_role_map and org_sso for sign-in role and membership changes, system:code_graph for code graph access lost upstream, system:workflow_triggers for a trigger that turned itself off, stripe-webhook for billing changes a Stripe event caused, and billing-monthly-job for invoices the monthly billing job drafted. |
changed_by_api_key | Hash of the key that made the change. |
action | created, updated, deleted, blocked, unblocked, rotated, exported, kill_switch_fired, viewed for a read of request logs, prompts or spend data and when someone reads stored prompt or response content (a span with its input and output, a trace SQL query, another caller's custom agent transcript), revealed for an audited reveal of a hidden log field, or invoked for a hosted admin MCP tool call (filter by the Admin MCP tools table, since the action is shared) and for a policy replay (object_id simulate:<policy> on Spanway_PolicyTable, with the replay request and its counts, never the replayed prompts) and for a request inspector dry run (object_id inspect:<model> on Spanway_VerificationToken, with the resolved model, whether the key may call it and each guardrail's verdict, never the messages; when a proxy admin dry runs as another key, the row is by the admin and adds inspect_as_key and inspect_as_key_alias). Switching a policy attachment between enforce and audit writes updated on Spanway_PolicyAttachmentTable. |
table_name | The table of the changed object, for example Spanway_TeamTable, Spanway_Config for gateway settings, Spanway_UISettings for the Admin UI switches on UI Settings, Spanway_MCPUserCredentials for a personal MCP key, Spanway_ApprovalRequest for an approval or Spanway_EnvPlan for an environment plan. |
object_id | The id of the changed object. Settings sections use their name, for example email_settings or router_settings.fallbacks. A change to one general_settings key, from Router Settings, POST /config/field/update or the retention API, uses object_id general_settings, so filter on that and read the key in before_value and updated_values. |
before_value | JSON of the object before the change, when there was one. |
updated_values | JSON of the object after the change, when there is one. |
previous_hash | entry_hash of the row written just before this one. |
entry_hash | SHA-256 over this row and previous_hash. |
Admin viewers see the billing fields of Spanway_CloudTenantTable rows (the auto top up settings and the tenant's billing details) as REDACTED, the same marker write-time redaction uses. Proxy admins see the stored values.
Events by feature
Beyond the key, team, user, organization and model rows, these features write their own rows. None of them stores a prompt, a response or a secret.
| Feature | Table | Action | What the row holds |
|---|---|---|---|
| Agents | Spanway_AgentsTable | created, updated, deleted, kill_switch_fired | The agent before and after, with credentials, header values and the kill switch secret redacted. kill_switch_fired holds the whole kill switch result, with the key action as halt_action. Each key the switch stops writes blocked or deleted on Spanway_VerificationToken. Publishing an agent to the AI hub writes updated on Spanway_Config with object_id public_agent_groups. |
| Agent credentials | Spanway_AgentCredential | created, rotated, updated, deleted, blocked, unblocked, revealed | object_id <agent_id>/<credential_id>, with the name, kind, MCP server, status, version, expiry and revoke reason before and after, never the secret. updated is a revoke. blocked and unblocked are Suspend all credentials with object_id <agent_id>/suspension. revealed is the agent fetching a SaaS credential through the token exchange, with changed_by agent:<agent_id>. |
| Custom agents | Spanway_CustomAgentSpec | created, updated, deleted | The agent before and after, with its instructions replaced by their SHA-256 and length. |
| Custom agent runs | Spanway_CustomAgentRun | created, updated, viewed | created when a run starts, with the agent, its revision and its write tools. updated when someone cancels it, with the status going from running to cancel_requested. viewed when someone other than the run's caller reads its input and transcript, without the content. |
| Agent traces | Spanway_AgentTraces | viewed | object_id <trace_id>/<span_id> when a span with input or output is read, or trace_sql_query with the SQL's SHA-256 and length for a trace SQL query. |
| Prompt storage switch | Spanway_Config | updated | object_id general_settings, with the section before and after (so store_prompts_in_spend_logs changes from false to true or back), when someone turns Store Prompts in Spend Logs on or off in Logging Settings. Filter the Table on Gateway settings to find it. |
| Data subject requests | Spanway_DataSubjectRequestTable, Spanway_UserTable, Spanway_EndUserTable | created, exported, deleted | created on the request table for every recorded export and erasure, refusals included, and for an export also exported with the export ledger fields. The erasure of a user or an end user also writes deleted on its table with the pseudonym as object_id and {"reason": "data_subject_erasure"}, never the deleted row. |
| Retention periods | Spanway_Config | updated, deleted, invoked | updated with object_id general_settings for every PATCH /compliance/retention, one row per request, holding only the periods sent, before and after. A manual POST /compliance/retention/run that deleted rows writes deleted with object_id retention:run and the rows deleted per table. A manual run that found nothing to delete writes invoked with the same object_id and the zero counts, so the log never shows a deletion that did not happen. Scheduled cleanup runs write no row, their counts are in the logs and metrics. |
| Billing accounts | Spanway_BillingAccountTable | created, updated, deleted, blocked, unblocked | object_id is the account id, with the account before and after. Suspending writes blocked, reinstating writes unblocked, and moving to past due writes updated. |
| Billing invoices | Spanway_InvoiceTable | created, updated, exported | object_id is the invoice id. created for each generated draft, by the admin or by billing-monthly-job, updated for issue, mark paid, void and every Stripe status change, without line_items. A download writes exported. |
| Billing scope blocks | Spanway_OrganizationTable, Spanway_TeamTable, Spanway_EndUserTable | blocked, unblocked | Suspending an organization account sets its system_block_reason to billing and blocks each of its teams, a team account blocks the team, and an end user account blocks the customer. A scope already blocked for another reason is left alone and writes no row. |
| Status page incidents | Spanway_StatusIncidentTable | created, updated | object_id is the incident id. Opening writes created with the incident. An update and a resolve both write updated with the incident before and after, a resolve showing status resolved and resolved_at. |
| Admin UI sign-in | Spanway_UserTable | invoked, updated | A password sign-in writes invoked with event sign_in, outcome (succeeded, failed or locked_out), method, the username typed and the source_ip, object_id the user id when it is known and the username otherwise. When failures start a block, the gateway writes invoked with event sign_in_blocked, the scope (user for an address and username pair, source for an address), block_seconds, the username and the source_ip. A sign-out writes invoked with event sign_out. Setting a password through an invitation or reset link writes updated with event password_set_by_link and a short hash of the link, never the link or the password. A successful SSO sign-in writes invoked with event sign_in, outcome succeeded, method sso, the email as username and the source_ip, never the identity provider's tokens. Two-factor steps have their own rows, see the next line. |
| Two-factor sign-in | Spanway_UserMFA | created, rotated, deleted | object_id is the user id and mfa says what happened. Finishing setup, at sign-in or on the Change password page, writes created, replacing the recovery codes writes rotated, and turning it off or a proxy admin's POST /user/mfa/reset writes deleted, never the secret or the codes. |
| CLI sign-in | Spanway_UserTable | invoked | event cli_sign_in when spanwayctl login receives a credential, with the team_id it was issued for and expires_in_hours, never the credential. |
| Gateway OAuth sign-in | Spanway_UserTable | invoked | Credentials the gateway's own OAuth server hands out, to spanwayctl login through the browser and PKCE, to the Claude Code gateway sign-in and to MCP clients that sign in to the gateway. event is oauth_credential_issued for a new sign-in, oauth_credential_refreshed when a refresh token is swapped for a new pair and oauth_credential_revoked when a sign-out ends the refresh token, with the client_id, the audience (proxy_api, admin_mcp or session) and the team_id when there is one. object_id and changed_by are the user. Starting a Claude Code device sign-in writes oauth_device_authorization_started with the client_id and the caller's source_ip, because nobody is signed in yet. A refused or replayed grant writes no row, and no row ever holds a token. |
| Admin Assistant Slack connections | Spanway_UserTable | created | event admin_assistant_slack_connected when a proxy admin connects their Slack account, with the Slack workspace_id, slack_user_id and slack_email, the session's expires_at and the source_ip, never the session credential. |
| Admin UI plugins | Spanway_Config | updated, invoked | Adding, editing or deleting a plugin on the Plugins tab writes updated with object_id general_settings and the plugin key masked. A POST, PUT, PATCH or DELETE through /plugin-proxy/<name>/... writes invoked with object_id the plugin name, event plugin_proxy, the method, path and the status the caller received, never the body. When the plugin answers with a redirect, which the gateway refuses, status is 502 and upstream_status holds the plugin's own status. |
| Security settings | Spanway_Config | updated, deleted | object_id general_settings, for every save or reset on the Sign-in protection, Network allowlists and Data access auditing cards, like the general settings row below. |
| Closed Cloud workspaces | Spanway_OrganizationTable | deleted | By spanway-cloud-retention, object_id the organization id, with reason closed_workspace_retention, the tenant id and the counts of users, end users, keys, request logs, files and teams erased. |
| Logging destinations | Spanway_Config, Spanway_TeamTable | updated | A gateway wide change writes object_id spanway_settings (the callback list) or environment_variables (the destination credentials, every value REDACTED). A team change (POST /team/{team_id}/callback, POST /team/{team_id}/disable_logging) writes updated on the team with its metadata before and after, callback_vars redacted. |
| Alerts inbox | Spanway_AlertInboxTable | created, updated, invoked | created for each new alert by the actor usage_anomaly_scan, or online_eval_alerts for an online eval regression, with the alert. updated for acknowledge, assign and resolve, with the alert before and after. invoked for Scan now, object_id scan:<day>, with how many flags and new alerts the scan found. |
| Trace comments | Spanway_TraceComment | created, updated, deleted | object_id is the comment id. Each row holds the trace id and reference, the step, the author, the length of the text and its SHA-256 fingerprint, before and after for an edit, never the text. Comments that expire with their run are deleted by trace_comment_retention. |
| Trace search and sessions | Spanway_AgentTraces | viewed | object_id trace_search for a search that looks inside inputs, outputs or errors, with the length and SHA-256 fingerprint of the search text and the fields searched, and session:<ref> when a session is read as a thread. Both follow audit_log_content_reads, and the session list follows audit_log_list_reads. |
| Query and Explore | Spanway_SpendLogs, Spanway_AnalyticsSavedQuery | viewed, invoked, created, updated, deleted | viewed for every SQL query sent, always written, including refused, failed, timed out and busy ones, object_id analytics_query, with read analytics_query, the SHA-256 hash and length of the SQL (never the SQL), the tables, scope, outcome, row_count and truncated when it ran, error_code when it did not, the checks' reason when refused, role, ip and user_agent. invoked for each Ask AI draft, object_id analytics_query_draft, with the model, the question length and whether the draft was valid. created, updated and deleted for saved queries and charts, with the item before and after. |
| Skills | Spanway_SkillsTable | created, deleted | The new skill on create. A delete holds the id, and for a gateway-hosted skill its title, source and latest version. |
| Skill scanning | Spanway_SkillScanTable | created, blocked | object_id is the scan id. created when the scanned skill or plugin was stored, blocked when the upload or change was refused. The after value is the scan: item type, id and name, status, mode, guardrails and each file's path, verdict and reason, never the file contents. |
| Skills page plugins | Spanway_ClaudeCodePluginTable | created, updated, deleted | object_id is the plugin id. Register, replace, enable, disable and delete each hold the name, version, description, source and enabled state before and after. |
| Tool policies | Spanway_ToolTable | created, updated, deleted, exported | object_id is the tool name. A global policy change holds input_policy and output_policy before and after, and created marks a policy set for a tool no model had used yet. deleted is written by DELETE /v1/tool/{tool_name} with the tool's origin, policies, call count and team before the delete. exported is written when GET /v1/tool/{tool_name}/logs returns prompt snippets and lists the request ids shown, never the text. |
| Tool blocks for a team or key | Spanway_ObjectPermissionTable | blocked, unblocked | object_id is the tool name. Both sides hold tool_name, team_id, the hashed key_hash (a raw key sent by the caller is hashed first) and blocked. |
| MCP servers | Spanway_MCPServerTable | created, updated, deleted | The server before and after with credentials left out, see MCP events for every MCP change that writes one. Turning write tools on or off through Tool access or PUT /v1/mcp/server/{server_id}/tool-policy writes updated with the old and new enabled_write_tools. |
| Prompts | Spanway_PromptTable | created, updated, deleted | object_id is the base prompt id. Both sides hold the prompt version with dotprompt_content and prompt_data replaced by their SHA-256 and length, and a remote integration api_key masked, so the template text is never in the audit log. A delete adds deleted_versions, the versions removed in each environment. |
| Team settings | Spanway_TeamTable | updated | The team before and after. When the request changes MCP access or tool search, both sides carry object_permission with the old and new mcp_tool_search_enabled, mcp_tool_search_top_k and mcp_tool_search_similarity_threshold. |
| Team member limits | Spanway_TeamMembership | updated | object_id is <team_id>:<user_id>. The member's old and new max_budget, rpm_limit, tpm_limit, max_parallel_requests and other per member limits, with cleared listing limits that were removed. A role change also writes a Spanway_TeamTable row with the member list. |
| General settings | Spanway_Config | updated, deleted | Saving one setting through POST /config/field/update, as the Admin UI settings cards do, writes updated with object_id general_settings. Clearing one through POST /config/field/delete writes deleted with the same object_id. Both sides hold the stored general_settings before and after, with secrets redacted, so the changed key shows as added, changed or removed. Admin UI switches stored in spanway_settings use the setting name as object_id instead. |
| Response cache settings | Spanway_CacheConfig | created, updated, deleted | object_id cache_config. Saving the Cache Settings tab stores the settings before and after, such as type, host, namespace and ttl, with passwords and URLs that carry a password shown as ***REDACTED***. Turn Cache Off (DELETE /cache/settings) writes deleted with the removed settings, redacted the same way. |
| UI Settings | Spanway_UISettings | updated | object_id ui_settings, with every UI setting before and after, written by PATCH /update/ui_settings and the UI Settings tab. For example turning on the Chat page changes enable_chat_ui from false to true. Find them with GET /audit?table_name=Spanway_UISettings. |
| Coordination Redis settings | Spanway_Config | created, updated | object_id coordination_redis, with the settings before and after and password, sentinel_password and url shown as ***REDACTED***. |
| Fallbacks | Spanway_Config | created, updated, deleted | object_id router_settings.fallbacks, router_settings.context_window_fallbacks or router_settings.content_policy_fallbacks, with that list before and after. Written by POST /fallback and DELETE /fallback/{model}. A refused change writes no row. |
| Data policies | Spanway_VerificationToken, Spanway_TeamTable, Spanway_OrganizationTable, Spanway_ProxyModelTable, Spanway_Config | created, updated | A key, team or organization data_policy is in that entity's row under metadata.data_policy, a deployment's data terms in its model row under model_info, and required_model_region and enforce_required_model_region in the general_settings row, each before and after. |
| Response cache delete and flush | Spanway_CacheConfig | deleted | object_id response_cache. POST /cache/delete stores operation delete, entries_requested and entry_sha256, the SHA-256 of each requested cache key (up to 100), never the keys themselves. POST /cache/flushall stores operation flushall and deleted_entries, the number of cached responses removed. A refused call writes no row. |
| Admin UI logo upload | Spanway_Config | created | object_id ui_logo:<file name>, with the image media_type and file_size in bytes, never the image. Saving the theme that uses it writes its own updated row with object_id ui_theme_config. |
| Router settings | Spanway_Config | updated | object_id router_settings, written by every save of POST /config/update that carries router_settings, including the Loadbalancing, Routing Groups and Fallbacks tabs. Both sides hold the stored router settings before and after with secrets redacted, so a cleared setting shows as removed. Saves of general_settings, spanway_settings and environment_variables write rows with those names, and every value of environment_variables is redacted. |
| Secret manager connections | Spanway_ConfigOverrides | created, updated, deleted | object_id hashicorp_vault or cyberark. Before and after keep the plain fields, such as the address, mount, path prefix, namespaces, account, username, ssl_verify and refresh_interval, and show ***REDACTED*** for the token, AppRole secret id, API key and client key. Test Connection writes no row, and deleting when nothing is stored writes none either. |
| Tool search defaults | Spanway_Config | updated | object_id mcp_tool_search, with the old and new spanway_settings.mcp_tool_search. |
| Hosted admin MCP | Spanway_AdminMCPTool | invoked | The tool, whether it reads, its outcome and status, the MCP client, the caller's ip, the request_id when the client sent one, and the hash of the caller's key in changed_by_api_key, never the arguments or the result. An OAuth session the gateway refuses before any tool runs, for an address outside a team or organization allowed_ips, a user who is no longer active or allow lists it cannot read, writes invoked with object_id oauth_session, outcome denied, the status and the reason, by that user. A token that names no user (malformed, expired or for another audience) writes no row, so anonymous callers cannot fill the log. |
| Team models | Spanway_TeamTable | updated | object_id is the team id. Adding a model with a team_id through Models or /model/new writes the team's models list before and after with reason team model added. Deleting a team model writes the list before and after, and every team alias the delete removed as model_aliases before with an empty map after, each with reason team model deleted. The deployment itself has its own row on Spanway_ProxyModelTable. |
| Team members | Spanway_TeamTable | updated | object_id is the team id. Adding or removing members, through /team/member_add, /team/member_delete or POST /management/v1/teams/{team_id}/members/bulk_delete, stores the member list before and after. Keys the removal deleted write their own deleted rows on Spanway_VerificationToken. |
| Team member spend and budget reset | Spanway_TeamMembership | updated | object_id is <team_id>:<user_id>. POST /team/{team_id}/member/{user_id}/reset_spend and .../reset_budget store the member's spend or budget window before and after. Filter by the Team memberships table. |
| Projects | Spanway_ProjectTable | created, updated, blocked, unblocked, deleted | object_id is the project id. The project with its budget row before and after. An update that only changes Block Project is blocked or unblocked. A delete writes one deleted row per project. Filter by the Projects table. |
| Custom roles | Spanway_RoleTable | created, updated, deleted | object_id is the role id, with the role's permissions before and after. Filter by the Custom roles table. |
| Custom role assignments | Spanway_UserTable | updated | object_id is the user id, with custom_role_id before and after. Assign, unassign and every holder of a deleted role each write one row. |
| Access requests | Spanway_AccessRequestTable | created, updated | created stores the new request with its payload, where a key is named only by its hashed token id. updated on cancel, approve and reject stores the request before and after, so status, reviewer_user_id, review_note and applied_result show the decision and who made it. When a temporary budget or rate limit raise runs out, updated by access_request_expiry shows the move from approved to expired and which limits came back. When an approval takes over a limit from an earlier raise that is still running, the earlier request gets an updated row by the approver whose applied_result.reverts no longer lists that limit. The change an approval applies writes its own key, team or membership row. A refused approval writes no row. |
| Organization members | Spanway_OrganizationMembership | created, updated, deleted | Member add stores the new memberships under memberships. Member update and delete use object_id <organization_id>:<user_id> with the membership before and after. |
| Organization delete | Spanway_OrganizationTable, Spanway_TeamTable, Spanway_VerificationToken | deleted | One row for the organization with its members and teams, and one row for every team and every key the delete removed, each with the row as it was. |
| SCIM provisioning | Spanway_UserTable, Spanway_TeamTable, Spanway_VerificationToken | created, updated, deleted, blocked, unblocked | Users and groups the identity provider creates, replaces, patches, links by email, deactivates or deletes, role grants and removals through scim_admin_group, one blocked or unblocked row per key a deactivation or reactivation changes, and placeholder merges. changed_by is scim token <name> and changed_by_api_key the token's hash. When an organization-scoped token deletes a user who belongs to other organizations, the gateway only detaches them: the team removals are written by the same token, and the removed membership is a deleted row on Spanway_OrganizationMembership with object_id <organization_id>:<user_id>. |
| Key hygiene | Spanway_VerificationToken | updated | Written by the hourly job with changed_by key_hygiene_policy. Auto-expiry and the lifetime cap store expires before and after with reason key_hygiene unused key auto-expiry or key_hygiene maximum key lifetime. An expiry email stores the thresholds already sent under expiry_notices_sent, before and after, with reason key_hygiene expiry notice. |
| Master key rotation | Spanway_Config | rotated | object_id master_key. A rotation through POST /key/regenerate names the admin who did it and whether stored values were re-encrypted, and the startup migration names master_key_migration with the number of values it re-encrypted. Never the key itself. |
| Access groups | Spanway_AccessGroupTable, Spanway_TeamTable, Spanway_VerificationToken, Spanway_AgentsTable | created, updated, deleted | The group before and after, one updated row with access_group_ids before and after for every team, key and agent a create, update or delete attaches or detaches, and an updated row on each group a model rename or delete rewrites. |
| Routing presets | Spanway_RoutingPresetTable | created, updated, deleted | object_id <scope>/<name>. Both sides hold the version with its config and created_by. created has no before value, updated has the version that was live before, a rollback adds restored_from_version, and deleted keeps the deleted version as its before value. Saving a name that was deleted earlier is created again. |
| Budget tiers | Spanway_TierPolicyTable | created, updated, deleted | object_id <team or organization>/<id>. An admin's save or removal stores the policy's presets, starting tier, shifts and active_tier before and after. An automatic shift is updated with changed_by system:tier_policies, active_tier before and after, reason budget_threshold and budget_used_percent. |
| Shadow evals | Spanway_ShadowEvalJob | created, updated | object_id is the job id. created stores the targets, routers, direction, judge and baseline models, sample percentage, duration, budget and end time. A stop is updated with the status before and after, stopped_by and stopped_at. A refused stop writes no row. |
| Leaked key report | Spanway_VerificationToken | blocked | object_id is the key hash and changed_by is compromised_key_report. before_value is blocked: false, and updated_values has blocked: true, the reason reported as compromised, the reporter's free text source and reporter_ip, the client address the report came from. The reported key itself is never stored. |
| Customers | Spanway_EndUserTable, Spanway_BudgetTable | created, updated, blocked, unblocked, deleted | The customer before and after. A block of an unknown id is created. A budget the customer routes create or change writes its own created or updated row on Spanway_BudgetTable. |
| Shared budgets | Spanway_BudgetTable | created, updated, deleted | object_id is the budget_id. /budget/new, /budget/update and /budget/delete store the budget before and after. An update or delete of an unknown id answers 404 and writes no row. Filter by the Budgets table, and use Customers and Tags for those objects. |
| Workload identity | Spanway_VerificationToken | created, deleted | object_id is the key hash. A mint is created by workload_identity:<policy> with event workload_identity_token_exchange, the issuer, subject, team, granted models, routes and budget, and the expiry. The mint row also holds the caller's source_ip. A refused exchange whose token names the issuer of a configured trust policy is blocked by workload_identity:unverified, with object_id that issuer, event workload_identity_token_exchange_refused, the OAuth error code, the detail and the source_ip, never the token. Form errors, tokens that are not JWTs and tokens from issuers no policy trusts write no row, only a gateway log line, so anonymous callers cannot fill the log. The hourly cleanup is deleted by workload_identity_cleanup with the creator and expiry. Filter Changed By for workload_identity. |
| JWT auto registration | Spanway_VerificationToken, Spanway_JWTKeyMapping | created | changed_by is auto_register. One row for the new key, named by its hash, unless an existing key was reused, and one for the mapping with the issuer, claim name and claim value. |
| SSO settings | Spanway_SSOConfig | updated | object_id sso_config, the settings before and after with secrets masked. Delete SSO Settings saves empty values, so it is also updated. |
| Sign-in role changes | Spanway_UserTable, Spanway_OrganizationMembership | updated, created | The role before and after when PROXY_ADMIN_ID promotes someone (sso_proxy_admin_id) or role mappings change a role at sign-in (sso_role_map). Organization SSO writes the membership it adds or the organization role it changes, object_id <user_id>:<organization_id>, changed by org_sso. |
| Organization SSO | Spanway_OrgSSOConnection, Spanway_OrgSSODomain, Spanway_VerificationToken | created, updated, deleted | Connections, domains and organization SCIM tokens, with secrets masked. |
| Gateway IP allowlist | Spanway_Config | updated, deleted | object_id general_settings, with allowed_ips before and after. |
| Personal MCP keys and OAuth tokens | Spanway_MCPUserCredentials | created, updated, deleted | object_id is <server_id>:<user_id>. The same rows are written for a personal API key and for a per-user OAuth token. created is a first stored credential, updated a replaced one, and deleted a key the user removed or a proxy admin revoked with user_id, with the admin as changed_by. A key entered on the OAuth connect page is recorded with the signed-in user as changed_by. A token stored when a user finishes the OAuth sign-in for an MCP server writes created, or updated when it replaces one, with the user as changed_by. Both sides hold only server_id, user_id and has_credential, never the key. Removing a key that was not stored writes no row. When an admin changes a server's URL, the gateway removes every user's stored keys and variables for it, and when an admin changes the server's OAuth settings it removes every stored OAuth token. Each of these purges writes one deleted row by that admin with object_id the server id and removed (how many rows went) and reason (server_url_changed or oauth_settings_changed) in the before value. |
| Model deployments | Spanway_ProxyModelTable | created, updated, deleted, blocked, unblocked | object_id is the deployment id, with the deployment before and after and its secrets masked. Pausing a deployment from the Admin UI goes through PATCH /model/{model_id}/update, so it is updated with blocked: true, while /model/block and /model/unblock write blocked and unblocked. Deleting a team writes one deleted row per deployment it removed, with model_name, team_id and the reason team deleted. Tagging a deployment through /tag/new writes updated with its tags before and after. Auto, complexity and quality routers saved from the Admin UI are deployments too, so they write the same rows. |
| Fine-tuning jobs | Spanway_ManagedObjectTable | created, updated | object_id is the job id the caller saw, the managed id for a managed job. created on create, updated on cancel, pause and resume, each with operation, status after the change, model, fine_tuned_model when there is one and custom_llm_provider when the call named one. Never the training data. Reads write no row. |
| Files | Spanway_ManagedFileTable | created, deleted | object_id is the file id the caller saw. An upload stores purpose, filename, bytes, target_model_names, target_storage when it is not the default and managed, whether the id is a gateway managed id. A delete stores managed and the model the delete was routed through. Never the file content. |
| Batches | Spanway_ManagedObjectTable | created, updated | object_id is batch:<batch id> as the caller saw it. created on create, updated on cancel, each with operation, the status after the call, the endpoint and the input_file_id. Never the file content. Reads write no row. |
| Containers | Spanway_ManagedObjectTable | created, deleted | object_id is container:<container id>. A delete also stores the provider. Running code in a container through /v1/responses writes no row, its spend log is the record. |
| Container files | Spanway_ManagedObjectTable | created, deleted | object_id is container_file:<container id>/<file id>. Never the file content. |
| MCP per-user variables | Spanway_MCPUserEnvVars | updated, deleted | object_id is <server_id>:<user_id>. Saving the variables stores their names after the save, clearing them stores the names that were removed. Never a value. |
| MCP toolsets | Spanway_MCPToolsetTable | created, updated, deleted | object_id is the toolset id, with the toolset name, description and tools before and after. A change made by an environment apply writes the same row with the plan id. |
| Approval policies | Spanway_ApprovalPolicy | created, updated, deleted | object_id is the policy id. Both sides hold the whole policy, what it matches, the approvers, required_approvals, timeout_seconds, the escalation levels, enabled and the authority that saved it. |
| Approval requests | Spanway_ApprovalRequest | created, updated, invoked, blocked | Decisions and withdrawals by the person who made them, with the decision, status and note. Lifecycle rows by system:approvals carry approval_event: request_created (with flags, the guardrail and category, when a guardrail flagged the tool call), escalated, expired, consumed, links_sent and cancelled with its cause. A cancelled row is written only once the run change that cancelled the request is saved, so a run update that fails and is rolled back leaves no row. A refused approval link click is blocked with the reason. Never the step message or the tool arguments. |
| Environment plans | Spanway_EnvPlan | created, updated | object_id is the plan id. created holds scope, environment and the create, update, unchanged and delete counts. Approve and reject are updated with the new status and the decision note, and the status and expiry before. Apply is updated with status applied or failed, every object with its outcome and id, and the status and approver before. |
| Environment exports | Spanway_EnvExport | exported | object_id is the export id, with scope, the object count and the bundle_digest, never the bundle. |
| Assistants | Spanway_ManagedObjectTable | created, deleted | object_id is assistant:<assistant id>. Threads, messages and runs are conversation data and write no audit row, their spend logs are the record. |
| Custom pass-through endpoints | Spanway_Config | created, updated, deleted | object_id is pass_through_endpoint:<endpoint id>, with the one endpoint before and after (path, target, auth, methods, guardrails, cost) and its headers redacted. The same change also writes the general_settings row described above. |
| Vector store registry | Spanway_ManagedVectorStoresTable | created, updated, deleted | object_id is the vector store id. /vector_store/new, /vector_store/update and /vector_store/delete store the registration before and after with provider secrets redacted. RAG ingest writes created when it registers a new store and updated with the ingested_files list before and after when it adds a document. |
| Vector stores at the provider | Spanway_ManagedObjectTable | created, updated, deleted | object_id is vector_store:<id>, with the operation (create, modify or delete), for calls to /v1/vector_stores. vector_store_index:<name> is a POST /v1/indexes registration with the store and provider index it points at. |
| Vector store files | Spanway_ManagedObjectTable | created, updated, deleted | object_id is vector_store_file:<vector store id>/<file id>, with the operation attach, update or detach. Never the file content. |
| Guardrails | Spanway_GuardrailsTable | created, updated, deleted | object_id is the guardrail id, with the definition before and after and its secrets redacted. A create the integration refuses, for example without the license Hide Secrets needs, writes no row. |
| Team guardrail submissions | Spanway_GuardrailsTable | created, updated | created on POST /guardrails/register with the submitted parameters, the team and the submitter's user id and email. Approve and reject are updated with the status before and after. A refused submission or approval writes no row. |
| Guardrail policies | Spanway_PolicyTable, Spanway_PolicyAttachmentTable | created, updated, deleted | object_id is the policy version id or the attachment id, with the value before and after. Promoting a version writes a second updated row for the production version it replaced. Deleting every version of a policy has object_id the policy name and keeps every deleted version under versions. An attachment's mode switch stores the old and new mode. |
| Prompt operations | Spanway_PromptTable, Spanway_PromptPartialTable, Spanway_PromptOpsSettings, Spanway_PromptGitSyncTable | created, updated, deleted, exported | A promotion is updated on the prompt with operation promote and the promotion record (source version, eval run, pinned partials). Prompt protection settings are updated with the settings before and after. Partials hold the name, version and description with the text replaced by its hash. Repository connections hold the provider, repository, branch, folder and environment, never the token. A Git pull writes one row per saved prompt with source git_sync:<name>, and a push is exported with the commit and the files written. |
| Search tools | Spanway_SearchToolsTable | created, updated, deleted | object_id is the search tool id, with the tool before and after and the provider key redacted. |
| Realtime client secrets | Spanway_VerificationToken | invoked | object_id is the hash of the key that minted the secret, with event realtime_client_secret_created, the model, the session_type and expires_at. Never the secret. |
| AI hub | Spanway_Config | updated | object_id public_model_groups, public_model_groups_links, public_agent_groups or public_mcp_servers, with the published model groups, useful links, agents or MCP servers before and after. |
| Spanway Cloud tenants | Spanway_CloudTenantTable | created, updated, blocked, unblocked, exported | object_id is the tenant id. created for a signup and for verification, updated for a repeat signup while pending, the first Stripe customer (only {"stripe_customer": true}), a rename, a plan change and a cancellation, blocked and unblocked for suspension and reinstatement, exported for a workspace export. The tenant's email, legal name, address and billing details are never stored in the row. |
| Spanway Cloud credits | Spanway_CloudCreditLedgerTable | created | A paid credit purchase or auto top-up recorded in the ledger. Turning auto top-up on, changing it or off is updated on Spanway_CloudTenantTable, without the saved card. |
| Spanway Cloud provider keys | Spanway_CredentialsTable | created, deleted | A tenant's own provider key added or removed, with the provider, the masked key and the deployment id, never the key. |
| Tags | Spanway_TagTable | created, updated, deleted | object_id is the tag name, with its description, models, budget id and, under budget, the max_budget, budget_duration, soft_budget, tpm_limit, rpm_limit and other budget fields before and after. |
| Cost tracking settings | Spanway_Config | updated | object_id cost_discount_config, cost_margin_config or block_requests_for_models_without_pricing, with the values before and after. A first save has an empty object or false as the before value. |
| Price map | Spanway_Config | updated, deleted | object_id model_cost_map for a manual reload, with the model count and revision before and after. object_id model_cost_map_reload_config for the reload schedule, updated with interval_hours before and after, and deleted when the schedule is cancelled. |
| Personal provider connections | Spanway_UserProviderCredentials | created, deleted | object_id is <credential name>:<user id>. Connect is created, disconnect and the purge after a credential delete are deleted. The rows hold the provider and the account login (github_login), never the token. |
| Credential encryption migration | Spanway_Config | updated | object_id credential_encryption_migration, with residual_legacy, total_undecryptable and the number of values migrated by a real run. Dry runs and checks write no row. |
| Global spend reset | Spanway_VerificationToken, Spanway_TeamTable | updated | object_id *. One row for keys and one for teams, with the total_spend and number of rows before the reset and spend: 0 after. |
| Spend exports | Spanway_DailySpend | exported | object_id is the daily table, such as spanway_dailyteamspend. Each daily activity download stores export (for example team_daily_activity), destination download, filters with the entity, entity ids, range, export_type and format, the row_count streamed, completed and the caller's ip and user_agent. The row is written when the download ends, so a download the browser stopped shows completed false. Listed in the export ledger. |
| Request log reads | Spanway_SpendLogs, Spanway_DailySpend | viewed | object_id is the request id for an opened request, otherwise the route. read (request_content, request_logs or spend_report), the caller's role, ip and user_agent, and the filters, row_count and hidden_fields where they apply. Never the prompt or response. Content reads are recorded unless audit_log_content_reads is false, list and report reads only when audit_log_list_reads is true. |
| Hidden field reveals | Spanway_SpendLogs | revealed | object_id is the request id. revealed_fields, the caller's reason, role, ip and user_agent. Always written, and written before the content is returned. |
| Run ledger export | Spanway_SpendLogs | exported | object_id run_ledger:<run id>, with export run_ledger, the run id and kind as filters, the number of entries as row_count, whether the ledger was truncated, ip and user_agent, never the entries. |
| Data plane log replay | Spanway_SpendLogs | created | One row per POST /v1/rust_control_plane/logs batch, object_id spend_log_replay:<id>, with the number of records, how many were processed and failed, and the attributed_key_hashes the records charge spend to, never the payloads. |
| Cloud import | Spanway_OrganizationTable, Spanway_TeamTable, Spanway_UserTable | created, updated | One POST /cloud/import writes created for the organization (its name, models, budget, new team ids, member ids and keys to regenerate), created for each team and each new member, and updated with the team list before and after for each member who already had a user, all with source cloud_import and never an email address. A dry run writes no row. |
| Gateway database copy | the copied Spanway table, for example Spanway_TeamTable | created | One row per copied table for every spanwayctl migrate gateway-db run that copies, all with the same object_id gateway_migration:<id>, changed_by spanwayctl migrate gateway-db (<who>), and the source_table, rows read and rows inserted, never a row's data. The rows are written straight into the target database and chained like every other row. A dry run writes none. |
| Data subject export | Spanway_DataSubjectRequestTable | exported | object_id is the request id, with export data_subject, the subject type and id as filters, the number of records in the bundle as row_count, completed false when the Lens copies could not be collected, ip and user_agent. The created row of the request is written as before. |
| Invoice download | Spanway_InvoiceTable | exported | object_id is the invoice id, with export billing_invoice, the invoice id and format csv as filters, the number of line items as row_count, ip and user_agent. |
| Cost exports | Spanway_Config | created, updated, deleted, exported | object_id cloudzero_settings or vantage_settings, with the connection id, timezone or base URL before and after, api_key_changed and integration_changed when a secret was replaced, what a delete removed, and for every manual export the window and row limit. |
| Red team runs | Spanway_RedTeamRunTable | created, updated, deleted | created stores the run request. updated on cancel stores the run before and after, followed by the cancel reason. deleted stores the run with its summary. Attack prompts and model replies are never written. |
| Code graph | Spanway_CodeRepoTable, Spanway_CodeCredentialTable | created, updated, deleted | Connecting a repository holds the repository as connected. Reindex holds the status and indexed commit before and the queued run id after, mirroring holds mirror_source_permissions and acl_server_id before and after, webhook rotation shows the path as REDACTED on both sides, and disconnecting holds the repository as it was. Binding a credential or installing the GitHub App is created on the credential table with object_id <tenant>:<credential>. An uninstalled App, a repository removed from an installation and a repository the poller finds unreadable are written by system:code_graph. Filter by the Code repositories and Code credentials tables. |
| Review queues | Spanway_EvalReviewQueueTable, Spanway_EvalReviewItemTable | created, updated, deleted, exported | A queue as created, before and after a change, and as deleted. Adding items is updated with enqueued_from and the counts. Removing an item is deleted on the item table with the queue, source and source id, never the prompt or answer. A golden dataset export is exported. Assigning items to reviewers and taking them back are updated with the item ids and who held them before and after. Labels and skips write no row. Filter by the Review queues and Review items tables. |
| Stored workflow runs and workflow runner | Spanway_WorkflowRun | created, updated, exported | A run start, a PATCH, an event that moves the run to another status, a cancel and a resume, each with the status before. exported when someone other than the run's caller reads step content through the run history, with runner_action history_content_read, never the content. |
| Workflow definitions and variables | Spanway_WorkflowDefinition, Spanway_WorkflowVariable | created, updated, blocked, unblocked, deleted | A saved workflow with its name, visibility, version and content hash, the previous version on a new version, restored_from_version when an earlier version was restored as the latest, and halted before and after on a halt or release. A variable holds its value before and after. |
| Workflow triggers | Spanway_WorkflowTrigger | created, updated, deleted, blocked, unblocked, rotated, invoked | The trigger before and after, never its secret or bound key. rotated holds the old and new secret hint, also when a Slack or Teams secret is replaced, and invoked a test fire. A Slack, Teams or mail access mapping is part of the trigger's source, and the secret Slack or Teams issued never appears. A trigger that turns itself off is written by system:workflow_triggers. |
| Workflow templates, pins and dead letters | Spanway_WorkflowTemplateInstall, Spanway_WorkflowPin, Spanway_WorkflowDeadLetter | created, updated, deleted | An install, upgrade with the digest and workflow version before, and uninstall. A pin's creation and deletion without its content. A dead letter requeue or discard. Releasing a halted agent writes unblocked on Spanway_AgentsTable. |
| Compliance evidence | Spanway_ComplianceEvidenceTable | created, exported | object_id is the evidence id. created for every generated bundle, by the caller or by compliance_evidence_schedule for a scheduled one, and exported for every JSON or HTML download, each with the bundle's window, trigger, SHA-256 and creator, never the bundle contents. Filter by the Compliance evidence table. |
| Compliance snapshots | Spanway_ComplianceSnapshotTable | created | object_id is the snapshot id, with the regime, score and creator, without the full report. Filter by Compliance snapshots. |
| Eval datasets, runs, schedules, scorers and rules | Spanway_EvalDatasetTable, Spanway_EvalRunTable, Spanway_EvalScheduleTable, Spanway_EvalRemoteScorerTable, Spanway_OnlineEvalRuleTable, Spanway_OnlineEvalBackfillTable, Spanway_EvalFeedback | created, updated, deleted, invoked | The object before and after, never dataset items, model outputs or signing secrets. A cancel stores cancel_reason, a submitted run writes updated per answer batch with counts only and again when it is finished, and deleting end-user feedback writes deleted. Restoring an online rule version writes updated with the version it came from and your reason, trying a rule before saving writes invoked with the sample count and judge cost, and starting or cancelling a backfill writes created or updated on the backfill table. Recording feedback and claiming, labelling or skipping a review item write no row, as Evals explains. Filter by the eval tables. |
| Lens | Lens | created, updated, deleted | object_id is the Lens path, such as /lens/tracing/keys/<key_id> or /lens/signals. created for POST, updated for PUT and PATCH, deleted for DELETE, each with the method, path and status, never the request body. Read-only searches write none. Filter by the Lens table. |
| Sanctions decisions | none, see the note | none | Case decisions, report filings and manual list refreshes are kept in the append-only sanctions decision log (GET /sanctions/events) with the actor, the time and the reason, because OFAC record keeping needs a log the database refuses to change. Changes to the geofence and screening settings themselves are Spanway_Config rows here. |
Admin settings, UI theme and banner
| Change | Table | object_id | Action |
|---|---|---|---|
| A switch on the UI Settings tab, or Team admin editable fields | Spanway_UISettings | ui_settings | updated, with every switch before and after |
| The dashboard banner | Spanway_UISettings | user_banner | updated, with the banner before and after |
| Logo, dark logo or favicon on the UI Theme page | Spanway_Config | ui_theme_config | updated, with the URLs before and after |
| An uploaded logo image | Spanway_Config | ui_logo:<name> | created, with the image type and size, never the image |
| Web search interception, MCP semantic filter and MCP tool search settings | Spanway_Config | websearch_interception_params, mcp_semantic_tool_filter or mcp_tool_search | updated, with the settings before and after |
| Allowed IPs, Data access auditing and Logging Settings | Spanway_Config | general_settings | updated, with the section before and after |
| SSO settings | Spanway_SSOConfig | sso_config | updated, with client secrets redacted |
These rows are written only while audit logging is on, see Turn on audit logging.
MCP events
Every MCP change made through the API or the Admin UI writes a row, on Spanway_MCPServerTable unless the table says otherwise: creating, editing and deleting a server, a team submission (created), each server an import creates (created), approving or rejecting a submission (updated, with approval_status before and after), pinning and unpinning a server's tools (updated, with pinned_tools before and after), turning write tools on or off (updated), closing live sessions (deleted, object_id the session id prefix or user:<user_id>, with the filters and how many sessions were closed), and publishing servers on the AI hub (updated on Spanway_Config, object_id public_mcp_servers, with the list before and after). Toolsets, personal keys, OAuth tokens and per-user variables have their own rows in the table above. The only MCP changes that write no row are the Admin UI's five-minute in-memory draft of a server and the OAuth relays a client uses while it connects, which store nothing.
Approval events
Human approval writes a row for every policy change and every decision, and the gateway's own actions are written by system:approvals. Filter Changed By for system:approvals, or Table for Spanway_ApprovalRequest, to follow one request from request_created to consumed, expired or cancelled.
Environment events
Environment promotion writes one row per plan event on Spanway_EnvPlan and one per export on Spanway_EnvExport. Each object an apply writes also gets its own row on that object's table, as the person who applied, so you can trace a change in production back to the plan that made it.
Secrets never reach the audit log. Before a row is written, field names are split into words on underscores, hyphens and camelCase boundaries, and a field is replaced with REDACTED at any depth when one of its words is password, passwd, pwd, secret, token, credential, credentials, authorization, cookie, private, certificate, signing, signature, sig, hmac, apikey, bearer, session, sas, dsn or webhook, when its last word is key, keys, auth or headers (so api_key, akto_api_key, x-api-key, apiKey, master_key and access_key are all redacted), or when it is headers or credential_values. Every value under env, env_vars, environment_variables and callback_vars is redacted whatever its name. Fields whose words include id, name, alias, info, hash, cost, max, budget, limit, rpm or tpm, such as key_alias or credential_name, are kept. Inside text values, the user and password part of a URL, secret query parameters, Bearer and Basic credentials and --flag=value arguments with a secret flag name are redacted too, and JSON stored as a string is redacted like any other field. Memory entries are recorded without their stored text. Invitation rows store a SHA-256 digest of the invitation id instead of the id itself, because the id is the onboarding link.
Tamper evidence
Each row carries a hash chain. When a row is written, the gateway takes a transaction-scoped Postgres advisory lock, reads the newest entry_hash, and stores it on the new row as previous_hash. It then stores entry_hash, the SHA-256 of the row's canonical JSON (sorted keys, no whitespace) followed by previous_hash. The first row of the chain points at a hash of 64 zeros. The lock serializes writers across every gateway replica, so two replicas never chain onto the same row.
Editing a row changes the digest it should have, deleting a row breaks the link of the row after it, and inserting a hashed row breaks the link of the row that follows. A row inserted without any hash does not break a link, so verification counts those separately as unhashed_rows, the rows without a hash written after the first hashed row of the window. The gateway writes such a row only when it could not extend the chain (it then logs Failed Creating audit log), so compare the count with those log lines, and treat any extra row as inserted behind the gateway's back. Rows written before the chain was introduced have no hash and are not counted.
Verify the chain
-
In the Admin UI, open Logs, then Audit Logs. Above the table, click Verify chain. The button reads Verifying while it runs.
-
Read the result. Audit chain verified gives the number of rows checked. Audit chain broken at row names the first row that fails, when it was written, why, and the expected and found hashes. No hashed audit rows yet means there is nothing to verify until new rows are written.
-
To check a window from the API, pass
sinceanduntilin ISO 8601:curl "http://localhost:4000/audit/verify?since=2026-10-01T00:00:00Z" \-H "Authorization: Bearer $SPANWAY_API_KEY"Expected result:
{"valid": false,"rows_checked": 1284,"since": "2026-10-01T00:00:00Z","until": null,"chain_head_id": "4f0c2d0e-0a8f-4a53-9a77-6f3f0d1b9a10","chain_tail_id": "c1b7e0f5-55d4-4f43-8f43-0a3c2f7f6e21","chain_anchor": "9a41c0d7e2b6f4a1c8d3e5f7a9b1c3d5e7f9a1b3c5d7e9f1a3b5c7d9e1f3a5b7","truncated_before": false,"unhashed_rows": 0,"first_break": {"id": "8d2e5a4c-2b0f-4c11-9e3b-7d55a0c4e8f2","updated_at": "2026-10-09T14:03:22.418Z","reason": "entry_hash_mismatch","expected": "6b1f2e3d4c5b6a798817263544536271808f9e0d1c2b3a4958677685940312ab","found": "e03a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8"}}
The first row of the window is checked against the newest hashed row written before since. Proxy admins and view-only proxy admins can run it, and it needs a valid license like reading the log. chain_anchor is the hash the first checked row was linked against. truncated_before is true when no hashed row exists before the window and the oldest surviving row does not point at the genesis hash, which is what you see after audit log retention deletes old rows.
reason is entry_hash_mismatch when the row's content no longer matches its digest, and previous_hash_mismatch when the row does not point at the row before it, which means a row was removed or inserted in between. The hash chain detects changes made directly in the database. Keep the chain head somewhere the database operators cannot write, for example by exporting rows to a SIEM, so that rewriting the whole chain is also detectable.
Retention
When maximum_audit_log_retention_period is set, the cleanup job deletes the oldest rows. Verification does not report that as a break. When nothing older than the window survives, the oldest remaining row's previous_hash is accepted as the anchor and returned as chain_anchor with truncated_before set to true. Every row after it must still link and recompute. Because the deleted prefix can no longer be checked on the gateway, compare chain_anchor with the entry_hash of the last purged row in your SIEM export to confirm that only retention removed rows.
Sending audit rows to other systems
audit_log_callbacks and audit_webhook are set only in config.yaml or the database config. The Admin UI does not show or change them, so check the gateway's startup log for Initialized Audit Log Callbacks - [...] to see which destinations loaded.
audit_log_callbacks sends every audit row to one or more destinations as it is written. Each delivered event includes previous_hash and entry_hash, so the receiving system can check the chain on its own.
spanway_settings:
store_audit_logs: true
audit_log_callbacks: ["azure_sentinel", "s3_v2"]
The built-in destinations are azure_sentinel, s3_v2 and azure_storage. A callback can also be a dotted path to your own CustomLogger subclass that implements async_log_audit_log_event.
Microsoft Sentinel
The azure_sentinel callback sends audit rows to a Log Analytics workspace through the Logs Ingestion API. Audit rows are batched separately from request logs, so the two record shapes never share an ingestion batch.
| Environment variable | Purpose |
|---|---|
AZURE_SENTINEL_ENDPOINT | The data collection endpoint URL. |
AZURE_SENTINEL_DCR_IMMUTABLE_ID | The immutable id of the data collection rule. |
AZURE_SENTINEL_AUDIT_STREAM_NAME | The rule's stream for audit rows. Defaults to AZURE_SENTINEL_STREAM_NAME, then Custom-Spanway. |
AZURE_SENTINEL_TENANT_ID, AZURE_SENTINEL_CLIENT_ID, AZURE_SENTINEL_CLIENT_SECRET | The app registration that can write to the rule. The AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET variables are used when these are unset. |
Give the stream's table columns for every field in the row table above. Keeping entry_hash and previous_hash in Sentinel lets an analytics rule alert when a hash seen in Sentinel is missing from the gateway's chain.
Signed webhook
general_settings.audit_webhook posts audit rows to an HTTPS endpoint as JSON batches. A url that is not https:// stops the config from loading, because audit rows name who changed what. For a collector on a trusted internal network that only speaks HTTP, set allow_insecure_http: true next to the url. Use it for a SIEM or an internal service that has no built-in callback.
general_settings:
audit_webhook:
url: https://siem.example.com/spanway/audit
secret: os.environ/AUDIT_WEBHOOK_SECRET
headers:
X-Source: spanway-gateway
batch_size: 50
flush_interval_seconds: 5
max_retries: 3
retry_backoff_seconds: 1
timeout_seconds: 10
Each request body is {"events": [...]}, one object per audit row, with the same fields as the row table above. Rows are sent when batch_size rows are queued or every flush_interval_seconds. A failed delivery, meaning a network error or a status outside 2xx, is retried max_retries times with exponential backoff starting at retry_backoff_seconds. A batch that still fails is kept and sent with the next flush. At most max_queue_size rows (10,000 by default) are held, and the oldest are dropped first.
secret can be the secret itself or an os.environ/NAME reference. A reference to an unset variable stops the config from loading instead of falling back to unsigned delivery. When secret is set, every request carries two headers. X-Spanway-Timestamp is the Unix time in seconds, and X-Spanway-Signature is sha256= followed by the hex HMAC-SHA256 of the timestamp, a ., and the raw request body, keyed with the secret. Verify the signature over the exact bytes you received and reject requests whose timestamp is too old.
import hashlib
import hmac
def verify(secret: str, timestamp: str, body: bytes, signature: str) -> bool:
expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(f"sha256={expected}", signature)
Errors
| Status | Where | Meaning | Fix |
|---|---|---|---|
401 Authentication Error, No api key passed in. | GET /audit, GET /audit/{id}, GET /audit/verify | No key was sent. | Send Authorization: Bearer <key>. |
403 Admin-only endpoint. Not allowed to access this. | GET /audit, GET /audit/{id}, GET /audit/verify, GET /audit/exports | The caller is neither a proxy admin nor an admin viewer, and has no custom role holding audit.read, or the role also denies it. | Use an admin key, or give the user a custom role with the Audit logs read grant. |
422 naming action | GET /audit | action is not a stored value. | Use created, updated, deleted, blocked, unblocked, rotated, exported, viewed, revealed, invoked or kill_switch_fired. |
403 Reading the audit log needs a Spanway enterprise license. ... or Verifying the audit log needs ... | The same routes | The gateway has no valid license. Rows are still written when store_audit_logs is set. | Add a license. The Admin UI shows the Enterprise notice in place of the tab. |
404 Audit log with id=<id> not found | GET /audit/{id} | No row has that id. | Copy the id from the list. |
400 since must not be later than until | GET /audit/verify | The window is inverted. | Swap the two values. |
| 422 | GET /audit, GET /audit/verify | A filter has the wrong shape, for example page_size over 100 or a date that is not ISO 8601. | Fix the parameter named in the response. |
500 DB not connected. ... | Every audit route | The gateway runs without a database. | Set DATABASE_URL. |
Audit chain broken at row <id> | Verify chain | A row was edited, removed or inserted directly in the database. | Compare the row with your SIEM export, and treat the database as tampered with until explained. |
Config fails to load naming audit_webhook | Gateway start | The url is not https:// without allow_insecure_http, or secret references an unset variable. | Fix the URL or set the variable. |
Logs
| Level | Line | Meaning |
|---|---|---|
| Startup output | Initialized Audit Log Callbacks - ['azure_sentinel', 's3_v2'] | The audit destinations from the config file loaded. Normal. |
| WARNING | 'audit_log_callbacks' is configured but audit logging is not enabled. Audit log callbacks will not fire. | No row reaches any destination. Set store_audit_logs: true, or add a license. |
| ERROR | Failed Creating audit log <error> | The hash chain could not be extended, so the row is stored again without hashes. Verification counts it in unhashed_rows and does not check it. Check the database. |
| ERROR | Failed Creating unchained audit log <error> | The row without hashes could not be stored either, so the log now has a real gap. The management request itself succeeded. Check the database at once. |
| ERROR | prisma_client is None, cannot write audit log to DB | Audit logging is on but the gateway has no database. Set DATABASE_URL. |
| WARNING | Could not resolve audit log callback: <name> | A name in audit_log_callbacks is not a built-in destination or an importable class. Fix the name. |
| ERROR | Failed dispatching audit log to callback: <error> or Audit log callback task failed: <error> | A destination rejected a row. The row is still in the database. Check the destination's credentials. |
| WARNING | Audit webhook: delivery to <url> failed: <error> or Audit webhook: <url> responded with status <code> | One delivery attempt failed and will be retried. Normal if rare. |
| ERROR | Audit webhook: giving up on batch of <n> events after retries | Every retry failed. The batch is kept for the next flush, up to max_queue_size rows. Check the receiver. |
Related
- Logs page for the Audit Logs tab in detail.
- Data access governance for read audit events, hidden log fields with an audited reveal, and the export ledger.
- What Spanway stores for how long audit rows are kept and how erasure treats them.
- Compliance for retention periods and evidence exports.
- Run ledger, which includes the audit rows written during a run.
- Error reference and log reference.