{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/gajo-io/json-schema/gajo-io-bind-request-schema.json",
  "title": "BindRequest",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/gajo-io-openapi.json#/components/schemas/BindRequest",
  "type": "object",
  "required": [
    "templateType",
    "templateName",
    "endpoints"
  ],
  "properties": {
    "templateType": {
      "$ref": "#/$defs/RoutingType",
      "description": "`Device` to bind a route template, `AbTest` to bind an A/B template."
    },
    "templateName": {
      "type": "string",
      "description": "Name of your route template or A/B template."
    },
    "endpoints": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/BindingEndpoint"
      },
      "description": "One endpoint per slot. Device bindings must cover every template slot unless a `Default` endpoint is included; A/B bindings must cover every variant, plus `Variant:Device` endpoints for any variant that chains to a route template."
    },
    "flowJson": {
      "type": [
        "string",
        "null"
      ],
      "description": "Optional layout state for the dashboard's visual Route Builder. API clients can omit it."
    }
  },
  "$defs": {
    "BindingEndpoint": {
      "type": "object",
      "required": [
        "slotKey"
      ],
      "properties": {
        "slotKey": {
          "description": "For `Device` bindings, one of the template's device slots. For `AbTest` bindings, one of the template's variant names, or `Variant:Device` (e.g. `Control:IOS`) for the device destinations of a variant that chains to a route template.",
          "anyOf": [
            {
              "$ref": "#/$defs/DeviceSlot"
            },
            {
              "type": "string",
              "description": "A/B variant name"
            }
          ]
        },
        "targetType": {
          "$ref": "#/$defs/EndpointTarget",
          "default": "Url"
        },
        "targetUrl": {
          "type": "string",
          "maxLength": 2048,
          "description": "Required when `targetType` is `Url`. May be an app deep link (custom scheme)."
        },
        "fallbackUrl": {
          "type": "string",
          "description": "Only when `targetUrl` is an app deep link: web URL (e.g. App Store / Google Play listing) used when the app is not installed."
        },
        "routeTemplateName": {
          "type": "string",
          "description": "With `targetType: RouteTemplate` (A/B bindings): the route template this variant chains to. Add the variant's per-device destinations as endpoints keyed `Variant:Device`, covering every slot of the route template or including `Variant:Default`."
        },
        "endpointName": {
          "type": "string",
          "description": "Optional label for this endpoint."
        }
      }
    },
    "DeviceSlot": {
      "type": "string",
      "enum": [
        "Android",
        "IOS",
        "Mobile",
        "Tablet",
        "Desktop",
        "Default"
      ],
      "description": "Device slot used by route templates and Device bindings. At redirect time OS-specific slots (`Android`, `IOS`) are matched first, then device classes (`Mobile`, `Tablet`, `Desktop`), then `Default` catches everything else."
    },
    "EndpointTarget": {
      "type": "string",
      "enum": [
        "Url",
        "RouteTemplate"
      ],
      "description": "`Url` (default) sends the slot to `targetUrl`. `RouteTemplate` is reserved for chaining an A/B variant to a route template; this is not fully supported yet, so use `Url` targets."
    },
    "RoutingType": {
      "type": "string",
      "enum": [
        "Device",
        "AbTest"
      ],
      "description": "`Device` routes by device class; `AbTest` splits traffic by percentage."
    }
  }
}