{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://autoagentprotocol.org/v1.3/schemas/lead-submit-response.schema.json",
  "title": "LeadSubmitResponse",
  "description": "Dealer agent's response to a `lead.submit.request`. Carries the assigned `lead_id` and overall lead `status`, plus an optional appointment block when the request included an `appointment` (the dealer can confirm the requested time, propose alternatives, leave it as merely requested for human follow-up, or reject the appointment while still accepting the lead). Carried inside an A2A `Message.parts[].data` DataPart via `SendMessage`.",
  "type": "object",
  "properties": {
    "type": {
      "const": "lead.submit.response",
      "description": "AAP message type discriminator."
    },
    "data": {
      "type": "object",
      "properties": {
        "lead_id": {
          "type": "string",
          "description": "Dealer-assigned identifier for this lead."
        },
        "status": {
          "type": "string",
          "enum": ["received", "duplicate", "rejected"],
          "description": "Overall lead status. `duplicate` indicates the dealer recognized the same buyer/vehicle combination from a recent prior submission and merged it. `rejected` indicates the dealer did not accept the lead (e.g. consent invalid, vehicle no longer available, dealer not serving the buyer's region)."
        },
        "appointment": {
          "type": "object",
          "description": "Present iff the request included an `appointment` block AND the dealer is acknowledging it (whether confirming, proposing alternatives, leaving it as requested for staff follow-up, or rejecting).",
          "properties": {
            "appointment_id": {
              "type": "string",
              "description": "Dealer-assigned identifier for this appointment."
            },
            "status": {
              "type": "string",
              "enum": ["requested", "proposed", "confirmed", "rejected"],
              "description": "Appointment status. `requested` = received but not yet scheduled (staff will follow up). `proposed` = dealer cannot honor the requested time but is offering alternatives in `proposed_times`. `confirmed` = dealer scheduled the appointment for `confirmed_at`. `rejected` = dealer cannot host this appointment (e.g. service unavailable)."
            },
            "confirmed_at": {
              "type": "string",
              "format": "date-time",
              "description": "Present iff `status` is `confirmed`. The scheduled start time as an ISO 8601 / RFC 3339 timestamp with timezone offset."
            },
            "proposed_times": {
              "type": "array",
              "description": "Present iff `status` is `proposed`. Alternative start times the dealer offers, each an ISO 8601 / RFC 3339 timestamp with timezone offset.",
              "minItems": 1,
              "items": { "type": "string", "format": "date-time" }
            }
          },
          "required": ["appointment_id", "status"],
          "additionalProperties": false
        },
        "dealer": {
          "type": "object",
          "description": "Convenience contact summary for the buyer agent to surface follow-up details to the user.",
          "properties": {
            "name": { "type": "string" },
            "phone": {
              "type": "string",
              "pattern": "^\\+[1-9]\\d{1,14}$",
              "description": "E.164 phone number for buyer follow-up."
            }
          },
          "additionalProperties": false
        }
      },
      "required": ["lead_id", "status"],
      "additionalProperties": false
    },
    "message": {
      "type": "string",
      "maxLength": 2000,
      "description": "Contextual note from the dealer (e.g. 'A salesperson will call within 1 business hour.', 'We are unable to honor your requested time; please pick from the alternatives.')."
    }
  },
  "required": ["type", "data"],
  "additionalProperties": false
}
