{
  "lexicon": 1,
  "id": "tickets.atmosphere.cancelTicketEvent",
  "defs": {
    "main": {
      "type": "procedure",
      "description": "Irreversibly cancel an ATM ticketed event. Requires app service-auth plus current primary-organizer authority. Atomically stops sales/check-in, revokes admission authority, and queues applicable refunds plus buyer/app notifications.",
      "input": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": [
            "eventId",
            "reason"
          ],
          "properties": {
            "environment": {
              "type": "string",
              "knownValues": [
                "test",
                "live"
              ],
              "maxLength": 16
            },
            "eventId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300
            },
            "organizerDid": {
              "type": "string",
              "format": "did",
              "description": "The current primary organizer authorizing cancellation. Omit only when the calling app is itself the event's primary organizer."
            },
            "organizerAssertionJwt": {
              "type": "string",
              "description": "Optional only for an app canceling its own event. Otherwise, a short-lived user service-auth JWT from organizerDid to ATM scoped to tickets.atmosphere.cancelTicketEvent.",
              "maxLength": 8192
            },
            "reason": {
              "type": "string",
              "minLength": 3,
              "maxGraphemes": 1000,
              "maxLength": 10000
            }
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": [
            "cancellation"
          ],
          "properties": {
            "cancellation": {
              "type": "ref",
              "ref": "#cancellation"
            }
          }
        }
      },
      "errors": [
        {
          "name": "AppNotRegistered",
          "description": "Caller DID is not registered as an ATM app."
        },
        {
          "name": "TicketsModuleDisabled",
          "description": "This app has not enabled ATM Tickets."
        },
        {
          "name": "TicketEventNotFound",
          "description": "Ticketed event config not found."
        },
        {
          "name": "EventControlRequired",
          "description": "A verified current primary-organizer authorization is required for this event."
        },
        {
          "name": "UserDidMismatch",
          "description": "organizerAssertionJwt issuer does not match organizerDid."
        },
        {
          "name": "InvalidCancellationReason",
          "description": "Cancellation reason must be between 3 and 1000 characters."
        }
      ]
    },
    "cancellation": {
      "type": "object",
      "required": [
        "id",
        "eventId",
        "status",
        "ticketCount",
        "paidTicketCount",
        "freeTicketCount",
        "releasedHoldCount"
      ],
      "properties": {
        "id": {
          "type": "string",
          "maxLength": 300
        },
        "eventId": {
          "type": "string",
          "maxLength": 300
        },
        "status": {
          "type": "string",
          "knownValues": [
            "requested",
            "already-canceled"
          ],
          "maxLength": 32
        },
        "ticketCount": {
          "type": "integer",
          "minimum": 0
        },
        "paidTicketCount": {
          "type": "integer",
          "minimum": 0
        },
        "freeTicketCount": {
          "type": "integer",
          "minimum": 0
        },
        "releasedHoldCount": {
          "type": "integer",
          "minimum": 0
        }
      }
    }
  }
}
