{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Take a moderation action on an actor.",
      "errors": [
        {
          "name": "SubjectHasAction"
        },
        {
          "description": "An event with the same external ID already exists for the subject.",
          "name": "DuplicateExternalId"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "createdBy": {
              "format": "did",
              "type": "string"
            },
            "event": {
              "refs": [
                "tools.ozone.moderation.defs#modEventTakedown",
                "tools.ozone.moderation.defs#modEventAcknowledge",
                "tools.ozone.moderation.defs#modEventEscalate",
                "tools.ozone.moderation.defs#modEventComment",
                "tools.ozone.moderation.defs#modEventLabel",
                "tools.ozone.moderation.defs#modEventReport",
                "tools.ozone.moderation.defs#modEventMute",
                "tools.ozone.moderation.defs#modEventUnmute",
                "tools.ozone.moderation.defs#modEventMuteReporter",
                "tools.ozone.moderation.defs#modEventUnmuteReporter",
                "tools.ozone.moderation.defs#modEventReverseTakedown",
                "tools.ozone.moderation.defs#modEventResolveAppeal",
                "tools.ozone.moderation.defs#modEventEmail",
                "tools.ozone.moderation.defs#modEventDivert",
                "tools.ozone.moderation.defs#modEventTag",
                "tools.ozone.moderation.defs#accountEvent",
                "tools.ozone.moderation.defs#identityEvent",
                "tools.ozone.moderation.defs#recordEvent",
                "tools.ozone.moderation.defs#modEventPriorityScore",
                "tools.ozone.moderation.defs#ageAssuranceEvent",
                "tools.ozone.moderation.defs#ageAssuranceOverrideEvent",
                "tools.ozone.moderation.defs#ageAssurancePurgeEvent",
                "tools.ozone.moderation.defs#revokeAccountCredentialsEvent",
                "tools.ozone.moderation.defs#scheduleTakedownEvent",
                "tools.ozone.moderation.defs#cancelScheduledTakedownEvent"
              ],
              "type": "union"
            },
            "externalId": {
              "description": "An optional external ID for the event, used to deduplicate events from external systems. Fails when an event of same type with the same external ID exists for the same subject.",
              "type": "string"
            },
            "modTool": {
              "ref": "tools.ozone.moderation.defs#modTool",
              "type": "ref"
            },
            "reportAction": {
              "description": "Optional report-level targeting. If provided, this event will be linked to specific reports and reporters may be notified.",
              "ref": "#reportAction",
              "type": "ref"
            },
            "subject": {
              "refs": [
                "com.atproto.admin.defs#repoRef",
                "com.atproto.repo.strongRef"
              ],
              "type": "union"
            },
            "subjectBlobCids": {
              "items": {
                "format": "cid",
                "type": "string"
              },
              "type": "array"
            }
          },
          "required": [
            "event",
            "subject",
            "createdBy"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "ref": "tools.ozone.moderation.defs#modEventView",
          "type": "ref"
        }
      },
      "type": "procedure"
    },
    "reportAction": {
      "description": "Target specific reports when emitting a moderation event",
      "properties": {
        "all": {
          "description": "Target ALL reports on the subject. Excludes assigned and escalated reports.",
          "type": "boolean"
        },
        "allOwned": {
          "description": "Target all eligible reports on the account and its owned subjects, including records, messages, and conversations. Only valid for account subjects and events that close reports. Excludes assigned, escalated, and actively assigned reports unless explicitly targeted by ID.",
          "type": "boolean"
        },
        "ids": {
          "description": "Target specific report IDs",
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "isAutomated": {
          "description": "Set true when the report activities are created by an automated process.",
          "type": "boolean"
        },
        "note": {
          "description": "Note to send to reporter(s) when actioning their report",
          "type": "string"
        },
        "subjectTypes": {
          "description": "Expands report targeting to include owned subjects of these types. Requires event subject to be an account. Mutually exclusive with `subjects`.",
          "items": {
            "enum": [
              "account",
              "record",
              "message",
              "conversation"
            ],
            "type": "string"
          },
          "maxLength": 4,
          "type": "array"
        },
        "subjects": {
          "description": "Expands report targeting to include additional subjects. Requires event subject to be an account. Mutually exclusive with `subjectTypes`.",
          "items": {
            "refs": [
              "com.atproto.admin.defs#repoRef",
              "com.atproto.repo.strongRef"
            ],
            "type": "union"
          },
          "maxLength": 100,
          "type": "array"
        },
        "types": {
          "description": "Target reports matching these report types on the subject (fully qualified NSIDs). Excludes assigned and escalated reports.",
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "type": "object"
    }
  },
  "id": "tools.ozone.moderation.emitEvent",
  "lexicon": 1
}
