{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "/schemas/3.0.0-rc.3/creative/preview-creative-response.json",
  "title": "Preview Creative Response",
  "description": "Response containing preview links for one or more creatives. Format matches the request: single preview response for single requests, batch results for batch requests.",
  "oneOf": [
    {
      "title": "PreviewCreativeSingleResponse",
      "type": "object",
      "description": "Single preview response - each preview URL returns an HTML page that can be embedded in an iframe",
      "properties": {
        "response_type": {
          "type": "string",
          "const": "single",
          "description": "Discriminator indicating this is a single preview response"
        },
        "previews": {
          "type": "array",
          "description": "Array of preview variants. Each preview corresponds to an input set from the request. If no inputs were provided, returns a single default preview.",
          "items": {
            "type": "object",
            "properties": {
              "preview_id": {
                "type": "string",
                "description": "Unique identifier for this preview variant"
              },
              "renders": {
                "type": "array",
                "description": "Array of rendered pieces for this preview variant. Most formats render as a single piece. Companion ad formats (video + banner), multi-placement formats, and adaptive formats render as multiple pieces.",
                "items": {
                  "$ref": "/schemas/3.0.0-rc.3/creative/preview-render.json"
                },
                "minItems": 1
              },
              "input": {
                "type": "object",
                "description": "The input parameters that generated this preview variant. Echoes back the request input or shows defaults used.",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Human-readable name for this variant"
                  },
                  "macros": {
                    "type": "object",
                    "description": "Macro values applied to this variant",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "context_description": {
                    "type": "string",
                    "description": "Context description applied to this variant"
                  }
                },
                "required": [
                  "name"
                ]
              }
            },
            "required": [
              "preview_id",
              "renders",
              "input"
            ]
          },
          "minItems": 1
        },
        "interactive_url": {
          "type": "string",
          "format": "uri",
          "description": "Optional URL to an interactive testing page that shows all preview variants with controls to switch between them, modify macro values, and test different scenarios."
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "description": "ISO 8601 timestamp when preview links expire"
        },
        "context": {
          "$ref": "/schemas/3.0.0-rc.3/core/context.json"
        },
        "ext": {
          "$ref": "/schemas/3.0.0-rc.3/core/ext.json"
        }
      },
      "required": [
        "response_type",
        "previews",
        "expires_at"
      ],
      "additionalProperties": true
    },
    {
      "title": "PreviewCreativeBatchResponse",
      "type": "object",
      "description": "Batch preview response - contains results for multiple creative requests",
      "properties": {
        "response_type": {
          "type": "string",
          "const": "batch",
          "description": "Discriminator indicating this is a batch preview response"
        },
        "results": {
          "type": "array",
          "description": "Array of preview results corresponding to each request in the same order. results[0] is the result for requests[0], results[1] for requests[1], etc. Order is guaranteed even when some requests fail. Each result contains either a successful preview response or an error.",
          "items": {
            "type": "object",
            "properties": {
              "success": {
                "type": "boolean",
                "description": "Whether this preview request succeeded"
              },
              "creative_id": {
                "type": "string",
                "description": "ID of the creative this result corresponds to. Enables correlation when processing batch results."
              },
              "response": {
                "type": "object",
                "description": "Preview data for successful requests",
                "properties": {
                  "previews": {
                    "type": "array",
                    "description": "Array of preview variants for this creative",
                    "items": {
                      "type": "object",
                      "properties": {
                        "preview_id": {
                          "type": "string"
                        },
                        "renders": {
                          "type": "array",
                          "items": {
                            "$ref": "/schemas/3.0.0-rc.3/creative/preview-render.json"
                          },
                          "minItems": 1
                        },
                        "input": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "macros": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            "context_description": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "name"
                          ]
                        }
                      },
                      "required": [
                        "preview_id",
                        "renders",
                        "input"
                      ]
                    },
                    "minItems": 1
                  },
                  "interactive_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When the preview URLs expire"
                  }
                },
                "required": [
                  "previews",
                  "expires_at"
                ]
              },
              "errors": {
                "type": "array",
                "description": "Errors for failed requests",
                "items": {
                  "$ref": "/schemas/3.0.0-rc.3/core/error.json"
                },
                "minItems": 1
              }
            },
            "required": [
              "success",
              "creative_id"
            ],
            "oneOf": [
              {
                "title": "PreviewBatchResultSuccess",
                "properties": {
                  "success": {
                    "type": "boolean",
                    "const": true,
                    "description": "Indicates this preview request succeeded"
                  }
                },
                "required": [
                  "response"
                ]
              },
              {
                "title": "PreviewBatchResultError",
                "properties": {
                  "success": {
                    "type": "boolean",
                    "const": false,
                    "description": "Indicates this preview request failed"
                  }
                },
                "required": [
                  "errors"
                ]
              }
            ]
          },
          "minItems": 1
        },
        "context": {
          "$ref": "/schemas/3.0.0-rc.3/core/context.json"
        },
        "ext": {
          "$ref": "/schemas/3.0.0-rc.3/core/ext.json"
        }
      },
      "required": [
        "response_type",
        "results"
      ],
      "additionalProperties": true
    },
    {
      "title": "PreviewCreativeVariantResponse",
      "type": "object",
      "description": "Variant preview response - shows what a specific creative variant looked like when served during delivery",
      "properties": {
        "response_type": {
          "type": "string",
          "const": "variant",
          "description": "Discriminator indicating this is a variant preview response"
        },
        "variant_id": {
          "type": "string",
          "description": "Platform-assigned variant identifier"
        },
        "creative_id": {
          "type": "string",
          "description": "Creative identifier this variant belongs to"
        },
        "previews": {
          "type": "array",
          "description": "Array of rendered pieces for this variant. Most formats render as a single piece.",
          "items": {
            "type": "object",
            "properties": {
              "preview_id": {
                "type": "string",
                "description": "Unique identifier for this preview"
              },
              "renders": {
                "type": "array",
                "description": "Rendered pieces for this variant",
                "items": {
                  "$ref": "/schemas/3.0.0-rc.3/creative/preview-render.json"
                },
                "minItems": 1
              }
            },
            "required": [
              "preview_id",
              "renders"
            ]
          },
          "minItems": 1
        },
        "manifest": {
          "$ref": "/schemas/3.0.0-rc.3/core/creative-manifest.json",
          "description": "The rendered creative manifest for this variant — the actual output that was served, not the input assets"
        },
        "expires_at": {
          "type": "string",
          "format": "date-time",
          "description": "ISO 8601 timestamp when preview links expire"
        },
        "context": {
          "$ref": "/schemas/3.0.0-rc.3/core/context.json"
        },
        "ext": {
          "$ref": "/schemas/3.0.0-rc.3/core/ext.json"
        }
      },
      "required": [
        "response_type",
        "variant_id",
        "previews"
      ],
      "additionalProperties": true
    }
  ]
}
