{
  "type": "record",
  "name": "ExternalEventReported",
  "namespace": "com.plumery.audittrail.events",
  "doc": "A generic event reported by a non-Plumery service to be recorded in the shared audit trail",
  "fields": [
    {
      "name": "id",
      "type": "string",
      "doc": "Unique event identifier"
    },
    {
      "name": "eventSource",
      "type": "string",
      "doc": "Origin/context the event is about, e.g. publishing service name or a business resource identifier such as payment:6878951b-256b-4baa-9e81-ad4c577adc4e"
    },
    {
      "name": "type",
      "type": "string",
      "doc": "Event type, e.g. com.partner.payments.PaymentInitiated"
    },
    {
      "name": "time",
      "type": {
        "type": "long",
        "logicalType": "timestamp-millis"
      },
      "doc": "When the action occurred"
    },
    {
      "name": "action",
      "type": "string",
      "doc": "What happened, e.g. PaymentInitiated"
    },
    {
      "name": "description",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Human-readable description of the action"
    },
    {
      "name": "userId",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Identifier of the acting end-user, if known to the publisher"
    },
    {
      "name": "partyId",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Identifier of the acting party, if known to the publisher"
    },
    {
      "name": "staffId",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Identifier of the acting staff member, if known to the publisher"
    },
    {
      "name": "staffRoles",
      "type": [
        "null",
        {
          "type": "array",
          "items": "string"
        }
      ],
      "default": null,
      "doc": "Roles of the acting staff member, if applicable"
    },
    {
      "name": "userLocation",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Location the action was performed from, if known"
    },
    {
      "name": "userAgent",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "User agent of the acting client, if known"
    },
    {
      "name": "sessionId",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Session identifier, if known"
    },
    {
      "name": "apiRequest",
      "type": [
        "null",
        {
          "type": "record",
          "name": "ApiRequest",
          "fields": [
            {
              "name": "requestId",
              "type": [
                "null",
                "string"
              ],
              "default": null
            },
            {
              "name": "uri",
              "type": "string"
            },
            {
              "name": "httpMethod",
              "type": "string"
            },
            {
              "name": "requestBody",
              "type": [
                "null",
                "string"
              ],
              "default": null
            }
          ]
        }
      ],
      "default": null,
      "doc": "Details of the API request that triggered the action, if applicable"
    },
    {
      "name": "responseStatusCode",
      "type": [
        "null",
        "int"
      ],
      "default": null,
      "doc": "HTTP response status code of the action outcome, if applicable"
    },
    {
      "name": "responseStatus",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Response status description of the action outcome, if applicable"
    },
    {
      "name": "metadata",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Free-form JSON-encoded context"
    },
    {
      "name": "payload",
      "type": [
        "null",
        "string"
      ],
      "default": null,
      "doc": "Free-form JSON-encoded payload"
    }
  ]
}