{
  "$defs": {
    "CustomerKind": {
      "description": "Customer kind.",
      "oneOf": [
        {
          "const": "b2b",
          "description": "Business-to-business (legal entity counterparty).",
          "type": "string"
        },
        {
          "const": "b2c",
          "description": "Business-to-consumer (natural person counterparty).",
          "type": "string"
        },
        {
          "const": "creator_collaborator",
          "description": "Creator collaborator (BDR 0054).",
          "type": "string"
        },
        {
          "const": "internal_tenant",
          "description": "Internal / dogfooding tenant.",
          "type": "string"
        },
        {
          "const": "public_sector",
          "description": "Government / public sector.",
          "type": "string"
        },
        {
          "const": "education",
          "description": "Educational institution.",
          "type": "string"
        },
        {
          "const": "non_profit",
          "description": "Non-profit / NGO.",
          "type": "string"
        }
      ]
    },
    "CustomerStatus": {
      "description": "Lifecycle.",
      "oneOf": [
        {
          "enum": [
            "trial",
            "active",
            "paused",
            "archived"
          ],
          "type": "string"
        },
        {
          "const": "churned",
          "description": "Voluntary cancellation.",
          "type": "string"
        },
        {
          "const": "terminated",
          "description": "Involuntary cancellation (non-payment, ToS).",
          "type": "string"
        }
      ]
    },
    "CustomerTier": {
      "description": "Tier (segmentation / pricing band).",
      "oneOf": [
        {
          "enum": [
            "starter",
            "growth",
            "enterprise"
          ],
          "type": "string"
        },
        {
          "const": "business",
          "description": "Strategic enterprise / mid-market.",
          "type": "string"
        },
        {
          "const": "strategic",
          "description": "Strategic logo (lighthouse account).",
          "type": "string"
        }
      ]
    },
    "IsoCountry": {
      "description": "ISO 3166-1 alpha-2 country code.",
      "pattern": "^[A-Z]{2}$",
      "type": "string"
    },
    "IsoCurrency": {
      "description": "ISO 4217 currency code.",
      "pattern": "^[A-Z]{3}$",
      "type": "string"
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "type": "string"
    },
    "Lei": {
      "description": "ISO 17442 Legal Entity Identifier (20-character alphanumeric).",
      "pattern": "^[A-Z0-9]{18}[0-9]{2}$",
      "type": "string"
    },
    "PathRef": {
      "description": "Path-based cross-reference relative to .corpospec/ root.\nPattern: `^[a-z0-9_-]+(/[a-z0-9_.-]+)+$`",
      "pattern": "^[a-z0-9_-]+(/[a-z0-9_.-]+)+$",
      "type": "string"
    },
    "PiiClass": {
      "description": "Personal-data classification on every record carrying personal data, per\nBDR 0070 / BDR 0069 / BDR 0078. Used by `corpospec-report` to gate\nrendering and by the privacy pillar's RoPA records to determine\nsafeguards.",
      "oneOf": [
        {
          "const": "none",
          "description": "No personal data.",
          "type": "string"
        },
        {
          "const": "public_personal",
          "description": "Public personal data (already disclosed by the subject, e.g. CEO name).",
          "type": "string"
        },
        {
          "const": "internal",
          "description": "Internal-only personal data (employee directory).",
          "type": "string"
        },
        {
          "const": "personal",
          "description": "Personal data per GDPR Art. 4(1).",
          "type": "string"
        },
        {
          "const": "special_category",
          "description": "Special-category data per GDPR Art. 9 (health, biometric, genetic,\nreligion, ethnicity, sex life, political opinion, trade union).",
          "type": "string"
        },
        {
          "const": "criminal_data",
          "description": "Criminal data per GDPR Art. 10.",
          "type": "string"
        },
        {
          "const": "sensitive",
          "description": "CCPA / CPRA \"sensitive personal information\".",
          "type": "string"
        }
      ]
    },
    "PostalAddress": {
      "description": "Physical address aligned with schema.org PostalAddress.",
      "properties": {
        "city": {
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "$ref": "#/$defs/IsoCountry"
        },
        "postal_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "state": {
          "type": [
            "string",
            "null"
          ]
        },
        "street": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "country"
      ],
      "type": "object"
    },
    "TaxIdentifier": {
      "description": "Billing identifier (tax / VAT).",
      "properties": {
        "issuing_country": {
          "$ref": "#/$defs/IsoCountry"
        },
        "kind": {
          "description": "Identifier kind (e.g. \"vat_id\", \"ein\", \"ust_id\", \"abn\").",
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "value",
        "issuing_country"
      ],
      "type": "object"
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/customer.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Customer master record.",
  "properties": {
    "account_owner": {
      "$ref": "#/$defs/PathRef",
      "description": "Account-owner (PathRef to people/team/...)."
    },
    "acv_amount": {
      "description": "Annual contract value (None for month-to-month).",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "billing_address": {
      "$ref": "#/$defs/PostalAddress",
      "description": "Billing address."
    },
    "churned_at": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ]
    },
    "customer_dpa_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to the DPA we entered into as processor for this\ncustomer's data."
    },
    "display_name": {
      "description": "Legal name (B2B) OR pseudonymised reference (B2C).",
      "type": "string"
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "jurisdiction": {
      "$ref": "#/$defs/IsoCountry"
    },
    "kind": {
      "$ref": "#/$defs/CustomerKind"
    },
    "legal_name": {
      "description": "Legal name (always present for B2B; None for B2C to honour\ndata minimisation).",
      "type": [
        "string",
        "null"
      ]
    },
    "lei": {
      "anyOf": [
        {
          "$ref": "#/$defs/Lei"
        },
        {
          "type": "null"
        }
      ],
      "description": "LEI per ISO 17442 (B2B)."
    },
    "master_subscription_agreement": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to active master subscription agreement."
    },
    "mrr_amount": {
      "format": "double",
      "type": "number"
    },
    "mrr_currency": {
      "$ref": "#/$defs/IsoCurrency",
      "description": "Monthly recurring revenue (in plan currency)."
    },
    "onboarded_at": {
      "$ref": "#/$defs/IsoDate"
    },
    "pii_class": {
      "$ref": "#/$defs/PiiClass",
      "description": "PII class for this record (B2C usually Personal; B2B Internal)."
    },
    "pricing_plan_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "Subscription / pricing plan reference."
    },
    "status": {
      "$ref": "#/$defs/CustomerStatus"
    },
    "success_owner": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "Customer-success owner (None ⇒ same as account_owner)."
    },
    "tax_address": {
      "anyOf": [
        {
          "$ref": "#/$defs/PostalAddress"
        },
        {
          "type": "null"
        }
      ],
      "description": "Tax address (often equal to billing)."
    },
    "tax_ids": {
      "items": {
        "$ref": "#/$defs/TaxIdentifier"
      },
      "type": "array"
    },
    "tier": {
      "$ref": "#/$defs/CustomerTier"
    }
  },
  "required": [
    "id",
    "kind",
    "tier",
    "status",
    "display_name",
    "jurisdiction",
    "billing_address",
    "mrr_currency",
    "mrr_amount",
    "account_owner",
    "onboarded_at",
    "pii_class"
  ],
  "title": "Customer",
  "type": "object",
  "x-corpospec-pillar": "market"
}