{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/past-dev/json-schema/past-dev-put-audience-request-schema.json",
  "title": "PutAudienceRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/past-dev-audiences-api-openapi.yml#/components/schemas/PutAudienceRequest",
  "type": "object",
  "required": [
    "kind"
  ],
  "additionalProperties": false,
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "fixed",
        "rule"
      ]
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Defaults to the slug on create."
    },
    "identities": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 200
      },
      "description": "Required for a fixed audience. An empty list reaches nobody. An id with no record is created."
    },
    "rule": {
      "$ref": "#/$defs/AudienceRule"
    }
  },
  "$defs": {
    "AudienceCondition": {
      "type": "object",
      "required": [
        "trait",
        "operator"
      ],
      "additionalProperties": false,
      "properties": {
        "trait": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "operator": {
          "type": "string",
          "enum": [
            "is",
            "is_not",
            "is_one_of",
            "is_not_one_of",
            "exists",
            "does_not_exist"
          ]
        },
        "values": {
          "type": "array",
          "maxItems": 50,
          "items": {
            "type": "string"
          },
          "description": "One value for is and is_not, 1 to 50 for is_one_of and is_not_one_of, none for exists and does_not_exist."
        }
      }
    },
    "AudienceRule": {
      "type": "object",
      "required": [
        "match",
        "conditions"
      ],
      "additionalProperties": false,
      "properties": {
        "match": {
          "type": "string",
          "enum": [
            "all",
            "any"
          ]
        },
        "conditions": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "items": {
            "$ref": "#/$defs/AudienceCondition"
          }
        }
      }
    }
  }
}