{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/media-buy/provide-performance-feedback-response.json",
  "title": "Provide Performance Feedback Response",
  "description": "Response payload for provide_performance_feedback task. Returns either success confirmation OR error information, never both.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/core/version-envelope.json"
    },
    {
      "$ref": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/core/protocol-envelope.json"
    }
  ],
  "oneOf": [
    {
      "title": "ProvidePerformanceFeedbackSuccess",
      "description": "Success response - feedback received and processed",
      "type": "object",
      "properties": {
        "success": {
          "type": "boolean",
          "description": "Whether the performance feedback was successfully received",
          "const": true
        },
        "feedback_id": {
          "type": "string",
          "minLength": 1,
          "x-status": "experimental",
          "description": "Receiver-issued identifier for this immutable assertion. Orchestrator gateways and sellers declaring media_buy.performance_feedback MUST return it; legacy sellers may omit it. The identifier is local to the receiving hop. Use it in supersedes_feedback_id when revising that hop's assertion."
        },
        "application_status": {
          "type": "string",
          "enum": [
            "accepted",
            "applied",
            "not_applied"
          ],
          "x-status": "experimental",
          "description": "Optimizer disposition at response time, distinct from the protocol envelope's task status. accepted means stored and eligible for evaluation, not that optimizer use is guaranteed. applied means incorporated into the seller's optimization inputs. not_applied means evaluated but not incorporated. Sellers declaring reports_application_status MUST return this field."
        },
        "status_reason": {
          "type": "string",
          "maxLength": 500,
          "x-status": "experimental",
          "description": "Human-readable explanation when application_status is not_applied. May also explain material qualifications on accepted feedback."
        },
        "received_at": {
          "type": "string",
          "format": "date-time",
          "x-status": "experimental",
          "description": "When the receiving orchestrator gateway or seller stored the assertion."
        },
        "applied_at": {
          "type": "string",
          "format": "date-time",
          "x-status": "experimental",
          "description": "When the seller incorporated the assertion into its optimization inputs. Present only when application_status is applied."
        },
        "sandbox": {
          "type": "boolean",
          "description": "When true, this response contains simulated data from sandbox mode."
        },
        "context": {
          "$ref": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/core/context.json"
        },
        "ext": {
          "$ref": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/core/ext.json"
        }
      },
      "required": [
        "success"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "application_status": {
                "const": "applied"
              }
            },
            "required": [
              "application_status"
            ]
          },
          "then": {
            "required": [
              "applied_at"
            ]
          },
          "else": {
            "not": {
              "required": [
                "applied_at"
              ]
            }
          }
        },
        {
          "if": {
            "properties": {
              "application_status": {
                "const": "not_applied"
              }
            },
            "required": [
              "application_status"
            ]
          },
          "then": {
            "required": [
              "status_reason"
            ]
          }
        }
      ],
      "additionalProperties": true,
      "not": {
        "required": [
          "errors"
        ]
      }
    },
    {
      "title": "ProvidePerformanceFeedbackError",
      "description": "Error response - feedback rejected or could not be processed",
      "type": "object",
      "properties": {
        "errors": {
          "type": "array",
          "description": "Array of errors explaining why feedback was rejected (e.g., invalid measurement period, missing campaign data)",
          "items": {
            "$ref": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/core/error.json"
          },
          "minItems": 1
        },
        "context": {
          "$ref": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/core/context.json"
        },
        "ext": {
          "$ref": "https://adcontextprotocol.org/schemas/3.2.0-beta.0/core/ext.json"
        }
      },
      "required": [
        "errors"
      ],
      "additionalProperties": true,
      "not": {
        "anyOf": [
          {
            "required": [
              "success"
            ]
          },
          {
            "required": [
              "sandbox"
            ]
          }
        ]
      }
    }
  ],
  "properties": {}
}
