{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/coldleads-app/json-schema/coldleads-app-lead-context-schema.json",
  "title": "LeadContext",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/coldleads-app-openapi.json#/components/schemas/LeadContext",
  "type": "object",
  "properties": {
    "lead": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "company": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "stage": {
          "type": "string",
          "enum": [
            "cold",
            "subscriber",
            "lead",
            "customer",
            "regular"
          ]
        },
        "source": {
          "type": "string"
        },
        "tags": {
          "type": "string"
        },
        "notes": {
          "type": "string"
        },
        "owner": {
          "type": [
            "string",
            "null"
          ]
        },
        "deal_value": {
          "type": [
            "number",
            "null"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "contactability": {
      "type": "object",
      "properties": {
        "do_not_contact": {
          "type": "boolean"
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "opted_out",
              "bounced",
              "do_not_contact_list",
              "consent_withdrawn"
            ]
          }
        },
        "consent": {
          "type": "string"
        },
        "email_verification": {
          "type": [
            "object",
            "null"
          ]
        },
        "safe_to_contact": {
          "type": "boolean"
        }
      }
    },
    "relationship": {
      "type": "object",
      "properties": {
        "sent_messages": {
          "type": "integer"
        },
        "received_replies": {
          "type": "integer"
        },
        "campaign_templates_received": {
          "type": "integer"
        },
        "last_contacted_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "last_reply_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "last_reply_class": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "positive",
            "neutral",
            "negative",
            "unsubscribe",
            "auto",
            null
          ]
        },
        "last_reply_tag": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "meeting",
            "pricing",
            "objection",
            "referral",
            "not_now",
            "question",
            null
          ]
        },
        "awaiting_our_reply": {
          "type": "boolean"
        }
      }
    },
    "next_action": {
      "type": "object",
      "properties": {
        "action": {
          "type": "string",
          "enum": [
            "reply",
            "close",
            "follow_up",
            "follow_up_later",
            "none"
          ]
        },
        "due_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "reason": {
          "type": "string"
        },
        "source": {
          "type": "string",
          "enum": [
            "reply_waiting",
            "scheduled",
            "none"
          ]
        }
      }
    },
    "recent_messages": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "direction": {
            "type": "string",
            "enum": [
              "in",
              "out"
            ]
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "subject": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "reply_class": {
            "type": [
              "string",
              "null"
            ]
          },
          "reply_tag": {
            "type": [
              "string",
              "null"
            ]
          },
          "channel": {
            "type": "string"
          }
        }
      }
    }
  }
}