{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/prosperstack/main/json-schema/prosperstack-subscriber-schema.json",
  "title": "Subscriber",
  "x-generated": "2026-10-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/prosperstack-openapi.json#/components/schemas/Subscriber",
  "type": "object",
  "required": [
    "id",
    "platform_id",
    "name",
    "email",
    "status",
    "properties",
    "data",
    "created_at",
    "updated_at"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "platform_id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "canceled",
        "converted",
        "deflected",
        "inactive",
        "reactivated",
        "recovered",
        "saved"
      ]
    },
    "properties": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SubscriberPropertyValue"
      }
    },
    "data": {
      "type": "object",
      "description": "Additional data about the subscriber from the connected subscription platform"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "SubscriberProperty": {
      "type": "object",
      "required": [
        "id",
        "key",
        "name",
        "entity",
        "type",
        "format"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "key": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "entity": {
          "type": "string",
          "enum": [
            "subscriber"
          ]
        },
        "type": {
          "type": "string",
          "enum": [
            "text",
            "number",
            "boolean",
            "date"
          ]
        },
        "format": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "number",
            "currency"
          ]
        }
      }
    },
    "SubscriberPropertyValue": {
      "type": "object",
      "required": [
        "property",
        "value",
        "formatted_value"
      ],
      "properties": {
        "property": {
          "$ref": "#/$defs/SubscriberProperty"
        },
        "value": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            }
          ]
        },
        "formatted_value": {
          "type": "string"
        }
      }
    }
  }
}