{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api-evangelist.com/schemas/gladly/gladly-customer-schema.json",
  "title": "Gladly Customer",
  "description": "Schema for a Customer resource in the Gladly REST API. Customers are the unified profile that Gladly builds for every end-customer interacting with a brand across channels (voice, chat, SMS, email, social).",
  "type": "object",
  "required": ["id"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Gladly-assigned unique identifier for the customer."
    },
    "name": {
      "type": "string",
      "description": "Display name for the customer."
    },
    "emails": {
      "type": "array",
      "description": "Email addresses associated with the customer.",
      "items": {
        "type": "object",
        "properties": {
          "original": {"type": "string", "format": "email"},
          "normalized": {"type": "string", "format": "email"},
          "primary": {"type": "boolean"}
        }
      }
    },
    "phones": {
      "type": "array",
      "description": "Phone numbers associated with the customer.",
      "items": {
        "type": "object",
        "properties": {
          "original": {"type": "string"},
          "normalized": {"type": "string", "description": "E.164 normalized phone number."},
          "type": {"type": "string", "enum": ["MOBILE", "HOME", "WORK", "OTHER"]},
          "regionCode": {"type": "string"},
          "primary": {"type": "boolean"}
        }
      }
    },
    "address": {
      "type": "string",
      "description": "Postal address as a single string."
    },
    "externalCustomerId": {
      "type": "string",
      "description": "Identifier from an external system of record (e-commerce, CRM, etc)."
    },
    "customAttributes": {
      "type": "object",
      "description": "Arbitrary key/value pairs the brand attaches to the customer profile.",
      "additionalProperties": true
    },
    "channels": {
      "type": "array",
      "description": "Channels the customer can be reached on.",
      "items": {
        "type": "object",
        "properties": {
          "type": {"type": "string", "enum": ["EMAIL", "VOICE", "SMS", "CHAT", "FACEBOOK", "INSTAGRAM", "WHATSAPP"]},
          "address": {"type": "string"}
        }
      }
    },
    "createdAt": {"type": "string", "format": "date-time"},
    "modifiedAt": {"type": "string", "format": "date-time"}
  }
}
