{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://api.chargedesk.com/v1/schema/customer",
  "title": "Customer",
  "description": "A customer billing record in ChargeDesk",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique identifier assigned by ChargeDesk"
    },
    "object": {
      "type": "string",
      "const": "customer"
    },
    "customer_id": {
      "type": "string",
      "description": "Customer identifier (from your system or gateway)"
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "Customer email address"
    },
    "name": {
      "type": "string",
      "description": "Customer full name"
    },
    "phone": {
      "type": "string",
      "description": "Customer phone number"
    },
    "username": {
      "type": "string",
      "description": "Customer username in your system"
    },
    "customer_company": {
      "type": "string",
      "description": "Company or organization name"
    },
    "website": {
      "type": "string",
      "format": "uri",
      "description": "Customer website URL"
    },
    "description": {
      "type": "string",
      "description": "Notes or description about the customer"
    },
    "country": {
      "type": "string",
      "description": "2-letter ISO country code",
      "minLength": 2,
      "maxLength": 2
    },
    "delinquent": {
      "type": "boolean",
      "description": "Whether the customer has failed payments"
    },
    "card_on_file": {
      "type": "boolean",
      "description": "Whether the customer has a card on file"
    },
    "tax_number": {
      "type": "string",
      "description": "Customer tax identification number"
    },
    "billing_address": {
      "type": "object",
      "description": "Customer billing address",
      "properties": {
        "line1": { "type": "string" },
        "line2": { "type": "string" },
        "city": { "type": "string" },
        "state": { "type": "string" },
        "postal_code": { "type": "string" },
        "country": { "type": "string" }
      }
    },
    "invoice_details": {
      "type": "string",
      "description": "Custom invoice details or notes"
    },
    "metadata": {
      "type": "object",
      "description": "Arbitrary key-value metadata",
      "additionalProperties": { "type": "string" }
    }
  },
  "required": ["customer_id"]
}
