{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/machinesignal-it/json-schema/machinesignal-it-lead-opportunity-score-response-schema.json",
  "title": "LeadOpportunityScoreResponse",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/machinesignal-it-openapi.json#/components/schemas/LeadOpportunityScoreResponse",
  "type": "object",
  "required": [
    "domain",
    "opportunity_score",
    "confidence",
    "decision",
    "usage"
  ],
  "properties": {
    "domain": {
      "type": "string"
    },
    "opportunity_score": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "decision": {
      "type": "string",
      "enum": [
        "discard",
        "watchlist",
        "review",
        "prioritize"
      ]
    },
    "priority": {
      "type": "string",
      "enum": [
        "low",
        "medium",
        "high"
      ]
    },
    "reason": {
      "type": "string"
    },
    "suggested_route": {
      "type": "string"
    },
    "product_code": {
      "type": "string",
      "const": "MS-DEC-250"
    },
    "request_id": {
      "type": "string"
    },
    "decision_contract": {
      "$ref": "#/$defs/DecisionContractPointer"
    },
    "usage": {
      "$ref": "#/$defs/UsageEnvelope"
    },
    "scope": {
      "type": "string",
      "const": "b2b_italy_controlled"
    },
    "checkout_public": {
      "type": "boolean",
      "const": false
    },
    "payment_executed": {
      "type": "boolean",
      "const": false
    },
    "invoice_issued": {
      "type": "boolean",
      "const": false
    },
    "external_contact_executed": {
      "type": "boolean",
      "const": false
    }
  },
  "$defs": {
    "DecisionContractPointer": {
      "type": "object",
      "properties": {
        "contract_url": {
          "type": "string",
          "format": "uri"
        },
        "route": {
          "type": "string",
          "enum": [
            "discard",
            "watchlist",
            "review",
            "prioritize"
          ]
        },
        "credit_rule": {
          "type": "string"
        },
        "payment_executed": {
          "type": "boolean",
          "const": false
        },
        "invoice_issued": {
          "type": "boolean",
          "const": false
        },
        "external_contact_executed": {
          "type": "boolean",
          "const": false
        }
      }
    },
    "UsageBalance": {
      "type": "object",
      "properties": {
        "product_code": {
          "type": "string",
          "const": "MS-DEC-250"
        },
        "credits_purchased": {
          "type": "integer"
        },
        "credits_used": {
          "type": "integer",
          "minimum": 0
        },
        "credits_remaining": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "UsageEnvelope": {
      "type": "object",
      "properties": {
        "customer_id": {
          "type": "string"
        },
        "ledger_persisted": {
          "type": "boolean"
        },
        "balances": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/UsageBalance"
          }
        },
        "current_event": {
          "$ref": "#/$defs/UsageEvent"
        },
        "rule": {
          "type": "string"
        },
        "real_payment_executed": {
          "type": "boolean",
          "const": false
        },
        "external_contact_executed": {
          "type": "boolean",
          "const": false
        }
      }
    },
    "UsageEvent": {
      "type": "object",
      "properties": {
        "product_code": {
          "type": "string",
          "const": "MS-DEC-250"
        },
        "status": {
          "type": "string",
          "enum": [
            "valid_output",
            "not_consumed"
          ]
        },
        "credits_consumed": {
          "type": "integer",
          "minimum": 0
        },
        "request_id": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        },
        "credits_remaining": {
          "type": "integer",
          "minimum": 0
        }
      }
    }
  }
}