{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/gajo-io/json-schema/gajo-io-routing-rule-result-schema.json",
  "title": "RoutingRuleResult",
  "description": "Envelope with one routing rule.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/gajo-io-routing-rules-api-openapi.yml#/components/schemas/RoutingRuleResult",
  "allOf": [
    {
      "$ref": "#/$defs/ApiResult"
    },
    {
      "type": "object",
      "required": [
        "data"
      ],
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "$ref": "#/$defs/RoutingRule"
        }
      }
    }
  ],
  "$defs": {
    "ApiResult": {
      "type": "object",
      "description": "Envelope shared by every response.",
      "required": [
        "success"
      ],
      "properties": {
        "success": {
          "type": "boolean",
          "description": "`true` when the request succeeded."
        },
        "message": {
          "type": [
            "string",
            "null"
          ],
          "description": "Human-readable status or error message. Often `null` on reads."
        },
        "data": {
          "description": "Operation-specific payload; `null` or absent when there is nothing to return."
        }
      }
    },
    "DeviceClass": {
      "type": "string",
      "enum": [
        "Mobile",
        "Tablet",
        "Desktop"
      ],
      "description": "Device class for per-URL `Device` rules."
    },
    "RoutingRule": {
      "type": "object",
      "required": [
        "id",
        "ruleType",
        "priority",
        "active",
        "deviceType",
        "targetUrl",
        "variantName",
        "splitPercentage",
        "createdDate"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "description": "Rule ID, used by `PUT`/`DELETE /urls/{code}/routing/{ruleId}`."
        },
        "ruleType": {
          "$ref": "#/$defs/RoutingType"
        },
        "priority": {
          "type": "integer",
          "minimum": 0,
          "description": "Position within the batch the rule was created in (0-based)."
        },
        "active": {
          "type": "boolean"
        },
        "deviceType": {
          "oneOf": [
            {
              "$ref": "#/$defs/DeviceClass"
            },
            {
              "type": "null"
            }
          ],
          "description": "Set on `Device` rules; `null` on `AbTest` rules."
        },
        "targetUrl": {
          "type": "string",
          "description": "Destination for matching clicks."
        },
        "variantName": {
          "type": [
            "string",
            "null"
          ],
          "description": "Set on `AbTest` rules."
        },
        "splitPercentage": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1,
          "maximum": 100,
          "description": "Set on `AbTest` rules."
        },
        "createdDate": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "RoutingType": {
      "type": "string",
      "enum": [
        "Device",
        "AbTest"
      ],
      "description": "`Device` routes by device class; `AbTest` splits traffic by percentage."
    }
  }
}