{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-audit-events-page-schema.json",
  "title": "AuditEventsPage",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nopaque-co-uk-audit-api-openapi.yml#/components/schemas/AuditEventsPage",
  "type": "object",
  "required": [
    "entries",
    "window",
    "windowApplied"
  ],
  "properties": {
    "entries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AuditLogEntry"
      }
    },
    "nextCursor": {
      "type": "string",
      "description": "Pass back as `cursor`, with `from` set to `window.from`, for the next page."
    },
    "window": {
      "type": "object",
      "required": [
        "days",
        "from"
      ],
      "description": "How far back the workspace's plan shows the log.",
      "properties": {
        "days": {
          "type": "integer"
        },
        "from": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "windowApplied": {
      "type": "boolean",
      "description": "True when the plan's window set the start of the range."
    }
  },
  "$defs": {
    "AuditLogEntry": {
      "type": "object",
      "description": "One action in the activity log. Entries hold ids, never names: look a person up by\ntheir user id, a key by its id. A nopaque staff actor has no `id`, and neither does a\ntarget that is a member of nopaque staff.\n",
      "required": [
        "id",
        "action",
        "category",
        "workspaceId",
        "actor",
        "via",
        "target",
        "details",
        "startedAt",
        "outcome"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "The action's id."
        },
        "action": {
          "type": "string",
          "description": "What happened, e.g. `api_key.created`, `test.updated`, `number.ordered`."
        },
        "category": {
          "type": "string",
          "enum": [
            "access",
            "keys",
            "billing",
            "workspace",
            "testing",
            "numbers",
            "assistant"
          ]
        },
        "workspaceId": {
          "type": [
            "string",
            "null"
          ]
        },
        "actor": {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "user",
                "staff",
                "api_key",
                "system"
              ]
            },
            "id": {
              "type": "string",
              "description": "A user id, an API key id, or a system name. Absent for nopaque staff."
            }
          }
        },
        "via": {
          "type": "string",
          "enum": [
            "app",
            "api_key",
            "mcp",
            "quinn",
            "platform_manager",
            "stripe",
            "system"
          ],
          "description": "How the action was taken."
        },
        "target": {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "description": "What was acted on, e.g. `workspace`, `member`, `api_key`, `test`, `number`."
            },
            "id": {
              "type": "string",
              "description": "The record's id. Never a phone number or an email address."
            }
          }
        },
        "details": {
          "type": "object",
          "description": "A few fields that depend on the action: ids, values from a fixed list, counts and\nbooleans (and lists of codes). Never free text.\n",
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          }
        },
        "startedAt": {
          "type": "string",
          "format": "date-time"
        },
        "finishedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When the result arrived. Absent while pending or not recorded."
        },
        "outcome": {
          "type": "string",
          "enum": [
            "success",
            "failure",
            "refused",
            "pending",
            "not_recorded"
          ]
        }
      }
    }
  }
}