{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "/schemas/3.1.0-rc.4/content-standards/create-content-standards-request.json",
  "title": "Create Content Standards Request",
  "description": "Request parameters for creating a new content standards configuration",
  "type": "object",
  "allOf": [
    {
      "$ref": "/schemas/3.1.0-rc.4/core/version-envelope.json"
    }
  ],
  "x-mutates-state": true,
  "properties": {
    "scope": {
      "type": "object",
      "description": "Where this standards configuration applies",
      "properties": {
        "countries_all": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "description": "ISO 3166-1 alpha-2 country codes. Standards apply in ALL listed countries (AND logic)."
        },
        "channels_any": {
          "type": "array",
          "items": {
            "$ref": "/schemas/3.1.0-rc.4/enums/channels.json"
          },
          "minItems": 1,
          "description": "Advertising channels. Standards apply to ANY of the listed channels (OR logic)."
        },
        "languages_any": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "description": "BCP 47 language tags (e.g., 'en', 'de', 'fr'). Standards apply to content in ANY of these languages (OR logic). Content in unlisted languages is not covered by these standards."
        },
        "description": {
          "type": "string",
          "description": "Human-readable description of this scope"
        }
      },
      "required": [
        "languages_any"
      ]
    },
    "registry_policy_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "x-entity": "governance_registry_policy"
      },
      "description": "Registry policy IDs to use as the evaluation basis for this content standard. When provided, the agent resolves policies from the registry and uses their policy text and exemplars as the evaluation criteria. The 'policy' field becomes optional when registry_policy_ids is provided."
    },
    "policies": {
      "type": "array",
      "description": "Bespoke policies for this content-standards configuration, using the same shape as registry entries. Each policy is addressable by policy_id and carries its own enforcement (must|should); governance findings reference the policy_id that triggered them. Inline bespoke policies can omit version/name/category (defaulted by the server). Combines with registry_policy_ids — registry policies and bespoke policies are both evaluated. Bespoke policy_ids MUST be flat (no colons/slashes) to avoid collision with namespaced registry ids.",
      "items": {
        "$ref": "/schemas/3.1.0-rc.4/governance/policy-entry.json"
      },
      "minItems": 1
    },
    "calibration_exemplars": {
      "type": "object",
      "description": "Training/test set to calibrate policy interpretation. Use URL references for pages to be fetched and analyzed, or full artifacts for pre-extracted content.",
      "properties": {
        "pass": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "object",
                "description": "URL reference - specific page to fetch and evaluate",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "url",
                    "description": "Indicates this is a URL reference"
                  },
                  "value": {
                    "type": "string",
                    "format": "uri",
                    "description": "Full URL to a specific page (e.g., 'https://espn.com/nba/story/_/id/12345/lakers-win')"
                  },
                  "language": {
                    "type": "string",
                    "description": "BCP 47 language tag for content at this URL"
                  }
                },
                "required": [
                  "type",
                  "value"
                ]
              },
              {
                "$ref": "/schemas/3.1.0-rc.4/content-standards/artifact.json",
                "description": "Full artifact with pre-extracted content (text, images, video, audio)"
              }
            ]
          },
          "description": "Content that passes the standards"
        },
        "fail": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "object",
                "description": "URL reference - specific page to fetch and evaluate",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "url",
                    "description": "Indicates this is a URL reference"
                  },
                  "value": {
                    "type": "string",
                    "format": "uri",
                    "description": "Full URL to a specific page (e.g., 'https://news.example.com/controversial-article')"
                  },
                  "language": {
                    "type": "string",
                    "description": "BCP 47 language tag for content at this URL"
                  }
                },
                "required": [
                  "type",
                  "value"
                ]
              },
              {
                "$ref": "/schemas/3.1.0-rc.4/content-standards/artifact.json",
                "description": "Full artifact with pre-extracted content (text, images, video, audio)"
              }
            ]
          },
          "description": "Content that fails the standards"
        }
      }
    },
    "idempotency_key": {
      "type": "string",
      "description": "Client-generated unique key for this request. Prevents duplicate content standards creation on retries. MUST be unique per (seller, request) pair to prevent cross-seller correlation. Use a fresh UUID v4 for each request.",
      "minLength": 16,
      "maxLength": 255,
      "pattern": "^[A-Za-z0-9_.:-]{16,255}$"
    },
    "context": {
      "$ref": "/schemas/3.1.0-rc.4/core/context.json"
    },
    "ext": {
      "$ref": "/schemas/3.1.0-rc.4/core/ext.json"
    }
  },
  "required": [
    "idempotency_key",
    "scope"
  ],
  "anyOf": [
    {
      "required": [
        "policies"
      ]
    },
    {
      "required": [
        "registry_policy_ids"
      ]
    }
  ],
  "additionalProperties": true
}
