{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://globaladalliance.com/downloads/schemas/ms-rtb-bid-request.schema.json",
  "title": "MS-RTB BidRequest v1.0",
  "type": "object",
  "additionalProperties": false,
  "required": ["request_id", "timestamp_ms", "tmax_ms", "inventory", "ad_slots"],
  "properties": {
    "request_id": { "type": "string", "minLength": 8, "description": "UUIDv7" },
    "timestamp_ms": { "type": "integer" },
    "tmax_ms": { "type": "integer", "minimum": 1, "maximum": 10000 },
    "auth": { "$ref": "#/$defs/SupplyChainSignature" },
    "inventory": { "$ref": "#/$defs/InventoryContext" },
    "ad_slots": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/AdSlot" } },
    "privacy": { "$ref": "#/$defs/PrivacyContext" },
    "agent": { "$ref": "#/$defs/AgentMetadata" },
    "green": { "$ref": "#/$defs/GreenMetrics" }
  },
  "$defs": {
    "SupplyChainSignature": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "seller_id": { "type": "string" },
        "node_id": { "type": "string" },
        "signature": { "type": "string", "contentEncoding": "base64" },
        "schain_digest": { "type": "string" }
      }
    },
    "InventoryContext": {
      "type": "object",
      "additionalProperties": false,
      "required": ["channel", "domain_or_bundle", "country_iso"],
      "properties": {
        "channel": { "type": "string", "enum": ["WEB", "MOBILE_APP", "CTV_OTT", "AI_CHAT_LLM", "GAMING_METAVERSE"] },
        "domain_or_bundle": { "type": "string" },
        "contextual_tags": { "type": "array", "items": { "type": "string" } },
        "language": { "type": "string" },
        "country_iso": { "type": "string", "pattern": "^[A-Z]{2}$" }
      }
    },
    "AdSlot": {
      "type": "object",
      "additionalProperties": false,
      "required": ["slot_id", "format"],
      "properties": {
        "slot_id": { "type": "string" },
        "width": { "type": "integer", "minimum": 0 },
        "height": { "type": "integer", "minimum": 0 },
        "bid_floor_usd": { "type": "number", "minimum": 0 },
        "format": { "type": "string", "enum": ["banner", "native", "video", "audio", "sponsored_prompt"] }
      }
    },
    "PrivacyContext": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "cookieless_mode": { "type": "boolean" },
        "gdpr_consent_hash": { "type": "string" },
        "zk_cohort_token": { "type": "string" }
      }
    },
    "AgentMetadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "is_agentic_request": { "type": "boolean" },
        "agent_protocol": { "type": "string" },
        "intent_embedding_id": { "type": "string" },
        "allow_dynamic_creative": { "type": "boolean" }
      }
    },
    "GreenMetrics": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "hop_count": { "type": "integer", "minimum": 0 },
        "estimated_gco2e": { "type": "number", "minimum": 0 }
      }
    }
  }
}