{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/affise/main/json-schema/affise-targeting-group-structure-schema.json",
  "title": "targeting_group_structure",
  "description": "Targeting group structure",
  "x-generated": "2026-10-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/affise-admin-offers-api-openapi.yml#/components/schemas/targeting_group_structure",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "id in UUID format"
    },
    "enabled": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "enable/disable targeting group"
    },
    "name": {
      "type": "string",
      "description": "name for targeting group"
    },
    "condition": {
      "type": "string",
      "enum": [
        "and",
        "or"
      ],
      "description": "condition for rules in targeting group"
    },
    "country": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "description": "list of allowed/denied countries. Example: country[allow][]=US"
    },
    "region": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        },
        "deny": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        }
      },
      "description": "list of allowed/denied regions for chosen country(ISO). Example: region[allow][US]=33"
    },
    "city": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        },
        "deny": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        }
      },
      "description": "list of allowed/denied cities for chosen country(ISO). Example: city[allow][US]=57"
    },
    "os": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/targeting_os_structure"
          }
        }
      },
      "description": "list of allowed OSes and them versions."
    },
    "os_deny": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "default": 0,
      "description": "When set to 1 blocks values listed in os"
    },
    "isp": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "deny": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "description": "list of allowed/denied ISP for chosen country(ISO). Example: isp[allow][US]=Att"
    },
    "isp_organization": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny_empty": {
          "type": "integer",
          "enum": [
            0,
            1
          ]
        }
      },
      "description": "list of allowed ISP organizations. Set deny_empty to block empty isp organizations."
    },
    "ip": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "ipv6_deny": {
          "type": "integer",
          "enum": [
            0,
            1
          ]
        }
      },
      "description": "list of allowed/denied ip ranges (IPv4 , IPv6)."
    },
    "device_type": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "mobile",
          "tablet",
          "desktop",
          "mediahub",
          "ereader",
          "console",
          "tv",
          "smartwatch"
        ]
      },
      "description": "list of allowed device types."
    },
    "device_type_deny": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "default": 0,
      "description": "When set to 1 blocks values listed in device_type"
    },
    "device_model": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "description": "list of allowed/denied device models."
    },
    "browser_version": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/targeting_browser_version_structure"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/targeting_browser_version_structure"
          }
        }
      },
      "description": "list of allowed/denied browsers and their versions."
    },
    "browser": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "description": "list of allowed/denied browsers. Example: browser[deny][] = \"Edge\""
    },
    "brand": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "description": "list of allowed/denied device brands. Example: brand[deny][] = \"SAMTEL\""
    },
    "sub": {
      "type": "object",
      "description": "Complex sub-account targeting rules."
    },
    "connection": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "wi-fi",
          "cellular"
        ]
      },
      "description": "list of allowed connection types."
    },
    "connection_deny": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "default": 0,
      "description": "When set to 1 blocks values listed in connection"
    },
    "block_proxy": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "enable/disable \"Click-level Anti-fraud\" feature"
    },
    "block_known_bots": {
      "type": "integer",
      "enum": [
        0,
        1
      ],
      "description": "enable/disable blocking of known bots"
    },
    "affiliate_id": {
      "type": "array",
      "items": {
        "type": "integer"
      },
      "description": "list of affiliates for personal targeting groups."
    },
    "url": {
      "type": "string",
      "description": "Additional Tracking URL"
    },
    "urls": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/targeting_url_weight"
      },
      "description": "URLs with weights for traffic redistribution between several track-links"
    },
    "referrer": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny_empty": {
          "type": "integer",
          "enum": [
            0,
            1
          ]
        },
        "is_regexp": {
          "type": "integer",
          "enum": [
            0,
            1
          ],
          "description": "Set to 1 to enable regular expressions in allow or deny values"
        }
      },
      "description": "list of allowed/denied referrers. Set deny_empty to block empty referrers. Set is_regexp to enable regular expressions in allow or deny values."
    },
    "ua": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny_crawlers": {
          "type": "integer",
          "enum": [
            0,
            1
          ]
        }
      },
      "description": "list of allowed/denied user agents. Set deny_crawlers to block known crawlers."
    },
    "zip": {
      "type": "object",
      "properties": {
        "allow": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "deny": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "description": "list of zip codes"
    },
    "macros_replacement": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "description": "Available if the Macros Replacement feature is enabled. Example of the structure: macros_replacement[sub1][]=value"
    },
    "macros_replacement_enabled": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Available if the Macros Replacement feature is enabled."
    }
  },
  "$defs": {
    "targeting_browser_version_structure": {
      "type": "object",
      "description": "Browser version structure for targeting",
      "properties": {
        "name": {
          "type": "string",
          "description": "Browser's name."
        },
        "comparison": {
          "type": "string",
          "enum": [
            "LT",
            "LTE",
            "EQ",
            "GT",
            "GTE"
          ],
          "description": "Comparison operation for browser's version."
        },
        "version": {
          "type": "string",
          "description": "Browser's version for comparison."
        }
      }
    },
    "targeting_os_structure": {
      "type": "object",
      "description": "OS structure for targeting",
      "properties": {
        "name": {
          "type": "string",
          "description": "OS name that could be found at OSes list method."
        },
        "comparison": {
          "type": "string",
          "enum": [
            "LT",
            "LTE",
            "EQ",
            "GT",
            "GTE"
          ],
          "description": "Comparison operation for OS version."
        },
        "version": {
          "type": "string",
          "description": "OS version for comparison."
        }
      }
    },
    "targeting_url_weight": {
      "type": "object",
      "description": "URL with weight for traffic redistribution",
      "properties": {
        "url": {
          "type": "string",
          "description": "Tracking URL. Example: additional_impression_destination_urls[0][url]=example.com"
        },
        "weight": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "description": "track-link weight. Example: additional_impression_destination_urls[0][weight]=50"
        }
      }
    }
  }
}