# Audit logs The Django backend, audio extractor worker, and S3 gateway emit structured JSON audit events to standard output. Filter by `service.name` and `event.action` to find the operation you want to investigate. Web and mobile actions are audited at the backend when they make a request. Browser or app actions on already-loaded data, such as copying to the clipboard, are outside this audit trail. Upload policies and download redirects record authorization. Evidence of bytes transferred directly to or from object storage comes from the proxy or storage provider serving that request. ## Reading an event - **Outcome.** The tables use `lasuite.outcome` so that `denied` remains distinct from `failure`. The ECS field `event.outcome` records both as `failure`. - **Request and diagnostics.** When available, the event includes `http.request.method`, `http.request.id`, `http.response.status_code`, and `url.path`. The path excludes the query string. Look for an outcome reason in `event.reason`, a safe error code or type in `error.message` or `error.type`, and operation-specific fields under `lasuite.details`. - **File and actor.** File-scoped events carry the file UUID in `entity.target.id` and available file metadata in `entity.target.raw` (`filename`, `size`, `mimetype`). When an account is known, look for `user.id` and the OIDC subject in `lasuite.actor.sub`. Set `AUDIT_LOG_PERSONAL_DATA=true` to include account email and full name where available. To include those fields in worker events, enable the setting in both the backend and the worker. ## Django backend The backend uses `service.name = dictaphone`. API paths below are relative to `/api/v1.0`. For actions audited by the Django REST Framework mixin, HTTP `401`, `403`, and `429` produce `denied`. Other `4xx` and `5xx` responses produce `failure`. The mobile login credential checks override this mapping for specific `400` responses. File and result actions include the status-derived reason when available. They omit raw exception and response messages. ### Authentication | Action | When it is emitted | Success | Failure or denial | | --- | --- | --- | --- | | `user.login` | Django signals that a session login succeeded or authentication failed. | `success` with the signed-in account and authentication backend. | `denied` with reason `authentication_failed` when Django emits its failed-login signal. The event has no account identity. | | `user.registration` | The OIDC backend creates a local account or rejects registration under the role policy. | `success` after the new account is committed. | `denied` with `permission_denied` when the role policy blocks registration. The response redirects the user (`302`). The event omits provider claims. | | `user.logout` | Django signs out an authenticated account. | `success` with the signed-out account. | No failure event. Signing out without an active account emits no event. | | `user.mobile_login` | `POST /oauth/token/` attempts to exchange a PKCE authorization code. | `success` (`200`) with the account receiving the tokens. | `failure` for malformed input (`400`, `validation_error`). An invalid or expired code, a mismatched verifier, or an invalid account produces `denied` (`400`, `authentication_failed`) with `failure_code` set to `invalid_or_expired_code`, `invalid_code_verifier`, or `invalid_code_user`. Throttling produces `denied` (`429`, `rate_limited`). | | `user.token.refresh` | `POST /oauth/token/refresh/` attempts to refresh a token. | `success` (`200`) with the account identified from the issued access token, when available. | Client errors are `denied` without an account. Server errors produce `failure`. | | `user.token.revoke` | `POST /oauth/token/revoke/` asks to blacklist a refresh token. | `success` (`200`) with the account named by the verified token when that account still exists. | An invalid or already-revoked token is `denied` (`401`). Malformed requests can produce `failure` (`400`). Rejections have no account identity. | Mobile authentication events carry the authentication method in `lasuite.auth.method` (`oidc` for the PKCE exchange and `jwt` for refresh and revocation). Token values, authorization codes, and PKCE verifiers are excluded. ### Files | Action | When it is emitted | Success | Failure or denial | | --- | --- | --- | --- | | `file.list` | `GET /files/` lists files. | `success` (`200`). The `files` detail contains the ID, filename, size, and MIME type of each file in the response page. | `denied` or `failure` follows the API response status. | | `file.upload.authorize` | `POST /files/` requests a pending file and upload policy. | `success` (`201`) when the API issues an upload policy. The policy itself is excluded. | `denied` or `failure` follows the API response status. | | `file.upload` | Upload finalization copies the stored object and inspects its size and MIME type. | `success` records the observed file metadata before upload restrictions are applied. | No failure event. Use `file.create` to see whether finalization was accepted. | | `file.create` | `POST /files/{id}/upload-ended/` attempts to finalize the upload. | `success` (`200`) when the backend marks the file ready and starts the audio extraction workflow. | `denied` for authorization or quota rejection. `failure` for an invalid upload state, missing temporary upload, rejected file, or other error. Size and type rejections use `error.message` values `file_size_exceeded` and `file_type_not_allowed`. | | `file.rename` | A file update changes the displayed title. | `success` with the old and new titles in `filename.from` and `filename.to` under `lasuite.details`. | No failure event. Updates that leave the title unchanged emit no rename event. | | `file.delete` | `DELETE /files/{id}/` soft-deletes a file, or `DELETE /files/{id}/hard-delete/` marks it for permanent deletion. | `success` (`204`). The detail `deletion_mode` is `trash` or `permanent`. A permanent request queues storage cleanup. | `denied` or `failure` follows the API response status. | | `file.restore` | `POST /files/{id}/restore/` requests that a file be taken out of the trash. | `success` (`200`) when the backend restores the file. | `denied` or `failure` follows the API response status. | | `file.retention.pending` | A retention command moves a file into a pending cleanup state. | `success` after the transition commits. Details include the new `state` and the retention `policy`. | A transition error appears in the `management.command` outcome. | | `file.purge.schedule` | A retention command attempts to queue deletion for a file, including retries for files already marked for deletion. | `success` when the queue accepts the task. The message names the file and says whether the task covers original data or the whole file. Details include `scope`, the command `run_id`, and the `policy` when the command applied one. | `failure` identifies the same file and records the exception class in `error.type`. | | `storage.object.delete` | A cleanup path attempts to delete a tracked storage object. | `success` after committing cleanup of the object, including when it is already absent from storage. | `failure` for storage errors, with the exception class in `error.type`. Both outcomes carry `object_id` and `object_kind`; these also identify the objects removed by original-media-only cleanup. | | `file.purge` | The backend permanently removes the file record after all tracked storage objects are cleaned up. | `success` after the transaction commits. | Use the per-object events to identify failures that prevent completion. | | `file.download` | `GET /files/{id}/download/` requests a media redirect. | `success` (`302`) when the backend returns the redirect. | `denied` on access refusal. A missing file or media URL produces `failure` (`404`). | | `file.access` | The media authorization endpoint evaluates a request. | `success` (`200` for the authorization subrequest) with the original media path and original `GET` or `HEAD` when supplied. Successful range requests that start after byte zero are skipped. | `denied` or `failure` follows the authorization response status. These events use the authorization endpoint path. | ### Transcription, summaries, and Docs access | Action | When it is emitted | Success | Failure or denial | | --- | --- | --- | --- | | `transcription.retry` | `POST /ai-jobs/{id}/retry/` requests a new transcript job. | `success` (`201`) when the API returns the new job. Use `summary.submit` for the outcome of submission to the processing service. | `denied` or `failure` follows the API response status. Validation can reject, for example, a pending job, audio that has yet to pass validation, or a retry in the same language as an already successful job. | | `transcription.language.change` | A retry creates a job with a different language from the original job. | `success` with `language.from` and `language.to` under `lasuite.details`. | No failure event. Retries in the same language emit no language-change event. | | `transcription.read` | `GET /ai-jobs/{id}/transcript/` requests the stored transcript. | `success` (`200`) when the API serves the result. The content is excluded. | `denied` or `failure` follows the API response status. | | `summary.read` | `GET /ai-jobs/{id}/summary/` requests the stored summary. | `success` (`200`) when the API serves the result. The content is excluded. | `denied` or `failure` follows the API response status. | | `docs.open` | `POST /ai-jobs/{id}/open-in-docs/` requests the linked document URL. | `success` (`200`) when Dictaphone returns the link. | `denied` or `failure` follows the API response status. | | `docs.create` | `POST /ai-jobs/{id}/create-in-docs/` requests creation of a Docs document. | `success` (`201`) when the API returns the new link. | `denied` or `failure` follows the API response status. Use `docs.push` for individual delivery outcomes, including automated delivery. | These API events carry `lasuite.details.ai_job_id` when a job was resolved, except for the separate language-change event. ### Webhooks and outbound services | Action | When it is emitted | Success | Failure or denial | | --- | --- | --- | --- | | `summary.submit` | The backend attempts to submit a transcription or summary job to the processing service. | `success` when the service returns a job ID. Details include `summary_job_id` and `job_type` (`transcript` or `summary`). | `failure` when the send or response handling fails, or when the response lacks a usable job ID. Transcription checks that stop the task before submission emit no event. | | `summary.callback` | `POST /ai-jobs/webhook/` rejects, processes, or acknowledges a delivery. Events for acknowledged deliveries are emitted after commit. | `success` for a processed success payload. The backend queues result handling. | `denied` for access refusals. `failure` for invalid payloads, processing errors, and processed failure payloads, including `no_audio_in_file` with HTTP `200`. `unknown` when the delivery is ignored because the job is missing or already terminal. | | `ai.result.publish` | A backend task downloads, validates, and stores a transcript or summary. | `success` when the saved result and job state commit. | `failure` when fetching, validating, or storing the result raises an error. The event carries the exception class and may be followed by a retry. | | `docs.push` | The backend attempts to create a document in Docs. | `success` with `docs_id` after saving the link. | `failure` with a `failure_code` such as `push_failed`, `response_unreadable`, or `remote_outcome_unknown`. A read timeout can leave the remote outcome unknown. | For authenticated callbacks, `summary.callback` records `shared_secret` as the authentication method and identifies the file creator when the job is known. The `callback_status` field records the reported status. An ignored delivery still returns HTTP `200` and records `disposition=ignored` with `ignore_reason=job_not_found` or `ignore_reason=job_already_terminal`. For a terminal job, `job_status` records its current state. Submission, callback, and publication events can be joined using `ai_job_id` or the remote ID `summary_job_id`, when available. The remote ID is recorded when it contains only ASCII letters, digits, periods, underscores, and hyphens and fits the stored ID's 255-character limit. Outbound calls use the file creator as the actor and identify the destination in `service.target.name` (`summary` or `docs`). ### Django admin Staff can open **Audit event reference** from the Django admin home page. The reference is also available at `/admin/audit-events/`. Failed admin writes record the qualified exception class in `error.type`. | Action | When it is emitted | Success | Failure or denial | | --- | --- | --- | --- | | `admin..create`, `.update`, `.delete` | An admin creates, changes, or deletes a user, file, access bypass email, or transcription usage record. Inline saves through these admins are also covered. | `success` after the write commits. Form events can include changed field names. | Deletion exceptions produce `failure` with the exception class. An invalid form that makes no change emits no write event. | | `admin.file.delete` | An admin confirms a single-file deletion, a bulk deletion, or removal of a file from a user’s inline form. | One `success` per file after the deletion request commits, with the admin ID and file ID. Use `file.purge` with the same file ID to verify storage cleanup. | An exception during a direct or bulk file deletion produces `failure` for the affected file. | | `admin..action` | An admin invokes a bulk action on an audited model. | `success` when the action finishes and its writes commit. Details include `admin_action` and the selection `count`. Individual rows may be skipped by the action. | An exception propagated by the action produces `failure` with the exception class. | | `admin.user.merge` | An admin confirms an account merge, or a request is refused for insufficient merge permissions. | `success` after the merge commits, with the source and destination account IDs. | `denied` for insufficient permissions. A missing account or integrity error during the merge produces `failure`. | ### Management commands Every application command listed below emits one `management.command` event with actor type `system`. Filter on `lasuite.details.command` and use `lasuite.details.run_id` to correlate events from the same execution. `lasuite.details.dry_run` identifies previews. The event excludes raw command arguments, bucket names, storage keys, passwords, and exception messages. Command summaries with a failure record the qualified exception class in `error.type`. | Action | Success | Failure | | --- | --- | --- | | `management.command` | The command returned normally, including an empty run or a preview. The counts describe the work the command performed or previewed. | An exception or an interrupt reached the command runner. The event includes `error.type` and any progress recorded before the failure. A failed run can still leave completed changes. Command-line parsing errors that prevent execution emit no event. | | `storage.object.migrate` | A live migration moved the tracked object to its destination. The target ID identifies the storage object. | A migration attempt raised an exception. The event includes the storage object ID and `error.type`. Aligned, deferred, and skipped objects appear in the run counts. | | `storage.object.reconcile` | A live reconciliation updated a pending record. Details include `file_id` and the resulting `state` (`available` or `deleted`). A `deleted` result means the object was already absent. | A reconciliation attempt raised a storage error. The event includes the storage object ID and `error.type`. Concurrently changed rows appear in the skipped count. | | `storage.object.delete` | S3 deletion completed or the key was already absent, and the cleanup state committed. Each event includes `object_id`, `object_kind`, and the owning file ID. | S3 deletion raised a storage error. The event includes `error.type`. Objects skipped by retention or lease checks emit no deletion event. | | `storage.object.delete.schedule` | `cleanup_storage_objects --failed-jobs` recorded cleanup intent for a selected failed-job artifact. The event carries the object and file IDs. | Errors appear in the command outcome. | | `ai.job.expire` | `cleanup_storage_objects --pending-ai-hours` committed a transition of a stale pending job to failed. The event carries the job and file IDs. | Errors appear in the command outcome. Jobs that became ineligible emit no expiry event. | | `file.pending.cleanup` | `clean_pending_files` marked a stale pending file for permanent deletion and its cleanup routine returned. Storage cleanup may be deferred. | Marking the file or running its cleanup routine raised an exception. The event includes the file ID and `error.type`. | | `transcription.usage.purge` | `purge_transcription_usage` committed deletion of a usage record. The event records only the record ID alongside the command context. | Errors appear in the command outcome. | | `user.superuser.change` | `createsuperuser` committed account creation, promotion, or password reset. The event records `account_change` and the target account ID. | Errors appear in the command outcome. | | `user.demo.create` | `create_demo` committed creation of a demo account. The event records the target account ID. | Errors appear in the command outcome. | Dry runs emit the command summary alone. Live retention runs can also emit `file.retention.pending` and `file.purge.schedule`. Per-object `storage.object.delete` and final `file.purge` events carry the command and run ID, including when a Celery task resumes deferred cleanup. A later `cleanup_storage_objects` run that retries a deletion records its own run ID. Use the file and object IDs to follow cleanup across runs. | Command | Run details | | --- | --- | | `auto_hard_delete_files`, `delete_original_files_data` | `marked_pending` and `queued` file counts. | | `purge_deleted_files` | `marked_for_purge` and `queued` file counts. Queued work includes retries for files already marked for purge. | | `clean_pending_files` | `age_hours` and the number of stale files `processed` by the cleanup routine. | | `cleanup_storage_objects` | `processed`, `deleted`, and `failed` object counts. When requested, also `failed_pending_ai_jobs` and `queued_failed_job_objects`. Preview counts use the `would_` prefix. | | `migrate_storage_objects` | `objects` counts for aligned, migrated, deferred, failed, and skipped objects. During a preview, `migrated` is the number of candidates that would move. | | `reconcile_pending_storage_objects` | `objects` counts for available, deleted, failed, and skipped records. | | `purge_transcription_usage` | `retention_days` and the number of usage records `deleted`. | | `createsuperuser` | `account_change` reports `created`, `promoted`, or `password_reset`. The saved account ID is in `user.target.id`. | | `create_demo` | `users_created` after demo data creation completes. | ### Audio worker API | Action | When it is emitted | Success | Failure or denial | | --- | --- | --- | --- | | `audio.job.claim` | The backend issues a job to a worker or rejects its request. Idle polls emit no event. | `success` (`200`) with the file ID, `audio_job_id`, and worker `mode`. | `denied` or `failure` follows the API response status. | | `audio.job.complete` | A worker reports the result of an attempt. | `success` (`200`) when the backend accepts the report. The reported job outcome is stored separately as `reported_status`. | `denied` or `failure` follows the API response status. Examples include an invalid worker token, an expired or stale lease (`409`), and a file no longer eligible for processing (`410`). | These events exclude signed URLs and worker-supplied error text. Match them to worker processing events using `lasuite.details.audio_job_id`. ## Audio extractor worker The default `service.name` is `dictaphone-audio-extractor`. | Action | When it is emitted | Success | Failure | | --- | --- | --- | --- | | `file.transcode` | The worker processes an audio transcoding job. | `success` after downloading the source, converting it, and uploading the audio output. | `failure` at stage `download`, `convert`, `upload`, or `supervisor`. | | `file.validate` | The worker processes an audio validation job. | `success` after downloading the audio and passing validation. | `failure` at stage `download`, `validate`, or `supervisor`. | Both events carry `lasuite.details.audio_job_id`, the source path, and the file and creator context when the backend supplied it. A failure carries `event.reason = internal_error` and the stage in `lasuite.details.stage`. `error.message` contains an exception class or `timeout`. The supervisor also uses `worker_crash` when the child exits without completing before the processing deadline. The worker emits its processing event before posting completion to the backend. A rejected completion report can therefore follow a `success` processing event. ## S3 gateway The default `service.name` is `dictaphone-s3-gateway`. | Action | When it is emitted | Success | Failure | | --- | --- | --- | --- | | `s3.proxy` | The gateway finishes handling a request to `/proxy`. This includes rejected requests. Health probes emit no audit event. | `success` when the status is below `400` and `transfer_reason` is `complete`. | `failure` for an HTTP status of `400` or above or a transfer reason other than `complete`. Examples include a blocked target, a concurrency limit, an upstream error, a cancelled request, or an interrupted stream. | Use `lasuite.details.transfer_reason` to distinguish failures such as `target_not_allowed`, `upstream_error`, and `transfer_failed`. A stream that breaks after headers were sent can have outcome `failure` with HTTP `200`. The event records the method (`GET`, `PUT`, or `OTHER`), gateway HTTP status, duration in milliseconds, upstream authority when known, and error type when available. It records `/proxy` as the path and excludes the signed target URL.