{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "/schemas/3.0.18/media-buy/sync-event-sources-response.json",
  "title": "Sync Event Sources Response",
  "description": "Response from event source sync operation. Returns either per-source results OR operation-level errors.",
  "type": "object",
  "oneOf": [
    {
      "title": "SyncEventSourcesSuccess",
      "description": "Success response - sync operation processed event sources",
      "type": "object",
      "properties": {
        "event_sources": {
          "type": "array",
          "description": "Results for each event source, including both synced and seller-managed sources on the account",
          "items": {
            "type": "object",
            "properties": {
              "event_source_id": {
                "type": "string",
                "description": "Event source ID from the request",
                "x-entity": "event_source"
              },
              "name": {
                "type": "string",
                "description": "Name of the event source"
              },
              "seller_id": {
                "type": "string",
                "description": "Seller-assigned identifier for this event source (the ID in the seller's ad platform)"
              },
              "event_types": {
                "type": "array",
                "description": "Event types this source handles",
                "items": {
                  "$ref": "/schemas/3.0.18/enums/event-type.json"
                }
              },
              "action_source": {
                "$ref": "/schemas/3.0.18/enums/action-source.json",
                "description": "Type of event source (website pixel, app SDK, in-store, etc.)"
              },
              "managed_by": {
                "type": "string",
                "enum": ["buyer", "seller"],
                "description": "Who manages this event source. 'buyer' = configured via this sync. 'seller' = always-on, managed by the seller (e.g. Amazon sales attribution for Amazon advertisers)."
              },
              "setup": {
                "type": "object",
                "description": "Implementation details for activating this event source (e.g. JavaScript tag, pixel URL)",
                "properties": {
                  "snippet": {
                    "type": "string",
                    "description": "Code snippet to place on the site (JavaScript, HTML pixel, etc.)"
                  },
                  "snippet_type": {
                    "type": "string",
                    "enum": ["javascript", "html", "pixel_url", "server_only"],
                    "description": "Type of implementation. 'server_only' means no client-side tag is needed."
                  },
                  "instructions": {
                    "type": "string",
                    "description": "Human/agent-readable setup instructions"
                  }
                },
                "additionalProperties": true
              },
              "action": {
                "type": "string",
                "enum": ["created", "updated", "unchanged", "deleted", "failed"],
                "description": "Action taken for this event source"
              },
              "health": {
                "$ref": "/schemas/3.0.18/core/event-source-health.json",
                "description": "Health assessment for this event source. Reflects event volume, data quality, and parameter completeness. Sellers that support health scoring include this on every source (buyer-managed and seller-managed). Absent when the seller does not evaluate event source health."
              },
              "errors": {
                "type": "array",
                "description": "Errors for this event source (only present when action='failed')",
                "items": {
                  "$ref": "/schemas/3.0.18/core/error.json"
                }
              }
            },
            "required": ["event_source_id", "action"],
            "additionalProperties": true
          }
        },
        "sandbox": {
          "type": "boolean",
          "description": "When true, this response contains simulated data from sandbox mode."
        },
        "context": {
          "$ref": "/schemas/3.0.18/core/context.json"
        },
        "ext": {
          "$ref": "/schemas/3.0.18/core/ext.json"
        }
      },
      "required": ["event_sources"],
      "additionalProperties": true,
      "not": {
        "required": ["errors"]
      }
    },
    {
      "title": "SyncEventSourcesError",
      "description": "Error response - operation failed completely",
      "type": "object",
      "properties": {
        "errors": {
          "type": "array",
          "description": "Operation-level errors that prevented processing",
          "items": {
            "$ref": "/schemas/3.0.18/core/error.json"
          },
          "minItems": 1
        },
        "context": {
          "$ref": "/schemas/3.0.18/core/context.json"
        },
        "ext": {
          "$ref": "/schemas/3.0.18/core/ext.json"
        }
      },
      "required": ["errors"],
      "additionalProperties": true,
      "not": {
        "anyOf": [
          { "required": ["event_sources"] },
          { "required": ["sandbox"] }
        ]
      }
    }
  ]
}
