{
  "lexicon": 1,
  "id": "tools.ozone.moderation.emitEvents",
  "defs": {
    "main": {
      "type": "procedure",
      "description": "Take a moderation action on multiple subjects at once. Each subject is processed independently; failures are listed in failedEvents. Only the listed event types are supported.",
      "input": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": ["event", "subjects", "createdBy"],
          "properties": {
            "event": {
              "type": "union",
              "refs": [
                "tools.ozone.moderation.defs#modEventTakedown",
                "tools.ozone.moderation.defs#modEventAcknowledge",
                "tools.ozone.moderation.defs#modEventLabel",
                "tools.ozone.moderation.defs#modEventReport",
                "tools.ozone.moderation.defs#modEventReverseTakedown",
                "tools.ozone.moderation.defs#modEventResolveAppeal",
                "tools.ozone.moderation.defs#modEventEmail",
                "tools.ozone.moderation.defs#modEventTag",
                "tools.ozone.moderation.defs#revokeAccountCredentialsEvent"
              ]
            },
            "subjects": {
              "type": "array",
              "description": "Array of subjects to apply the moderation event to.",
              "maxLength": 100,
              "items": {
                "type": "ref",
                "ref": "#subjectEntry"
              }
            },
            "createdBy": {
              "type": "string",
              "format": "did"
            },
            "modTool": {
              "type": "ref",
              "ref": "tools.ozone.moderation.defs#modTool"
            }
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": ["events", "failedEvents"],
          "properties": {
            "events": {
              "type": "array",
              "description": "Successfully processed moderation events.",
              "items": {
                "type": "ref",
                "ref": "tools.ozone.moderation.defs#modEventView"
              }
            },
            "failedEvents": {
              "type": "array",
              "description": "Events that failed to process.",
              "items": {
                "type": "ref",
                "ref": "#failedEvent"
              }
            }
          }
        }
      },
      "errors": [
        {
          "name": "InvalidLabel",
          "description": "One or more labels contain invalid characters."
        },
        {
          "name": "DuplicateSubjects",
          "description": "The subjects array contains duplicate entries."
        },
        {
          "name": "EmptySubjects",
          "description": "The subjects array is empty."
        },
        {
          "name": "UnsupportedEvent",
          "description": "The event type is not supported by this bulk endpoint."
        }
      ]
    },
    "subjectEntry": {
      "type": "object",
      "description": "A subject with optional blob CIDs, external event ID, and report-level targeting. Report targeting applies only to this entry.",
      "required": ["subject"],
      "properties": {
        "subject": {
          "type": "union",
          "refs": [
            "com.atproto.admin.defs#repoRef",
            "com.atproto.repo.strongRef"
          ]
        },
        "subjectBlobCids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "cid"
          }
        },
        "externalId": {
          "type": "string",
          "description": "Deduplicate events of this type for this subject using an external ID."
        },
        "reportAction": {
          "type": "ref",
          "ref": "tools.ozone.moderation.emitEvent#reportAction",
          "description": "Optional report-level targeting for this subject. Links the event to matching reports and may notify reporters."
        }
      }
    },
    "failedEvent": {
      "type": "object",
      "description": "An event that failed to process.",
      "required": ["error", "subject"],
      "properties": {
        "error": {
          "type": "string",
          "description": "Error message describing the reason for failure."
        },
        "errorName": {
          "type": "string",
          "description": "Typed error identifier for programmatic handling. Omitted when the error is unexpected/uncategorized.",
          "knownValues": [
            "InvalidSubject",
            "SubjectHasAction",
            "AlreadyTakendown",
            "NotTakendown",
            "DuplicateExternalId",
            "InvalidConfiguration",
            "InvalidRequest"
          ]
        },
        "subject": {
          "type": "union",
          "description": "The subject from the failed event input.",
          "refs": [
            "com.atproto.admin.defs#repoRef",
            "com.atproto.repo.strongRef"
          ]
        }
      }
    }
  }
}

