Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
]
}
]
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agentsmust echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
],
"additionalProperties": false
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand All @@ -68,6 +73,11 @@
"$ref": "/schemas/v1/core/error.json"
},
"minItems": 1
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
"description": "End date for reporting period (YYYY-MM-DD)"
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agentsmust echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,28 @@
"type": "number",
"description": "Delivery pace (1.0 = on track, <1.0 = behind, >1.0 = ahead)",
"minimum": 0
},
"pricing_model": {
"$ref": "/schemas/v1/enums/pricing-model.json",
"description": "The pricing model used for this package (e.g., cpm, cpcv, cpp). Indicates how the package is billed and which metrics are most relevant for optimization."
},
"rate": {
"type": "number",
"description": "The pricing rate for this package in the specified currency. For fixed-rate pricing, this is the agreed rate (e.g., CPM rate of 12.50 means $12.50 per 1,000 impressions). For auction-based pricing, this represents the effective rate based on actual delivery.",
"minimum": 0
},
"currency": {
"type": "string",
"description": "ISO 4217 currency code (e.g., USD, EUR, GBP) for this package's pricing. Indicates the currency in which the rate and spend values are denominated. Different packages can use different currencies when supported by the publisher.",
"pattern": "^[A-Z]{3}$"
}
},
"required": [
"package_id",
"spend"
"spend",
"pricing_model",
"rate",
"currency"
]
}
]
Expand Down Expand Up @@ -236,6 +253,11 @@
"items": {
"$ref": "/schemas/v1/core/error.json"
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
}
},
"additionalProperties": false
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agentsmust echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"required": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
"items": {
"$ref": "/schemas/v1/core/error.json"
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"description": "Publisher domain to filter by (e.g., 'cnn.com', 'espn.com')"
},
"minItems": 1
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agentsmust echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
"items": {
"$ref": "/schemas/v1/core/error.json"
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
"name_search": {
"type": "string",
"description": "Search for formats by name (case-insensitive partial match)"
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agents must echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
"items": {
"$ref": "/schemas/v1/core/error.json"
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@
"sub_assets"
]
}
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agentsmust echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@
}
},
"additionalProperties": false
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"push_notification_config": {
"$ref": "/schemas/v1/core/push-notification-config.json",
"description": "Optional webhook configuration for async sync notifications. Publisher will send webhook when sync completes if operation takes longer than immediate response time (typically for large bulk operations or manual approval/HITL)."
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agents must echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"required": [
Expand Down
10 changes: 10 additions & 0 deletions schemas/v1/_schemas_v1_media-buy_sync-creatives-response_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
],
"additionalProperties": false
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand All @@ -117,6 +122,11 @@
"$ref": "/schemas/v1/core/error.json"
},
"minItems": 1
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
"push_notification_config": {
"$ref": "/schemas/v1/core/push-notification-config.json",
"description": "Optional webhook configuration for async update notifications. Publisher will send webhook when update completes if operation takes longer than immediate response time."
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agents must echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"oneOf": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
],
"additionalProperties": false
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand All @@ -70,6 +75,11 @@
"$ref": "/schemas/v1/core/error.json"
},
"minItems": 1
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
5 changes: 5 additions & 0 deletions schemas/v1/_schemas_v1_signals_get-signals-request_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
"type": "integer",
"description": "Maximum number of results to return",
"minimum": 1
},
"context": {
"type": "object",
"description": "Initiator-provided context included in the request payload. Agents must echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.",
"additionalProperties": true
}
},
"required": [
Expand Down
5 changes: 5 additions & 0 deletions schemas/v1/_schemas_v1_signals_get-signals-response_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
"items": {
"$ref": "/schemas/v1/core/error.json"
}
},
"context": {
"type": "object",
"description": "Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.",
"additionalProperties": true
}
},
"required": [
Expand Down
87 changes: 3 additions & 84 deletions src/admin/blueprints/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,90 +17,9 @@
api_bp = Blueprint("api", __name__)


@api_bp.route("/formats/list", methods=["GET"])
def list_formats():
"""List all available creative formats from registered creative agents.

Query params:
tenant_id: Optional tenant ID for tenant-specific formats

Returns:
JSON with format list grouped by agent URL
"""
from src.core.format_resolver import list_available_formats

tenant_id = request.args.get("tenant_id")

logger.info(f"[/api/formats/list] Fetching formats for tenant_id={tenant_id}")

try:
# Get all formats from creative agent registry
formats = list_available_formats(tenant_id=tenant_id)

logger.info(f"[/api/formats/list] Successfully fetched {len(formats)} formats from creative agents")

if not formats:
logger.warning(f"[/api/formats/list] No formats returned for tenant_id={tenant_id}")
return jsonify(
{
"agents": {},
"total_formats": 0,
"warning": "No creative formats available. Check creative agent configuration.",
}
)

# Group formats by agent URL for frontend compatibility
agents = {}
for fmt in formats:
agent_url = fmt.agent_url
if agent_url not in agents:
agents[agent_url] = []

# Convert to dict for JSON serialization
try:
# Handle FormatId object - extract string value
format_id_str = fmt.format_id.id if hasattr(fmt.format_id, "id") else str(fmt.format_id)

format_dict = {
"format_id": format_id_str,
"name": fmt.name,
"type": fmt.type,
"category": fmt.category,
"description": fmt.description,
"iab_specification": fmt.iab_specification,
}

# Add dimensions if available
dimensions = fmt.get_primary_dimensions()
if dimensions:
width, height = dimensions
format_dict["dimensions"] = f"{width}x{height}"

agents[agent_url].append(format_dict)
except Exception as fmt_error:
logger.error(
f"[/api/formats/list] Error serializing format {getattr(fmt, 'format_id', 'unknown')}: {fmt_error}",
exc_info=True,
)
# Continue with other formats

logger.info(
f"[/api/formats/list] Returning {len(agents)} agent(s) with {sum(len(fmts) for fmts in agents.values())} total formats"
)
return jsonify({"agents": agents, "total_formats": len(formats)})
except Exception as e:
logger.error(f"[/api/formats/list] Error listing formats for tenant_id={tenant_id}: {e}", exc_info=True)
return (
jsonify(
{
"error": str(e),
"agents": {},
"error_type": type(e).__name__,
"message": "Failed to fetch creative formats. Check server logs for details.",
}
),
500,
)
# Note: /formats/list route moved to format_search.py blueprint
# (registered at /api/formats/list via format_search_bp)
# This avoids route conflicts and uses the proper async registry pattern


@api_bp.route("/health", methods=["GET"])
Expand Down
Loading