{
  "lexicon": 1,
  "id": "tickets.atmosphere.setTicketTypeForm",
  "defs": {
    "main": {
      "type": "procedure",
      "description": "Set (or clear) the private per-ticket-type attendee form for a ticketed event. Authorized through event control (primary organizer or accepted co-organizer).",
      "input": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": [
            "ticketTypeId",
            "organizerDid"
          ],
          "nullable": [
            "form"
          ],
          "properties": {
            "environment": {
              "type": "string",
              "knownValues": [
                "test",
                "live"
              ],
              "maxLength": 16
            },
            "ticketTypeId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 300
            },
            "organizerDid": {
              "type": "string",
              "format": "did"
            },
            "organizerAssertionJwt": {
              "type": "string",
              "description": "Optional short-lived user service-auth JWT from organizerDid to ATM, scoped to tickets.atmosphere.setTicketTypeForm. Proves the app is configuring ticketing with organizer consent.",
              "maxLength": 8192
            },
            "form": {
              "type": "ref",
              "ref": "#form"
            }
          }
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "type": "object",
          "required": [
            "ticketTypeId",
            "fieldCount"
          ],
          "properties": {
            "ticketTypeId": {
              "type": "string",
              "maxLength": 300
            },
            "fieldCount": {
              "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": "TicketTypeNotFound",
          "description": "Ticket type not found."
        },
        {
          "name": "EventNotFound",
          "description": "Ticketed event not found."
        },
        {
          "name": "EventControlRequired",
          "description": "A verified primary-organizer or accepted co-organizer authorization is required for this event."
        },
        {
          "name": "InvalidTicketForm",
          "description": "The form schema is invalid (e.g. showAtCheckIn set on a free-text or email field)."
        },
        {
          "name": "UserDidMismatch",
          "description": "organizerAssertionJwt issuer does not match organizerDid."
        }
      ]
    },
    "form": {
      "type": "object",
      "description": "The attendee form schema. Omit the form, pass null, or pass an empty fields array to clear it. Only structured fields (select/checkbox/boolean/number) may set showAtCheckIn.",
      "required": [
        "version",
        "fields"
      ],
      "properties": {
        "version": {
          "type": "integer",
          "minimum": 1,
          "description": "Form schema version. Currently 1."
        },
        "fields": {
          "type": "array",
          "maxLength": 30,
          "items": {
            "type": "ref",
            "ref": "#formField"
          }
        }
      }
    },
    "formField": {
      "type": "object",
      "required": [
        "key",
        "label",
        "type"
      ],
      "properties": {
        "key": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": {
          "type": "string",
          "maxLength": 1000,
          "description": "Optional buyer-facing help text shown below the question."
        },
        "type": {
          "type": "string",
          "knownValues": [
            "text",
            "textarea",
            "email",
            "select",
            "checkbox",
            "boolean",
            "number"
          ],
          "maxLength": 16
        },
        "required": {
          "type": "boolean"
        },
        "showAtCheckIn": {
          "type": "boolean",
          "description": "Show this answer at check-in. Allowed ONLY on select/checkbox/boolean/number fields; rejected on text/textarea/email so no free-text/email answer can reach the door scanner."
        },
        "options": {
          "type": "array",
          "maxLength": 50,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": "Choice values for select fields; each string is both the stored value and the display label. Deliberately atomic: richer per-option shapes (value/label pairs) would ship as a NEW optional field rather than mutating these items."
        }
      }
    }
  }
}
