{
  "lexicon": 1,
  "id": "tickets.atmosphere.setEventCapacity",
  "defs": {
    "main": {
      "type": "procedure",
      "description": "Set, change, or clear the shared EVENT capacity — one pool every ticket type of the event draws from, in addition to any per-type caps. Requires app service-auth plus current primary-organizer authority; creation provenance alone is insufficient. Exactly one of capacity or unlimited:true is required. Per-type caps MAY sum above the event capacity; sales still stop at the event capacity (availability is the min across a type's pools).",
      "input": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": [],
          "properties": {
            "environment": {
              "type": "string",
              "knownValues": [
                "test",
                "live"
              ],
              "maxLength": 16
            },
            "eventId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300
            },
            "eventUri": {
              "type": "string",
              "format": "at-uri"
            },
            "organizerDid": {
              "type": "string",
              "format": "did",
              "description": "The current primary organizer authorizing this mutation. Omit only when the calling app is itself that primary organizer."
            },
            "organizerAssertionJwt": {
              "type": "string",
              "description": "Optional only for an app updating its own event. Otherwise, a short-lived user service-auth JWT from organizerDid to ATM scoped to tickets.atmosphere.setEventCapacity.",
              "maxLength": 8192
            },
            "capacity": {
              "type": "integer",
              "minimum": 1,
              "maximum": 250000,
              "description": "Total tickets across ALL ticket types of the event."
            },
            "unlimited": {
              "type": "boolean",
              "description": "true clears the event capacity (unlimited — the default posture for new events)."
            }
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": [
            "eventId",
            "soldQuantity",
            "heldQuantity"
          ],
          "properties": {
            "eventId": {
              "type": "string",
              "maxLength": 300
            },
            "capacity": {
              "type": "integer",
              "minimum": 1,
              "maximum": 250000,
              "description": "The event capacity now in effect. Omitted when unlimited."
            },
            "soldQuantity": {
              "type": "integer",
              "minimum": 0
            },
            "heldQuantity": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      },
      "errors": [
        {
          "name": "AppNotRegistered",
          "description": "Caller DID is not registered as an ATM app."
        },
        {
          "name": "TicketsModuleDisabled",
          "description": "This app has not enabled ATM Tickets."
        },
        {
          "name": "EventNotFound",
          "description": "Ticketed event 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": "InvalidCapacity",
          "description": "Capacity is invalid, or lower than tickets already sold or held for the event."
        },
        {
          "name": "InvalidCapacityConfig",
          "description": "Provide exactly one of capacity or unlimited:true."
        }
      ]
    }
  }
}
