{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.indemption.com/docs/api/schemas/loop-start-v1.schema.json",
  "title": "UOCL Loop Start v1",
  "description": "Inbound JSON contract for starting a UOCL Loop. CURRENT production path is Ride Start (requires hubspot_deal_id or alias). Additional properties are allowed so callers can pass template-specific context without schema churn.",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "hubspot_deal_id": {
      "type": "string",
      "minLength": 1,
      "description": "Primary correlation id for CURRENT Ride Start. Required unless an alias is provided."
    },
    "hubspotDealId": {
      "type": "string",
      "minLength": 1,
      "description": "Alias for hubspot_deal_id."
    },
    "deal_id": {
      "type": "string",
      "minLength": 1,
      "description": "Alias for hubspot_deal_id."
    },
    "title": { "type": "string" },
    "instructions": { "type": "string" },
    "submitLabel": { "type": "string" },
    "successMessage": { "type": "string" },
    "source": { "type": "string" },
    "logoUrl": { "type": "string" },
    "backgroundUrl": { "type": "string" },
    "bannerUrl": { "type": "string" },
    "booking": {
      "type": "object",
      "additionalProperties": true,
      "description": "Booking / recipient context preserved for confirmation email; not the primary form model."
    },
    "fields": {
      "description": "Form field model as an array of field objects, or a map of name → value / field object.",
      "oneOf": [
        {
          "type": "array",
          "items": { "$ref": "#/$defs/field" }
        },
        {
          "type": "object",
          "additionalProperties": true
        }
      ]
    },
    "data": {
      "type": "object",
      "additionalProperties": true,
      "description": "Flexible nested context. May include fields, title, instructions, or arbitrary template context. Only known UI keys are guaranteed to affect CURRENT Ride Start rendering."
    }
  },
  "anyOf": [
    { "required": ["hubspot_deal_id"] },
    { "required": ["hubspotDealId"] },
    { "required": ["deal_id"] }
  ],
  "$defs": {
    "field": {
      "type": "object",
      "additionalProperties": true,
      "required": ["name"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "label": { "type": "string" },
        "type": { "type": "string" },
        "value": {},
        "editable": { "type": "boolean" },
        "options": {
          "type": "array",
          "items": {}
        },
        "required": { "type": "boolean" },
        "placeholder": { "type": "string" }
      }
    }
  }
}
