{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/creative/sync-creatives-response.json",
  "title": "Sync Creatives Response",
  "description": "Response from creative sync operation. Exactly one of three shapes: (1) synchronous success — per-creative results in the creatives array (best-effort processing with per-item status/failures); (2) terminal failure — errors array with no creatives processed; (3) submitted task envelope — status 'submitted' with task_id when the whole operation is queued (batch ingestion, async review that must settle before per-item results can be issued). The submitted branch MAY carry advisory errors for non-blocking warnings; terminal failures belong in the error branch. Final per-item results land on the task completion artifact, not this envelope. These three shapes are mutually exclusive — a response has exactly one.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/protocol-envelope.json"
    }
  ],
  "oneOf": [
    {
      "title": "SyncCreativesSuccess",
      "description": "Success response - sync operation processed creatives (may include per-item failures)",
      "type": "object",
      "properties": {
        "dry_run": {
          "type": "boolean",
          "description": "Whether this was a dry run (no actual changes made)"
        },
        "creatives": {
          "type": "array",
          "description": "Results for each creative processed. Items with action='failed' indicate per-item validation/processing failures, not operation-level failures.",
          "items": {
            "type": "object",
            "properties": {
              "creative_id": {
                "type": "string",
                "description": "Creative ID from the request",
                "x-entity": "creative"
              },
              "revision_id": {
                "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/creative-revision-id.json",
                "description": "Exact revision_id from the matching request creative. When the agent advertises creative.supports_revisions, required for accepted created, updated, or unchanged items whose request supplied revision_id. A peer without that capability may ignore the request field. Forbidden on failed or deleted items."
              },
              "account": {
                "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/account.json",
                "description": "Account that owns this creative"
              },
              "action": {
                "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/enums/creative-action.json",
                "description": "Action taken for this creative during this sync operation (lifecycle operation, not approval state)."
              },
              "status": {
                "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/enums/creative-status.json",
                "description": "Advisory review-lifecycle state of the creative after this sync — a UI hint and polling-scheduling signal, NOT a spend-authorization gate. Orthogonal to action — action says what the sync did (created, updated, ...); status says where the creative sits in review. Values come from CreativeStatus only (processing, pending_review, approved, suspended, rejected, archived) — never from CreativeAction. Sellers with async review return processing or pending_review; sellers with synchronous review MAY return a terminal value (approved, rejected) or suspended when a recoverable dependency/authorization gate prevents serving. Buyers MUST NOT gate downstream spend or package activation on status: approved from this response — a compromised or buggy seller could declare approved while bypassing content-policy review. Reconcile via list_creatives or a signed review webhook before committing spend. Authoritative state is always via list_creatives. MUST be omitted when action is failed or deleted (the creative has no meaningful review state — failure details belong in the errors array; deleted creatives are gone from the library). Omit entirely when the seller has no review lifecycle at all."
              },
              "staged_update": {
                "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/creative-staged-update.json",
                "description": "Present when this item changed a live creative and the seller accepted the change in staged mode. action is updated, and status describes the version that keeps serving (normally approved), not the staged content. Track the staged update on list_creatives or by subscribing to creative.staged_update_changed. Omitted on failed and deleted items, and when no staged update is pending after this sync.",
                "x-status": "experimental",
                "x-added-in": "3.3.0"
              },
              "platform_id": {
                "type": "string",
                "description": "The seller's identifier for this creative in its source of truth. Also returned on list_creatives.",
                "$comment": "x-entity deliberately omitted: seller-opaque identifier in the seller's own namespace; buyers echo creative_id, never platform_id, on AdCP requests."
              },
              "localization": {
                "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/creative-localization-readback.json",
                "description": "Exact materialized locale-variant state. Required for every accepted creative whose request included a non-null localization object; omitted for unlocalized, failed, or deleted items. The enclosing creative status is the single review lifecycle for all variants.",
                "x-adcp-validation": {
                  "verifier_constraints": {
                    "lifecycle_source": "enclosing_creative.status",
                    "source_assets": "must_equal_request_creative.assets",
                    "accepted_localized_request": {
                      "actions": [
                        "created",
                        "updated",
                        "unchanged"
                      ],
                      "required_response_fields": [
                        "status",
                        "localization"
                      ],
                      "source_equal_properties": [
                        "locale_variant_id",
                        "locale"
                      ],
                      "target_match_key": "locale_variant_id",
                      "target_set": "exact",
                      "target_equal_properties": [
                        "locale"
                      ],
                      "localization_equal_properties": [
                        "default_locale_variant_id",
                        "unmatched_locale_action",
                        "locale_fallbacks"
                      ]
                    },
                    "forbidden_actions": [
                      "failed",
                      "deleted"
                    ]
                  },
                  "spec": "docs/creative/task-reference/sync_creatives.mdx#response"
                }
              },
              "changes": {
                "type": "array",
                "description": "Field names that were modified (only present when action='updated')",
                "items": {
                  "type": "string"
                }
              },
              "errors": {
                "type": "array",
                "description": "Validation or processing errors (only present when action='failed')",
                "items": {
                  "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/error.json"
                }
              },
              "warnings": {
                "type": "array",
                "description": "Non-fatal warnings about this creative",
                "items": {
                  "type": "string"
                }
              },
              "macro_resolution_results": {
                "type": "array",
                "items": {
                  "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/macro-resolution-result.json"
                },
                "description": "Per-token result for declared macros. Sellers include this on accepted items when macro declarations were evaluated, and may include it alongside a failed item's structured errors."
              },
              "preview_url": {
                "type": "string",
                "format": "uri",
                "description": "Preview URL for generative creatives (only present for generative formats)"
              },
              "expires_at": {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp when preview link expires (only present when preview_url exists)"
              },
              "assigned_to": {
                "type": "array",
                "description": "Package IDs this creative was successfully assigned to (only present when assignments were requested)",
                "items": {
                  "type": "string"
                }
              },
              "assignment_errors": {
                "type": "object",
                "description": "Assignment errors by package ID (only present when assignment failures occurred)",
                "patternProperties": {
                  "^[a-zA-Z0-9_-]+$": {
                    "type": "string",
                    "description": "Error message for this package assignment"
                  }
                },
                "additionalProperties": true
              }
            },
            "required": [
              "creative_id",
              "action"
            ],
            "additionalProperties": true,
            "allOf": [
              {
                "if": {
                  "properties": {
                    "action": {
                      "enum": [
                        "failed",
                        "deleted"
                      ]
                    }
                  },
                  "required": [
                    "action"
                  ]
                },
                "then": {
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "status"
                        ]
                      },
                      {
                        "required": [
                          "localization"
                        ]
                      },
                      {
                        "required": [
                          "revision_id"
                        ]
                      }
                    ]
                  }
                }
              },
              {
                "if": {
                  "required": [
                    "localization"
                  ]
                },
                "then": {
                  "required": [
                    "status"
                  ]
                }
              },
              {
                "x-adcp-validation": {
                  "verifier_constraints": {
                    "revision_echo": {
                      "required_capability": "creative.supports_revisions",
                      "request_match_key": "creative_id",
                      "request_field": "revision_id",
                      "accepted_actions": [
                        "created",
                        "updated",
                        "unchanged"
                      ],
                      "required_when_request_field_present": true,
                      "must_equal_request": true,
                      "forbidden_actions": [
                        "failed",
                        "deleted"
                      ]
                    }
                  },
                  "spec": "docs/creative/task-reference/sync_creatives.mdx#creative-revisions"
                }
              }
            ]
          }
        },
        "merges": {
          "type": "array",
          "x-added-in": "3.3.0",
          "description": "One entry per merge assignment operation the seller applied, in request order (under dry_run, one per merge that would be applied). Present exactly when the request contained merge operations and succeeded. A merge that fails verification fails the whole request with CREATIVE_MERGE_REJECTED, whose details list every rejected merge and its reason; a merge awaiting a person's confirmation is reported on the submitted task's completion artifact, never as a partial result here.",
          "items": {
            "type": "object",
            "properties": {
              "creative_id": {
                "type": "string",
                "minLength": 1,
                "description": "Buyer's creative that now holds the assignment.",
                "x-entity": "creative"
              },
              "package_id": {
                "type": "string",
                "minLength": 1,
                "x-entity": "package"
              },
              "merged_creative_id": {
                "type": "string",
                "minLength": 1,
                "description": "Seller-assigned creative whose assignment on package_id was merged into creative_id.",
                "x-entity": "creative"
              },
              "approval_status": {
                "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/enums/creative-approval-status.json",
                "description": "Approval state the merged assignment inherited from merged_creative_id."
              }
            },
            "required": [
              "creative_id",
              "package_id",
              "merged_creative_id",
              "approval_status"
            ],
            "additionalProperties": true
          }
        },
        "sandbox": {
          "type": "boolean",
          "description": "When true, this response contains simulated data from sandbox mode."
        },
        "context": {
          "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/context.json"
        },
        "ext": {
          "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/ext.json"
        }
      },
      "required": [
        "creatives"
      ],
      "additionalProperties": true,
      "not": {
        "anyOf": [
          {
            "required": [
              "errors"
            ]
          },
          {
            "required": [
              "task_id"
            ]
          },
          {
            "required": [
              "warnings"
            ]
          },
          {
            "properties": {
              "status": {
                "const": "submitted"
              }
            },
            "required": [
              "status"
            ]
          }
        ]
      }
    },
    {
      "title": "SyncCreativesError",
      "description": "Error response - operation failed completely, no creatives were processed",
      "type": "object",
      "properties": {
        "errors": {
          "type": "array",
          "description": "Operation-level errors that prevented processing any creatives (e.g., authentication failure, service unavailable, invalid request format)",
          "items": {
            "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/error.json"
          },
          "minItems": 1
        },
        "context": {
          "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/context.json"
        },
        "ext": {
          "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/ext.json"
        }
      },
      "required": [
        "errors"
      ],
      "additionalProperties": true,
      "not": {
        "anyOf": [
          {
            "required": [
              "creatives"
            ]
          },
          {
            "required": [
              "merges"
            ]
          },
          {
            "required": [
              "dry_run"
            ]
          },
          {
            "required": [
              "sandbox"
            ]
          },
          {
            "required": [
              "task_id"
            ]
          },
          {
            "required": [
              "warnings"
            ]
          },
          {
            "properties": {
              "status": {
                "const": "submitted"
              }
            },
            "required": [
              "status"
            ]
          }
        ]
      }
    },
    {
      "allOf": [
        {
          "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/task-submitted.json"
        }
      ],
      "title": "SyncCreativesSubmitted",
      "description": "Async task envelope returned when the whole sync operation cannot be confirmed before the response is emitted — for example, when the seller batches ingestion, when async review must settle before per-item results can be issued, or when governance review gates the sync. The buyer invokes get_task_status with task_id or receives a webhook when the task completes; the creatives array with per-item action/status lands in the terminal result, not this envelope. Per-item async review (an item in pending_review while the rest of the sync resolves synchronously) belongs on the SyncCreativesSuccess branch with status: pending_review, not here.",
      "type": "object",
      "properties": {
        "errors": {
          "type": "array",
          "description": "Optional advisory errors accompanying the submitted envelope. Use only for non-blocking warnings (e.g., throttled_severity advisories, governance observations). Terminal failures belong in the error branch, not here.",
          "items": {
            "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/error.json"
          }
        },
        "context": {
          "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/context.json"
        },
        "ext": {
          "$ref": "https://adcontextprotocol.org/schemas/3.3.0-beta.3/core/ext.json"
        }
      },
      "additionalProperties": true,
      "not": {
        "anyOf": [
          {
            "required": [
              "creatives"
            ]
          },
          {
            "required": [
              "merges"
            ]
          },
          {
            "required": [
              "warnings"
            ]
          }
        ]
      }
    }
  ],
  "properties": {}
}
