{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.netify.ai/developer/agent/v5/schemas/netify-config-sink-mqtt.json",
  "title": "Netify Sink MQTT Configuration",
  "description": "JSON Schema for the Netify Sink MQTT Plugin configuration.",
  "type": "object",
  "required": ["topic"],
  "properties": {
    "host": {
      "type": "string",
      "format": "hostname",
      "default": "localhost",
      "description": "MQTT server hostname or IP address."
    },
    "port": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535,
      "default": 1883,
      "description": "Port used to connect to the MQTT server (typically 1883 for TCP or 8883 for SSL)."
    },
    "user": {
      "type": "string",
      "description": "Username used to authenticate with the MQTT server."
    },
    "pass": {
      "type": "string",
      "writeOnly": true,
      "description": "Password used to authenticate with the MQTT server."
    },
    "topic": {
      "type": "string",
      "description": "Topic to publish messages to. Supports template variables.",
      "pattern": "^[a-zA-Z0-9/\\._\\-${}]+$",
      "examples": ["netify/${uuid_agent}/${channel}"]
    },
    "message_qos": {
      "type": "integer",
      "enum": [0, 1, 2],
      "default": 1,
      "description": "QoS level: 0 (At most once), 1 (At least once), 2 (Exactly once)."
    },
    "message_retain": {
      "type": "boolean",
      "default": false,
      "description": "When true, the broker retains the last message on the topic for new subscribers."
    },
    "tls_insecure": {
      "type": "boolean",
      "default": false,
      "description": "If true, validates the remote server's SSL/TLS certificate."
    },
    "ca_file": {
      "type": "string",
      "description": "Path to the Certificate Authority file."
    },
    "ca_path": {
      "type": "string",
      "description": "Path to the directory containing Certificate Authority files."
    },
    "client_cert_file": {
      "type": "string",
      "description": "Path to the client certificate file."
    },
    "client_key_file": {
      "type": "string",
      "description": "Path to the client private key file."
    }
  },
  "examples": [
    {
      "host": "mq.example.com",
      "port": 1883,
      "user": "nobody",
      "pass": "secret",
      "topic": "netify/${channel}/${uuid_agent}",
      "message_qos": 1,
      "message_retain": false
    }
  ]
}
