{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pomerado-ai/json-schema/pomerado-ai-audit-event-schema.json",
  "title": "AuditEvent",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pomerado-ai-openapi.json#/components/schemas/AuditEvent",
  "type": "object",
  "required": [
    "id",
    "occurred_at",
    "kind",
    "actor",
    "target",
    "member",
    "from",
    "to",
    "client",
    "ends_at",
    "fields",
    "transfer"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "occurred_at": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "team.member_added",
        "team.role_changed",
        "team.member_removed",
        "team.invitation_sent",
        "team.invitation_resent",
        "team.invitation_revoked",
        "login.access_granted",
        "login.access_changed",
        "login.access_revoked",
        "api_key.created",
        "api_key.revoked",
        "tool.published",
        "tool.deleted",
        "tool.code_link_created",
        "tool.code_downloaded",
        "file.uploaded",
        "login.created",
        "login.updated",
        "login.deleted",
        "login.unlock_requested",
        "login.unlock_granted",
        "login.unlocked_replace_started",
        "login.unlocked_delete_started",
        "login.unlocked_change",
        "login.revealed",
        "login.sms_number_linked",
        "login.sms_number_unlinked",
        "webhook.created",
        "webhook.updated",
        "webhook.secret_rotated",
        "webhook.tested",
        "webhook.deleted",
        "account.session_recordings_changed",
        "account.two_step_rule_changed",
        "account.identity_provider_only_changed",
        "usage.daily_cap_changed",
        "usage.overage_budget_changed",
        "usage.alert_created",
        "usage.alert_changed",
        "usage.alert_deleted",
        "usage.summary_changed",
        "usage.dollar_alerts_changed",
        "two_step.authenticator_added",
        "two_step.authenticator_removed",
        "two_step.passkey_added",
        "two_step.passkey_renamed",
        "two_step.passkey_removed",
        "two_step.backup_codes_created",
        "two_step.backup_code_used"
      ]
    },
    "actor": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "member_id",
            "name",
            "email",
            "api_key",
            "oauth_app"
          ],
          "properties": {
            "member_id": {
              "type": "string",
              "description": "The member's user ID"
            },
            "name": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "email": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "api_key": {
              "anyOf": [
                {
                  "type": "object",
                  "required": [
                    "id",
                    "name"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ],
              "description": "The API key they made the change with, as your team's keys name it now. Null for a change made in the Dashboard or by an OAuth app, and on a change recorded before its key was"
            },
            "oauth_app": {
              "anyOf": [
                {
                  "type": "object",
                  "required": [
                    "id",
                    "name"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The app's OAuth client ID"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "The name the app registered, or null when it can't be read now"
                    }
                  },
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ],
              "description": "The connected OAuth app they made the change with. Null for a change made in the Dashboard or with an API key, and on a change recorded before its app was"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "Who made the change, with the API key or connected OAuth app they used, on every kind of change one can make with one. Null when Pomerado made it. On file.uploaded and tool.code_downloaded, the member, API key or OAuth app that made the link, or the member whose own session moved it; see transfer.authenticated_by for how the transfer proved it. Null for a code download recorded before transfers were"
    },
    "target": {
      "type": "object",
      "required": [
        "id",
        "name"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "description": "What changed: the member, invitation, login, API key, tool, file, webhook or usage alert, or the account for a setting, the daily cap and the overage budget, or the member whose usage summary changed. A login is named as it is named now (its label, or its site), and has no name once deleted. On webhook.created, on webhook.updated when the change set a new URL, and on webhook.tested, a webhook is named by the destination the change set or the test was sent to: its URL's origin (scheme, host and port), never its path or query. Its other events, and a usage alert, have no name. On file.uploaded, the uploaded file by its ID, never its name; on tool.code_downloaded, the tool"
    },
    "member": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "member_id",
            "name",
            "email"
          ],
          "properties": {
            "member_id": {
              "type": "string",
              "description": "The member's user ID"
            },
            "name": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "email": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "On a login access event, the member whose access changed. Null for the whole team, and on other events"
    },
    "from": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The role, access level or setting (on or off) before; for the daily cap, overage budget, a usage alert or a usage summary, what it was, in words (null for a new alert)"
    },
    "to": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The role, access level or setting (on or off) after; for the daily cap, overage budget, a usage alert or a usage summary, what it is now, in words (null for a deleted alert)"
    },
    "client": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "kind",
            "name"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "api_key",
                "oauth"
              ]
            },
            "name": {
              "type": "string"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "On login.unlock_requested, login.unlock_granted, login.unlocked_replace_started, login.unlocked_delete_started and login.unlocked_change, the API key or OAuth app the Logins PIN unlocked saved login changes for, by its name then. Null on other events"
    },
    "ends_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "On login.unlock_granted, login.unlocked_replace_started, login.unlocked_delete_started and login.unlocked_change, when that unlock ends (ISO 8601). Null on other events"
    },
    "fields": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "label",
              "username",
              "email",
              "phone",
              "account_number",
              "primary_identifier",
              "password",
              "date_of_birth",
              "zip",
              "preferred_method",
              "authenticator_secret",
              "authenticator_code",
              "recovery_codes",
              "security_answers",
              "private_identifier"
            ]
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "On login.updated, the saved login's fields the change set or cleared; on login.revealed, what was shown: its saved values (such as username and password) or authenticator_code. Never the values themselves. Null on other events, and on a change recorded before fields were named"
    },
    "transfer": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "size",
            "authenticated_by",
            "ip_address",
            "user_agent",
            "via"
          ],
          "properties": {
            "size": {
              "type": "number",
              "description": "The bytes moved"
            },
            "authenticated_by": {
              "type": "string",
              "enum": [
                "transfer_key",
                "credential",
                "owner_session",
                "link_only",
                "unverified"
              ],
              "description": "How the transfer proved it may move the link: transfer_key (the link's Pomerado-Transfer-Key), credential (the API key, OAuth app or Dashboard session that made the link, as its bearer), owner_session (the member's own Dashboard session moving their job's output), link_only (the link's URL alone, with no credential or another one) or unverified (a credential that couldn't be checked then)"
            },
            "ip_address": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The caller's IP address, as Pomerado's edge saw it. Null when it wasn't known, and when Pomerado itself read the link (via run_input)"
            },
            "user_agent": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The caller's User-Agent header, up to 512 characters"
            },
            "via": {
              "type": "string",
              "enum": [
                "link",
                "run_input"
              ],
              "description": "link: a request to the link itself. run_input: Pomerado read one of your code download links that a run was given as a file input, for that run"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "On file.uploaded and tool.code_downloaded, the transfer: its size, how it authenticated, and the caller's IP address and user agent. Null on other events, and on a code download recorded before transfers were"
    }
  },
  "additionalProperties": false
}